Skip to content

Instantly share code, notes, and snippets.

@johnbellone
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnbellone/5a72111898c7709dddeb to your computer and use it in GitHub Desktop.
Save johnbellone/5a72111898c7709dddeb to your computer and use it in GitHub Desktop.
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