Simplify and improve chef attribute handling
Set the attributes in a Ruby file under /etc/chef/client.d/ instead of editing /etc/chef/client.rb Now uses the new whitelist attribute: https://docs.chef.io/client/19/cookbooks/attributes/attribute_persistence/ Local chef config also uses the same file. That means there is no longer a need to use the sanitize script to remove override and default attributes from nodes.
This commit is contained in:
+2
-22
@@ -8,27 +8,7 @@ data_bag_path "data_bags"
|
||||
encrypted_data_bag_secret "#{current_dir}/encrypted_data_bag_secret"
|
||||
local_mode true # Chef local mode, replacing Solo
|
||||
|
||||
# Knife-Zero config, see https://knife-zero.github.io/40_configuration/
|
||||
# Prevent attributes from being saved to the node files
|
||||
knife[:automatic_attribute_whitelist] = %w[
|
||||
fqdn
|
||||
os
|
||||
os_version
|
||||
hostname
|
||||
ipaddress
|
||||
roles
|
||||
recipes
|
||||
ipaddress
|
||||
platform
|
||||
platform_version
|
||||
cloud
|
||||
cloud_v2
|
||||
chef_packages
|
||||
]
|
||||
|
||||
# Added to /etc/chef/client.rb on node bootstrap
|
||||
# https://docs.chef.io/attribute_persistence/
|
||||
# Source of truth: site-cookbooks/kosmos-base/files/default/chef_normal_attributes.yml
|
||||
normal_attrs = YAML.load_file(File.expand_path("../site-cookbooks/kosmos-base/files/default/chef_normal_attributes.yml", __dir__))
|
||||
knife[:normal_attribute_allowlist] = normal_attrs
|
||||
knife[:allowed_normal_attributes] = normal_attrs
|
||||
# Source of truth: site-cookbooks/kosmos-base/files/default/chef_attributes.rb
|
||||
client_d_dir(File.expand_path("../site-cookbooks/kosmos-base/files/default/chef_attributes.rb"))
|
||||
|
||||
Reference in New Issue
Block a user