Hydrate a Chef Server with generated keys.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root_path = File.join(File.dirname(__FILE__), '.chef') | |
chef_data_bag 'clients' | |
%w(chef-validator blp-validator).each do |name| | |
key = OpenSSL::PKey::RSA.new IO.read(File.join(root_path, "#{name}.pem")) | |
chef_data_bag_item name do | |
data_bag 'clients' | |
raw_data({ | |
chef_server: { | |
enabled: true, | |
validator: true, | |
client_key: key.public_key.to_pem | |
} | |
}) | |
end | |
end | |
chef_data_bag 'admins' | |
%w(jbellone pyanni ske).each do |name| | |
key = OpenSSL::PKey::RSA.new(2048) | |
IO.write(File.join(root_path, "#{name}.pem"), key.to_pem) | |
chef_data_bag_item name do | |
data_bag 'admins' | |
raw_data({ | |
chef_server: { | |
enabled: true, | |
admin: true, | |
client_key: key.public_key.to_pem | |
} | |
}) | |
end | |
end | |
machine 'chef-server' do | |
run_list ['chef-server-populator::data_bag'] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment