Skip to content

Instantly share code, notes, and snippets.

@johnbellone

johnbellone/chef-server.rb

Last active Aug 29, 2015
Embed
What would you like to do?
Hydrate a Chef Server with generated keys.
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