diff --git a/README.md b/README.md index ac973dc..71d8e33 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ support, please pin your environment to version 0.4.0. * Create json for organization, user, and (optionally) client(s) * Run chef-solo -See the `default[:chef_server_populator][:solo_org]` and -`default[:chef_server_populator][:solo_org_user]` attribute hashes in +See the `default['chef_server_populator']['solo_org']` and +`default['chef_server_populator']['solo_org_user']` attribute hashes in `attributes/default.rb` for the required attribute structure. **When converging with chef-client:** @@ -29,7 +29,7 @@ See the `default[:chef_server_populator][:solo_org]` and Applicable attributes: -* `node[:chef_server_populator][:databag]` - name of the data bag +* `node['chef_server_populator']['databag']` - name of the data bag Structure of the data bag item: @@ -97,15 +97,15 @@ the full name will be used, as the option is not parsed correctly **Restoring from a backup:** -* Set path to restore file with node[:chef_server_populator][:restore][:file] +* Set path to restore file with `node['chef_server_populator']['restore']['file']` * The restore recipe is run if a restore file is set * The restore file can be remote or local **When enabling backups:** * Include chef-server-populator::restore recipe -* Set backup cron interval with node[:chef_server_populator][:schedule] -* Optionally set a remote storage location with node[:chef_server_populator][:backup][:remote][:connection] +* Set backup cron interval with `node['chef_server_populator']['schedule']` +* Optionally set a remote storage location with `node['chef_server_populator']['backup']['remote']['connection']` * Backups include both a pg_dump of the entire chef database and a tarball of the Chef data directory ## Public Key Format @@ -130,14 +130,14 @@ openssl rsa -in .pem -pubout ## Extras -Need to use the IP address of the node for a bit, or another name instead of -having `node[:fqdn]`? +Need to use the IP address of the node for a bit, or another name instead of +having `node['fqdn']`? -* `node[:chef_server_populator][:servername_override]` +* `node['chef_server_populator']['servername_override']` Keep chef server configured via chef client: -* `node[:chef_server_populator][:chef_server]` +* `node['chef_server_populator']['chef_server']` If the hash is non-empty, it will write the chef-server `dna.json` and trigger a `reconfigure` when ever the attributes are updated. diff --git a/attributes/default.rb b/attributes/default.rb index d208ed5..ccc25e7 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,36 +1,36 @@ -default[:chef_server_populator][:configuration_directory] = '/etc/chef-server/populator' -default[:chef_server_populator][:base_path] = '/tmp/chef-server-populator' -default[:chef_server_populator][:clients] = {} -default[:chef_server_populator][:knife_exec] = '/usr/bin/knife' -default[:chef_server_populator][:user] = 'admin' -default[:chef_server_populator][:pem] = '/etc/chef-server/admin.pem' -default[:chef_server_populator][:databag] = nil -default[:chef_server_populator][:user_databag] = nil +default['chef_server_populator']['configuration_directory'] = '/etc/chef-server/populator' +default['chef_server_populator']['base_path'] = '/tmp/chef-server-populator' +default['chef_server_populator']['clients'] = {} +default['chef_server_populator']['knife_exec'] = '/usr/bin/knife' +default['chef_server_populator']['user'] = 'admin' +default['chef_server_populator']['pem'] = '/etc/chef-server/admin.pem' +default['chef_server_populator']['databag'] = nil +default['chef_server_populator']['user_databag'] = nil -default[:chef_server_populator][:endpoint] = nil +default['chef_server_populator']['endpoint'] = nil -default[:chef_server_populator][:backup_gems][:miasma] = '~> 0.2' +default['chef_server_populator']['backup_gems']['miasma'] = '~> 0.2' # Deprecated in favor of endpoint -default[:chef_server_populator][:servername_override] = nil +default['chef_server_populator']['servername_override'] = nil # The :chef_server attribute is passed to chef-server cookbook # Default the ttl since it kills runs with 403s on templates with # annoying frequency -default[:chef_server_populator][:chef_server][:configuration][:opscode_erchef][:s3_url_ttl] = 3600 +default['chef_server_populator']['chef_server']['configuration']['opscode_erchef']['s3_url_ttl'] = 3600 -default[:chef_server_populator][:cookbook_auto_install] = true +default['chef_server_populator']['cookbook_auto_install'] = true -default[:chef_server_populator][:restore][:file] = '' -default[:chef_server_populator][:restore][:data] = '' -default[:chef_server_populator][:restore][:local_path] = '/tmp/' +default['chef_server_populator']['restore']['file'] = '' +default['chef_server_populator']['restore']['data'] = '' +default['chef_server_populator']['restore']['local_path'] = '/tmp/' -default[:chef_server_populator][:backup][:dir] = '/tmp/chef-server/backup' -default[:chef_server_populator][:backup][:filename] = 'chef-server-full' -default[:chef_server_populator][:backup][:remote][:connection] = nil -default[:chef_server_populator][:backup][:remote][:directory] = nil -default[:chef_server_populator][:backup][:remote][:file_prefix] = nil -default[:chef_server_populator][:backup][:schedule] = { +default['chef_server_populator']['backup']['dir'] = '/tmp/chef-server/backup' +default['chef_server_populator']['backup']['filename'] = 'chef-server-full' +default['chef_server_populator']['backup']['remote']['connection'] = nil +default['chef_server_populator']['backup']['remote']['directory'] = nil +default['chef_server_populator']['backup']['remote']['file_prefix'] = nil +default['chef_server_populator']['backup']['schedule'] = { :minute => '33', :hour => '3' } @@ -39,20 +39,20 @@ #imaginable case you will want to replace some or all of these with #your own values. -default[:chef_server_populator][:solo_org] = { - :org_name => 'inception_llc', - :full_name => 'Chef Inception Organization', - :validator_pub_key => 'validator_pub.pem' +default['chef_server_populator']['solo_org'] = { + 'org_name' => 'inception_llc', + 'full_name' => 'Chef Inception Organization', + 'validator_pub_key' => 'validator_pub.pem' } -default[:chef_server_populator][:solo_org_user] = { - :name => 'populator', - :first => 'Populator', - :last => 'User', - :email => 'pop@example.com', - :pub_key => 'user_pub.pem' +default['chef_server_populator']['solo_org_user'] = { + 'name' => 'populator', + 'first' => 'Populator', + 'last' => 'User', + 'email' => 'pop@example.com', + 'pub_key' => 'user_pub.pem', } -default[:chef_server_populator][:server_org] = 'inception_llc' +default['chef_server_populator']['server_org'] = 'inception_llc' #If this is set to nil, the configurator recipe will set it to the server_org. -default[:chef_server_populator][:default_org] = nil +default['chef_server_populator']['default_org'] = nil diff --git a/recipes/backups.rb b/recipes/backups.rb index 2a3f127..bc8c322 100644 --- a/recipes/backups.rb +++ b/recipes/backups.rb @@ -1,4 +1,4 @@ -directory node[:chef_server_populator][:backup][:dir] do +directory node['chef_server_populator']['backup']['dir'] do recursive true owner 'opscode-pgsql' mode '0755' @@ -6,7 +6,7 @@ #Upload to Remote Storage # Include fog -case node[:platform_family] +case node['platform_family'] when 'debian' packages = %w(gcc libxml2 libxml2-dev libxslt-dev) when 'rhel' @@ -16,7 +16,7 @@ package fog_dep end -node[:chef_server_populator][:backup_gems].each_pair do |gem_name, gem_version| +node['chef_server_populator']['backup_gems'].each_pair do |gem_name, gem_version| gem_package gem_name do if !gem_version.nil? version gem_version @@ -25,15 +25,15 @@ end end -directory node[:chef_server_populator][:configuration_directory] do +directory node['chef_server_populator']['configuration_directory'] do recursive true owner 'root' mode 0700 end -file File.join(node[:chef_server_populator][:configuration_directory], 'backup.json') do +file File.join(node['chef_server_populator']['configuration_directory'], 'backup.json') do content Chef::JSONCompat.to_json_pretty( - node[:chef_server_populator][:backup].merge( + node['chef_server_populator']['backup'].merge( :cookbook_version => node.run_context.cookbook_collection['chef-server-populator'].version ) ) @@ -49,7 +49,7 @@ cron 'Chef Server Backups' do command '/usr/local/bin/chef-server-backup' - node[:chef_server_populator][:backup][:schedule].each do |k,v| + node['chef_server_populator']['backup']['schedule'].each do |k,v| send(k,v) end path "/opt/chef/embedded/bin/:/usr/bin:/usr/local/bin:/bin" diff --git a/recipes/client.rb b/recipes/client.rb index 3ad08db..c2f8b4d 100644 --- a/recipes/client.rb +++ b/recipes/client.rb @@ -1,6 +1,6 @@ include_recipe 'chef-server-populator::configurator' -knife_cmd = "#{node[:chef_server_populator][:knife_exec]}" +knife_cmd = node['chef_server_populator']['knife_exec'] knife_opts = '-c /etc/opscode/pivotal.rb' ssl_port = %w(chef-server configuration nginx ssl_port).inject(node) do |memo, key| @@ -10,14 +10,14 @@ pg_cmd = "/opt/chef-server/embedded/bin/psql -d opscode_chef" -if(node[:chef_server_populator][:databag]) +if(node['chef_server_populator']['databag']) begin - items = data_bag(node[:chef_server_populator][:databag]).map do |bag_item| - item = data_bag_item(node[:chef_server_populator][:databag], bag_item).fetch('chef_server', {}) + items = data_bag(node['chef_server_populator']['databag']).map do |bag_item| + item = data_bag_item(node['chef_server_populator']['databag'], bag_item).fetch('chef_server', {}) if item.empty? Chef::Log.info("No chef-server data for #{bag_item['id']}") end - item.merge('client' => data_bag_item(node[:chef_server_populator][:databag], bag_item)['id'], + item.merge('client' => data_bag_item(node['chef_server_populator']['databag'], bag_item)['id'], 'pub_key' => item['client_key'], 'enabled' => item['enabled'], 'admin' => item.fetch('admin', false), @@ -36,7 +36,7 @@ item.merge('full_name' => item.fetch('full_name', item['client'].capitalize)) command "chef-server-ctl org-create #{item['client']} #{item['full_name']}" not_if "chef-server-ctl org-list | grep '^#{item['client']}$'" - if item['client'] == node[:chef_server_populator][:default_org] + if item['client'] == node['chef_server_populator']['default_org'] notifies :reconfigure, 'chef_server_ingredient[chef-server-core]', :immediately end end @@ -49,7 +49,7 @@ end end execute "add org validator key: #{item['client']}" do - if (node['chef-server'][:version].to_f >= 12.1 || node['chef-server'][:version].to_f == 0.0) + if (node['chef-server']['version'].to_f >= 12.1 || node['chef-server']['version'].to_f == 0.0) command "chef-server-ctl add-client-key #{item['client']} #{item['client']}-validator --public-key-path #{key_file} --key-name populator" else command "chef-server-ctl add-client-key #{item['client']} #{item['client']}-validator #{key_file} --key-name populator" @@ -102,7 +102,7 @@ not_if "chef-server-ctl user-list | grep '^#{item['client']}$'" end execute "set user key: #{item['client']}" do - if (node['chef-server'][:version].to_f >= 12.1 || node['chef-server'][:version].to_f == 0.0) + if (node['chef-server']['version'].to_f >= 12.1 || node['chef-server']['version'].to_f == 0.0) command "chef-server-ctl add-user-key #{item['client']} --public-key-path #{key_file} --key-name populator" else command "chef-server-ctl add-user-key #{item['client']} #{key_file} --key-name populator" @@ -130,10 +130,10 @@ end if(options) if(options.has_key?('enabled')) - item[:enabled] = options[:enabled] + item['enabled'] = options['enabled'] end if(options.has_key?('admin')) - item[:admin] = options[:admin] + item['admin'] = options['admin'] end end if(item['enabled'] == false) @@ -158,16 +158,16 @@ end if(item['pub_key']) execute "set client key: #{item['client']}" do - if (node['chef-server'][:version].to_f >= 12.1 || node['chef-server'][:version].to_f == 0.0) - command "chef-server-ctl add-client-key #{org || node[:chef_server_populator][:default_org]} #{item['client']} --public-key-path #{key_file} --key-name populator" + if (node['chef-server']['version'].to_f >= 12.1 || node['chef-server']['version'].to_f == 0.0) + command "chef-server-ctl add-client-key #{org || node['chef_server_populator']['default_org']} #{item['client']} --public-key-path #{key_file} --key-name populator" else - command "chef-server-ctl add-client-key #{org || node[:chef_server_populator][:default_org]} #{item['client']} #{key_file} --key-name populator" + command "chef-server-ctl add-client-key #{org || node['chef_server_populator']['default_org']} #{item['client']} #{key_file} --key-name populator" end - not_if "chef-server-ctl list-client-keys #{org || node[:chef_server_populator][:default_org]} #{item['client']} | grep 'name: populator$'" + not_if "chef-server-ctl list-client-keys #{org || node['chef_server_populator']['default_org']} #{item['client']} | grep 'name: populator$'" end execute "delete default client key: #{item['client']}" do - command "chef-server-ctl delete-client-key #{org || node[:chef_server_populator][:default_org]} #{item['client']} default" - only_if "chef-server-ctl list-client-keys #{org || node[:chef_server_populator][:default_org]} #{item['client']} | grep 'name: default$'" + command "chef-server-ctl delete-client-key #{org || node['chef_server_populator']['default_org']} #{item['client']} default" + only_if "chef-server-ctl list-client-keys #{org || node['chef_server_populator']['default_org']} #{item['client']} | grep 'name: default$'" end end end diff --git a/recipes/configurator.rb b/recipes/configurator.rb index 81fd3d1..d7ee916 100644 --- a/recipes/configurator.rb +++ b/recipes/configurator.rb @@ -1,27 +1,27 @@ -if(node[:chef_server_populator][:default_org]) - node.default[:chef_server_populator][:chef_server][:configuration][:default_orgname] = node[:chef_server_populator][:default_org] +if(node['chef_server_populator']['default_org']) + node.default['chef_server_populator']['chef_server']['configuration']['default_orgname'] = node['chef_server_populator']['default_org'] end -unless(node[:chef_server_populator][:endpoint]) - node.default[:chef_server_populator][:endpoint] = node[:chef_server_populator][:servername_override] +unless(node['chef_server_populator']['endpoint']) + node.default['chef_server_populator']['endpoint'] = node['chef_server_populator']['servername_override'] end -if(node[:chef_server_populator][:endpoint]) - node.set['chef-server'][:api_fqdn] = - node.set[:chef_server_populator][:chef_server][:configuration][:nginx][:server_name] = - node.set[:chef_server_populator][:chef_server][:configuration][:bookshelf][:vip] = - node.set[:chef_server_populator][:chef_server][:configuration][:lb][:api_fqdn] = - node.set[:chef_server_populator][:chef_server][:configuration][:lb][:web_ui_fqdn] = node[:chef_server_populator][:endpoint] - node.set[:chef_server_populator][:chef_server][:configuration][:nginx][:url] = - node.set[:chef_server_populator][:chef_server][:configuration][:bookshelf][:url] = "https://#{node[:chef_server_populator][:endpoint]}" +if(node['chef_server_populator']['endpoint']) + node.set['chef-server']['api_fqdn'] = + node.set['chef_server_populator']['chef_server']['configuration']['nginx']['server_name'] = + node.set['chef_server_populator']['chef_server']['configuration']['bookshelf']['vip'] = + node.set['chef_server_populator']['chef_server']['configuration']['lb']['api_fqdn'] = + node.set['chef_server_populator']['chef_server']['configuration']['lb']['web_ui_fqdn'] = node['chef_server_populator']['endpoint'] + node.set['chef_server_populator']['chef_server']['configuration']['nginx']['url'] = + node.set['chef_server_populator']['chef_server']['configuration']['bookshelf']['url'] = "https://#{node['chef_server_populator']['endpoint']}" else - node.set['chef-server'][:api_fqdn] = - node.set[:chef_server_populator][:chef_server][:configuration][:nginx][:server_name] = - node.set[:chef_server_populator][:chef_server][:configuration][:bookshelf][:vip] = - node.set[:chef_server_populator][:chef_server][:configuration][:lb][:api_fqdn] = - node.set[:chef_server_populator][:chef_server][:configuration][:lb][:web_ui_fqdn] = node[:fqdn] - node.set[:chef_server_populator][:chef_server][:configuration][:nginx][:url] = - node.set[:chef_server_populator][:chef_server][:configuration][:bookshelf][:url] = "https://#{node[:fqdn]}" + node.set['chef-server']['api_fqdn'] = + node.set['chef_server_populator']['chef_server']['configuration']['nginx']['server_name'] = + node.set['chef_server_populator']['chef_server']['configuration']['bookshelf']['vip'] = + node.set['chef_server_populator']['chef_server']['configuration']['lb']['api_fqdn'] = + node.set['chef_server_populator']['chef_server']['configuration']['lb']['web_ui_fqdn'] = node['fqdn'] + node.set['chef_server_populator']['chef_server']['configuration']['nginx']['url'] = + node.set['chef_server_populator']['chef_server']['configuration']['bookshelf']['url'] = "https://#{node['fqdn']}" end mash_maker = lambda do |x| @@ -39,17 +39,17 @@ end current_server_config = mash_maker.call(node['chef-server']) -populator_server_config = mash_maker.call(node[:chef_server_populator][:chef_server] || {}) +populator_server_config = mash_maker.call(node['chef_server_populator']['chef_server'] || {}) -if(current_server_config[:configuration].is_a?(Hash)) - populator_server_config[:configuration] = Chef::Mixin::DeepMerge.deep_merge( - current_server_config[:configuration], +if(current_server_config['configuration'].is_a?(Hash)) + populator_server_config['configuration'] = Chef::Mixin::DeepMerge.deep_merge( + current_server_config['configuration'], populator_server_config.fetch(:configuration, Mash.new) ) end -if(populator_server_config[:configuration]) - populator_server_config[:configuration] = populator_server_config[:configuration].map do |k,v| +if(populator_server_config['configuration']) + populator_server_config['configuration'] = populator_server_config['configuration'].map do |k,v| "#{k}(#{v.inspect})" end.join("\n") end diff --git a/recipes/default.rb b/recipes/default.rb index e6de05e..c7e1aa9 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -7,7 +7,7 @@ include_recipe 'chef-server-populator::client' end -if(!node[:chef_server_populator][:restore][:file].empty? && - node[:chef_server_populator][:restore][:file] != 'none') +if(!node['chef_server_populator']['restore']['file'].empty? && + node['chef_server_populator']['restore']['file'] != 'none') include_recipe 'chef-server-populator::restore' end diff --git a/recipes/org.rb b/recipes/org.rb index 4bf0e05..38277a1 100644 --- a/recipes/org.rb +++ b/recipes/org.rb @@ -1,29 +1,29 @@ include_recipe 'chef-server-populator::configurator' include_recipe 'chef-server' -conf_dir = node[:chef_server_populator][:base_path] +conf_dir = node['chef_server_populator']['base_path'] -org = node[:chef_server_populator][:solo_org] -user = node[:chef_server_populator][:solo_org_user] -pass = user[:pass] || SecureRandom.urlsafe_base64(23).gsub(/^\-*/,'') +org = node['chef_server_populator']['solo_org'] +user = node['chef_server_populator']['solo_org_user'] +pass = user['pass'] || SecureRandom.urlsafe_base64(23).gsub(/^\-*/,'') execute 'create populator user' do - command "chef-server-ctl user-create #{user[:name]} #{user[:first]} #{user[:last]} #{user[:email]} #{pass}" - not_if "chef-server-ctl user-show #{user[:name]}" + command "chef-server-ctl user-create #{user['name']} #{user['first']} #{user['last']} #{user['email']} #{pass}" + not_if "chef-server-ctl user-show #{user['name']}" end execute 'set populator user key' do - if (node['chef-server'][:version].to_f >= 12.1 || node['chef-server'][:version].to_f == 0.0) - command "chef-server-ctl add-user-key #{user[:name]} --public-key-path #{conf_dir}/#{user[:pub_key]} --key-name populator" + if (node['chef-server']['version'].to_f >= 12.1 || node['chef-server']['version'].to_f == 0.0) + command "chef-server-ctl add-user-key #{user['name']} --public-key-path #{conf_dir}/#{user['pub_key']} --key-name populator" else - command "chef-server-ctl add-user-key #{user[:name]} #{conf_dir}/#{user[:pub_key]} --key-name populator" + command "chef-server-ctl add-user-key #{user['name']} #{conf_dir}/#{user['pub_key']} --key-name populator" end - not_if "chef-server-ctl list-user-keys #{user[:name]} | grep 'name: populator$'" + not_if "chef-server-ctl list-user-keys #{user['name']} | grep 'name: populator$'" end execute 'delete default user key' do - command "chef-server-ctl delete-user-key #{user[:name]} default" - only_if "chef-server-ctl list-user-keys #{user[:name]} | grep 'name: default$'" + command "chef-server-ctl delete-user-key #{user['name']} default" + only_if "chef-server-ctl list-user-keys #{user['name']} | grep 'name: default$'" end execute 'reconfigure for populator org create' do @@ -32,23 +32,23 @@ end execute 'create populator org' do - command "chef-server-ctl org-create #{org[:org_name]} #{org[:full_name]} -a #{user[:name]}" - not_if "chef-server-ctl org-list | grep '^#{org[:org_name]}$'" - if org[:org_name] == node[:chef_server_populator][:default_org] + command "chef-server-ctl org-create #{org['org_name']} #{org['full_name']} -a #{user['name']}" + not_if "chef-server-ctl org-list | grep '^#{org['org_name']}$'" + if org['org_name'] == node['chef_server_populator']['default_org'] notifies :run, 'execute[reconfigure for populator org create]', :immediately end end execute 'add populator org validator key' do - if (node['chef-server'][:version].to_f >= 12.1 || node['chef-server'][:version].to_f == 0.0) - command "chef-server-ctl add-client-key #{org[:org_name]} #{org[:org_name]}-validator --public-key-path #{conf_dir}/#{org[:validator_pub_key]} --key-name populator" + if (node['chef-server']['version'].to_f >= 12.1 || node['chef-server']['version'].to_f == 0.0) + command "chef-server-ctl add-client-key #{org['org_name']} #{org['org_name']}-validator --public-key-path #{conf_dir}/#{org['validator_pub_key']} --key-name populator" else - command "chef-server-ctl add-client-key #{org[:org_name]} #{org[:org_name]}-validator #{conf_dir}/#{org[:validator_pub_key]} --key-name populator" + command "chef-server-ctl add-client-key #{org['org_name']} #{org['org_name']}-validator #{conf_dir}/#{org['validator_pub_key']} --key-name populator" end - not_if "chef-server-ctl list-client-keys #{org[:org_name]} #{org[:org_name]}-validator | grep 'name: populator$'" + not_if "chef-server-ctl list-client-keys #{org['org_name']} #{org['org_name']}-validator | grep 'name: populator$'" end execute 'remove populator org default validator key' do - command "chef-server-ctl delete-client-key #{org[:org_name]} #{org[:org_name]}-validator default" - only_if "chef-server-ctl list-client-keys #{org[:org_name]} #{org[:org_name]}-validator | grep 'name: default$'" + command "chef-server-ctl delete-client-key #{org['org_name']} #{org['org_name']}-validator default" + only_if "chef-server-ctl list-client-keys #{org['org_name']} #{org['org_name']}-validator | grep 'name: default$'" end diff --git a/recipes/restore.rb b/recipes/restore.rb index 3ab88af..bf081be 100644 --- a/recipes/restore.rb +++ b/recipes/restore.rb @@ -1,22 +1,22 @@ #Determine if we're using a remote file or a local file. -if(URI(node[:chef_server_populator][:restore][:file]).scheme) - local_file = File.join(node[:chef_server_populator][:restore][:local_path], 'chef_database_restore.dump') +if(URI(node['chef_server_populator']['restore']['file']).scheme) + local_file = File.join(node['chef_server_populator']['restore']['local_path'], 'chef_database_restore.dump') remote_file local_file do - source node[:chef_server_populator][:restore][:file] + source node['chef_server_populator']['restore']['file'] end file = local_file else - file = node[:chef_server_populator][:restore][:file] + file = node['chef_server_populator']['restore']['file'] end -if(URI(node[:chef_server_populator][:restore][:data]).scheme) - local_data = File.join(node[:chef_server_populator][:restore][:local_path], 'chef_data_restore.tar.gz') +if(URI(node['chef_server_populator']['restore']['data']).scheme) + local_data = File.join(node['chef_server_populator']['restore']['local_path'], 'chef_data_restore.tar.gz') remote_file local_data do - source node[:chef_server_populator][:restore][:data] + source node['chef_server_populator']['restore']['data'] end data = local_data else - data = node[:chef_server_populator][:restore][:data] + data = node['chef_server_populator']['restore']['data'] end execute 'backup chef server stop' do diff --git a/recipes/solo.rb b/recipes/solo.rb index 2277b4d..3d94c5c 100644 --- a/recipes/solo.rb +++ b/recipes/solo.rb @@ -1,20 +1,20 @@ -if(node[:chef_server_populator][:default_org].nil?) - node.default[:chef_server_populator][:default_org] = node[:chef_server_populator][:server_org] +if(node['chef_server_populator']['default_org'].nil?) + node.default['chef_server_populator']['default_org'] = node['chef_server_populator']['server_org'] end include_recipe 'chef-server-populator::configurator' # if backup pull files include restore -if(node[:chef_server_populator][:backup][:remote][:connection]) +if(node['chef_server_populator']['backup']['remote']['connection']) chef_gem 'miasma' require 'miasma' - remote_creds = node[:chef_server_populator][:backup][:remote][:connection] - remote_directory = node[:chef_server_populator][:backup][:remote][:directory] - remote = Miasma.api(:provider => remote_creds[:provider].to_s.downcase, :type => 'storage', :credentials => remote_creds[:credentials]) + remote_creds = node['chef_server_populator']['backup']['remote']['connection'] + remote_directory = node['chef_server_populator']['backup']['remote']['directory'] + remote = Miasma.api(:provider => remote_creds['provider'].to_s.downcase, :type => 'storage', :credentials => {:aws_iam_instance_profile => true}) remote_bucket = remote.buckets.get(remote_directory) - if(remote_bucket && gz_file = remote_bucket.files.get(File.join(node[:chef_server_populator][:backup][:remote][:file_prefix], 'latest.tgz'))) - dump_file = remote_bucket.files.get(File.join(node[:chef_server_populator][:backup][:remote][:file_prefix], 'latest.dump')) + if(remote_bucket && gz_file = remote_bucket.files.get(File.join(node['chef_server_populator']['backup']['remote']['file_prefix'], 'latest.tgz'))) + dump_file = remote_bucket.files.get(File.join(node['chef_server_populator']['backup']['remote']['file_prefix'], 'latest.dump')) local_gz = '/tmp/latest.tgz' local_dump = '/tmp/latest.dump' File.open(local_gz, 'wb') do |file| @@ -27,8 +27,8 @@ file.print data end end - node.set[:chef_server_populator][:restore][:file] = local_dump - node.set[:chef_server_populator][:restore][:data] = local_gz + node.set['chef_server_populator']['restore']['file'] = local_dump + node.set['chef_server_populator']['restore']['data'] = local_gz end end @@ -40,28 +40,28 @@ include_recipe 'chef-server-populator::org' - knife_cmd = "#{node[:chef_server_populator][:knife_exec]}" - knife_opts = "-s https://127.0.0.1/organizations/#{node[:chef_server_populator][:server_org]} -c /etc/opscode/pivotal.rb" + knife_cmd = "#{node['chef_server_populator']['knife_exec']}" + knife_opts = "-s https://127.0.0.1/organizations/#{node['chef_server_populator']['server_org']} -c /etc/opscode/pivotal.rb" - node[:chef_server_populator][:clients].each do |client, pub_key| + node['chef_server_populator']['clients'].each do |client, pub_key| execute "create client: #{client}" do command "#{knife_cmd} client create #{client} --admin -d #{knife_opts} > /dev/null 2>&1" not_if "#{knife_cmd} client list #{knife_opts}| tr -d ' ' | grep '^#{client}$'" retries 5 end - if(pub_key && node[:chef_server_populator][:base_path]) - pub_key_path = File.join(node[:chef_server_populator][:base_path], pub_key) + if(pub_key && node['chef_server_populator']['base_path']) + pub_key_path = File.join(node['chef_server_populator']['base_path'], pub_key) execute "remove default public key for #{client}" do - command "chef-server-ctl delete-client-key #{node[:chef_server_populator][:server_org]} #{client} default" - only_if "chef-server-ctl list-client-keys #{node[:chef_server_populator][:server_org]} #{client} | grep 'name: default$'" + command "chef-server-ctl delete-client-key #{node['chef_server_populator']['server_org']} #{client} default" + only_if "chef-server-ctl list-client-keys #{node['chef_server_populator']['server_org']} #{client} | grep 'name: default$'" end execute "set public key for: #{client}" do - if (node['chef-server'][:version].to_f >= 12.1 || node['chef-server'][:version].to_f == 0.0) - command "chef-server-ctl add-client-key #{node[:chef_server_populator][:server_org]} #{client} --public-key-path #{pub_key_path} --key-name populator" + if (node['chef-server']['version'].to_f >= 12.1 || node['chef-server']['version'].to_f == 0.0) + command "chef-server-ctl add-client-key #{node['chef_server_populator']['server_org']} #{client} --public-key-path #{pub_key_path} --key-name populator" else - command "chef-server-ctl add-client-key #{node[:chef_server_populator][:server_org]} #{client} #{pub_key_path} --key-name populator" + command "chef-server-ctl add-client-key #{node['chef_server_populator']['server_org']} #{client} #{pub_key_path} --key-name populator" end - not_if "chef-server-ctl list-client-keys #{node[:chef_server_populator][:server_org]} #{client} | grep 'name: populator$'" + not_if "chef-server-ctl list-client-keys #{node['chef_server_populator']['server_org']} #{client} | grep 'name: populator$'" end end end @@ -69,7 +69,7 @@ execute 'install chef-server-populator cookbook' do command "#{knife_cmd} cookbook upload chef-server-populator #{knife_opts} -o #{Chef::Config[:cookbook_path].join(':')} --include-dependencies" only_if do - node[:chef_server_populator][:cookbook_auto_install] + node['chef_server_populator']['cookbook_auto_install'] end retries 5 end diff --git a/templates/default/chef-server-backup.rb.erb b/templates/default/chef-server-backup.rb.erb index 0e580a1..e80e571 100644 --- a/templates/default/chef-server-backup.rb.erb +++ b/templates/default/chef-server-backup.rb.erb @@ -4,7 +4,7 @@ require 'miasma' require 'multi_json' require 'mixlib/shellout' -DEFAULT_CONFIGURATION_PATH = '<%= node[:chef_server_populator][:configuration_directory] %>/backup.json' +DEFAULT_CONFIGURATION_PATH = '<%= node['chef_server_populator']['configuration_directory'] %>/backup.json' if(ARGV.size > 1 || (ARGV.first && !File.exists?(ARGV.first.to_s))) puts 'Usage: chef-server-backup CONFIG_FILE_PATH' diff --git a/test/unit/backups_spec.rb b/test/unit/backups_spec.rb index 0ddf060..1c85f77 100644 --- a/test/unit/backups_spec.rb +++ b/test/unit/backups_spec.rb @@ -12,11 +12,11 @@ let(:chef_run) do ChefSpec::SoloRunner.new(:platform => 'ubuntu', :version => '14.04') do |node| - node.set[:chef_server_populator][:backup][:dir] = data_dir - node.set[:chef_server_populator][:configuration_directory] = config_dir - node.set[:chef_server_populator][:backup_gems] = gems - node.set[:chef_server_populator][:backup][:schedule] = backup_schedule - node.set[:chef_server_populator][:backup][:remote][:connection] = {} + node.set['chef_server_populator']['backup']['dir'] = data_dir + node.set['chef_server_populator']['configuration_directory'] = config_dir + node.set['chef_server_populator']['backup_gems'] = gems + node.set['chef_server_populator']['backup']['schedule'] = backup_schedule + node.set['chef_server_populator']['backup']['remote']['connection'] = {} end.converge(described_recipe) end @@ -30,7 +30,7 @@ it 'installs platform-specific build dependencies for transmitting backup data to a remote service' do centos_chef_run = ChefSpec::SoloRunner.new(:platform => 'centos', :version => '6.5') do |node| - node.set[:chef_server_populator][:backup][:remote][:connection] = {} + node.set['chef_server_populator']['backup']['remote']['connection'] = {} end.converge(described_recipe) apt_packages.each do |pkg| diff --git a/test/unit/client_spec.rb b/test/unit/client_spec.rb index e054bcf..36bbd5e 100644 --- a/test/unit/client_spec.rb +++ b/test/unit/client_spec.rb @@ -60,7 +60,7 @@ let(:chef_run) do ChefSpec::ServerRunner.new do |node, server| - node.set[:chef_server_populator][:databag] = populator_data_bag + node.set['chef_server_populator']['databag'] = populator_data_bag server.create_data_bag(populator_data_bag, { test_user_name => test_user_item, 'case' => { diff --git a/test/unit/configurator_spec.rb b/test/unit/configurator_spec.rb index ca01ed9..8f74bc6 100644 --- a/test/unit/configurator_spec.rb +++ b/test/unit/configurator_spec.rb @@ -7,44 +7,44 @@ let(:chef_run) { ChefSpec::SoloRunner.new do |node| - node.automatic[:fqdn] = fqdn - node.set[:chef_server_populator][:chef_server][:version] = '12.0.5' - node.set[:chef_server_populator][:chef_server][:foo] = 'bar' + node.automatic['fqdn'] = fqdn + node.set['chef_server_populator']['chef_server']['version'] = '12.0.5' + node.set['chef_server_populator']['chef_server']['foo'] = 'bar' end.converge(described_recipe) } it 'overrides chef-server attributes with those from the chef_server_populator.chef_server hash' do - expect(chef_run.node['chef-server'][:foo]).to eq('bar') + expect(chef_run.node['chef-server']['foo']).to eq('bar') end context 'with a specified endpoint' do before do - chef_run.node.set[:chef_server_populator][:endpoint] = endpoint + chef_run.node.set['chef_server_populator']['endpoint'] = endpoint chef_run.converge(described_recipe) end it 'overrides the values of a number of chef-server attributes with the specified endpoint' do - expect(chef_run.node[:chef_server_populator][:chef_server][:configuration][:nginx][:server_name]).to eq(endpoint) - expect(chef_run.node[:chef_server_populator][:chef_server][:configuration][:bookshelf][:vip]).to eq(endpoint) - expect(chef_run.node[:chef_server_populator][:chef_server][:configuration][:lb][:api_fqdn]).to eq(endpoint) - expect(chef_run.node[:chef_server_populator][:chef_server][:configuration][:lb][:web_ui_fqdn]).to eq(endpoint) - - expect(chef_run.node[:chef_server_populator][:chef_server][:configuration][:nginx][:url]).to eq("https://#{endpoint}") - expect(chef_run.node[:chef_server_populator][:chef_server][:configuration][:bookshelf][:url]).to eq("https://#{endpoint}") - expect(chef_run.node['chef-server'][:configuration]).to include(endpoint) + expect(chef_run.node['chef_server_populator']['chef_server']['configuration']['nginx']['server_name']).to eq(endpoint) + expect(chef_run.node['chef_server_populator']['chef_server']['configuration']['bookshelf']['vip']).to eq(endpoint) + expect(chef_run.node['chef_server_populator']['chef_server']['configuration']['lb']['api_fqdn']).to eq(endpoint) + expect(chef_run.node['chef_server_populator']['chef_server']['configuration']['lb']['web_ui_fqdn']).to eq(endpoint) + + expect(chef_run.node['chef_server_populator']['chef_server']['configuration']['nginx']['url']).to eq("https://#{endpoint}") + expect(chef_run.node['chef_server_populator']['chef_server']['configuration']['bookshelf']['url']).to eq("https://#{endpoint}") + expect(chef_run.node['chef-server']['configuration']).to include(endpoint) end end context 'without a specified endpoint' do it 'overrides the values of a number of chef-server attributes with the node\'s fqdn' do - expect(chef_run.node[:chef_server_populator][:chef_server][:configuration][:nginx][:server_name]).to eq(fqdn) - expect(chef_run.node[:chef_server_populator][:chef_server][:configuration][:bookshelf][:vip]).to eq(fqdn) - expect(chef_run.node[:chef_server_populator][:chef_server][:configuration][:lb][:api_fqdn]).to eq(fqdn) - expect(chef_run.node[:chef_server_populator][:chef_server][:configuration][:lb][:web_ui_fqdn]).to eq(fqdn) - - expect(chef_run.node[:chef_server_populator][:chef_server][:configuration][:nginx][:url]).to eq("https://#{fqdn}") - expect(chef_run.node[:chef_server_populator][:chef_server][:configuration][:bookshelf][:url]).to eq("https://#{fqdn}") - expect(chef_run.node['chef-server'][:configuration]).to include(fqdn) + expect(chef_run.node['chef_server_populator']['chef_server']['configuration']['nginx']['server_name']).to eq(fqdn) + expect(chef_run.node['chef_server_populator']['chef_server']['configuration']['bookshelf']['vip']).to eq(fqdn) + expect(chef_run.node['chef_server_populator']['chef_server']['configuration']['lb']['api_fqdn']).to eq(fqdn) + expect(chef_run.node['chef_server_populator']['chef_server']['configuration']['lb']['web_ui_fqdn']).to eq(fqdn) + + expect(chef_run.node['chef_server_populator']['chef_server']['configuration']['nginx']['url']).to eq("https://#{fqdn}") + expect(chef_run.node['chef_server_populator']['chef_server']['configuration']['bookshelf']['url']).to eq("https://#{fqdn}") + expect(chef_run.node['chef-server']['configuration']).to include(fqdn) end end diff --git a/test/unit/default_spec.rb b/test/unit/default_spec.rb index 286608f..6186472 100644 --- a/test/unit/default_spec.rb +++ b/test/unit/default_spec.rb @@ -27,7 +27,7 @@ context 'when provided values for restore file attribute' do it 'includes restore recipe' do - chef_solo_run.node.set[:chef_server_populator][:restore][:file] = '/tmp/latest.tgz' + chef_solo_run.node.set['chef_server_populator']['restore']['file'] = '/tmp/latest.tgz' expect_any_instance_of(Chef::Recipe).to receive(:include_recipe).with('chef-server-populator::restore') chef_solo_run.converge(described_recipe) end diff --git a/test/unit/org_spec.rb b/test/unit/org_spec.rb index 7b2b17a..a8d662b 100644 --- a/test/unit/org_spec.rb +++ b/test/unit/org_spec.rb @@ -6,34 +6,34 @@ let(:test_org) { Mash.new( - :org_name => 'endurance', - :full_name => 'Endurance Shuttle Mission', - :validator_pub_key => 'validation_pub.pem' + 'org_name' => 'endurance', + 'full_name' => 'Endurance Shuttle Mission', + 'validator_pub_key' => 'validation_pub.pem' ) } let(:test_org_user) { Mash.new( - :name => 'murph', - :first => 'Murphy', - :last => 'Cooper', - :email => 'murph@nasa.gov' + 'name' => 'murph', + 'first' => 'Murphy', + 'last' => 'Cooper', + 'email' => 'murph@nasa.gov' ) } let(:list_user_keys_cmd) { - "chef-server-ctl list-user-keys #{test_org_user[:name]}" + "chef-server-ctl list-user-keys #{test_org_user['name']}" } let(:list_validator_keys_cmd) { - "chef-server-ctl list-client-keys #{test_org[:org_name]} #{test_org[:org_name]}-validator" + "chef-server-ctl list-client-keys #{test_org['org_name']} #{test_org['org_name']}-validator" } let(:chef_run) { ChefSpec::ServerRunner.new do |node, _server| - node.set[:chef_server_populator][:solo_org] = test_org - node.set[:chef_server_populator][:solo_org_user] = test_org_user - node.set[:chef_server_populator][:default_org] = default_org + node.set['chef_server_populator']['solo_org'] = test_org + node.set['chef_server_populator']['solo_org_user'] = test_org_user + node.set['chef_server_populator']['default_org'] = default_org end.converge(described_recipe) } @@ -42,18 +42,18 @@ } before do - stub_command("chef-server-ctl user-show #{test_org_user[:name]}").and_return(false) + stub_command("chef-server-ctl user-show #{test_org_user['name']}").and_return(false) stub_command("#{list_user_keys_cmd} | grep 'name: populator$'").and_return(false) stub_command("#{list_user_keys_cmd} | grep 'name: default$'").and_return(false) - stub_command("chef-server-ctl org-list | grep '^#{test_org[:org_name]}$'").and_return(false) + stub_command("chef-server-ctl org-list | grep '^#{test_org['org_name']}$'").and_return(false) stub_command("#{list_validator_keys_cmd} | grep 'name: populator$'").and_return(false) stub_command("#{list_validator_keys_cmd} | grep 'name: default$'").and_return(false) - stub_command("chef-server-ctl list-client-keys #{test_org[:org_name]} #{test_org[:org_name]}-validator | grep 'name: populator$'").and_return(false) - stub_command("chef-server-ctl list-client-keys #{test_org[:org_name]} #{test_org[:org_name]}-validator | grep 'name: default$'").and_return(true) + stub_command("chef-server-ctl list-client-keys #{test_org['org_name']} #{test_org['org_name']}-validator | grep 'name: populator$'").and_return(false) + stub_command("chef-server-ctl list-client-keys #{test_org['org_name']} #{test_org['org_name']}-validator | grep 'name: default$'").and_return(true) end it 'overrides the chef-server default_orgname' do - expect(chef_run.node['chef-server'][:configuration]).to include(default_org) + expect(chef_run.node['chef-server']['configuration']).to include(default_org) end @@ -82,7 +82,7 @@ context 'when the populator org is also the default org' do it 'notifies chef-server to reconfigure immediately' do - chef_run.node.set[:chef_server_populator][:default_org] = test_org[:org_name] + chef_run.node.set['chef_server_populator']['default_org'] = test_org['org_name'] chef_run.converge(described_recipe) expect(execute_create_populator_org).to notify('execute[reconfigure for populator org create]').to(:run).immediately end diff --git a/test/unit/restore_spec.rb b/test/unit/restore_spec.rb index bc3de57..bb1cd06 100644 --- a/test/unit/restore_spec.rb +++ b/test/unit/restore_spec.rb @@ -6,13 +6,13 @@ let(:db_restore_user) { 'opscode-pgsql' } let(:chef_run) do ChefSpec::SoloRunner.new do |node| - node.set[:chef_server_populator][:restore][:local_path] = restore_path + node.set['chef_server_populator']['restore']['local_path'] = restore_path end.converge(described_recipe) end context 'when provided a URL for the database dump' do it 'downloads the remote file' do - chef_run.node.set[:chef_server_populator][:restore][:file] = 'https://www.example.com/restore.dump' + chef_run.node.set['chef_server_populator']['restore']['file'] = 'https://www.example.com/restore.dump' chef_run.converge(described_recipe) expect(chef_run).to create_remote_file(File.join(restore_path, 'chef_database_restore.dump')) end @@ -20,7 +20,7 @@ context 'when provided a URL for the tarball' do it 'downloads the remote file' do - chef_run.node.set[:chef_server_populator][:restore][:data] = 'https://www.example.com/restore.tgz' + chef_run.node.set['chef_server_populator']['restore']['data'] = 'https://www.example.com/restore.tgz' chef_run.converge(described_recipe) expect(chef_run).to create_remote_file(File.join(restore_path, 'chef_data_restore.tar.gz')) end diff --git a/test/unit/solo_spec.rb b/test/unit/solo_spec.rb index b1038ac..1e3255c 100644 --- a/test/unit/solo_spec.rb +++ b/test/unit/solo_spec.rb @@ -8,50 +8,50 @@ let(:test_org) do Mash.new( - :org_name => 'endurance', - :full_name => 'Endurance Shuttle Mission', - :validator_pub_key => 'validation_pub.pem' + 'org_name' => 'endurance', + 'full_name' => 'Endurance Shuttle Mission', + 'validator_pub_key' => 'validation_pub.pem' ) end let(:test_org_user) do Mash.new( - :name => 'murph', - :first => 'Murphy', - :last => 'Cooper', - :email => 'murph@nasa.gov' + 'name' => 'murph', + 'first' => 'Murphy', + 'last' => 'Cooper', + 'email' => 'murph@nasa.gov' ) end - let(:list_user_keys_cmd) { "chef-server-ctl list-user-keys #{test_org_user[:name]}" } + let(:list_user_keys_cmd) { "chef-server-ctl list-user-keys #{test_org_user['name']}" } - let(:list_validator_keys_cmd) { "chef-server-ctl list-client-keys #{test_org[:org_name]} #{test_org[:org_name]}-validator" } + let(:list_validator_keys_cmd) { "chef-server-ctl list-client-keys #{test_org['org_name']} #{test_org['org_name']}-validator" } - let(:list_client_keys_cmd) { "chef-server-ctl list-client-keys #{server_org} #{test_org_user[:name]}" } + let(:list_client_keys_cmd) { "chef-server-ctl list-client-keys #{server_org} #{test_org_user['name']}" } - let(:list_validator_client_keys) { "chef-server-ctl list-client-keys #{test_org[:org_name]} #{test_org[:org_name]}-validator" } + let(:list_validator_client_keys) { "chef-server-ctl list-client-keys #{test_org['org_name']} #{test_org['org_name']}-validator" } let(:chef_run) do ChefSpec::SoloRunner.new do |node| - node.set[:chef_server_populator][:server_org] = server_org - node.set[:chef_server_populator][:default_org] = default_org - node.set[:chef_server_populator][:solo_org] = test_org - node.set[:chef_server_populator][:solo_org_user] = test_org_user + node.set['chef_server_populator']['server_org'] = server_org + node.set['chef_server_populator']['default_org'] = default_org + node.set['chef_server_populator']['solo_org'] = test_org + node.set['chef_server_populator']['solo_org_user'] = test_org_user end.converge(described_recipe) end let(:execute_create_populator_org) { chef_run.execute('create populator org') } before do - stub_command("chef-server-ctl user-show #{test_org_user[:name]}").and_return(false) - stub_command("#{list_user_keys_cmd} | grep 'name: #{test_org_user[:name]}$'").and_return(false) + stub_command("chef-server-ctl user-show #{test_org_user['name']}").and_return(false) + stub_command("#{list_user_keys_cmd} | grep 'name: #{test_org_user['name']}$'").and_return(false) stub_command("#{list_user_keys_cmd} | grep 'name: default$'").and_return(false) stub_command("#{list_user_keys_cmd} | grep 'name: populator$'").and_return(false) - stub_command("chef-server-ctl org-list | grep '^#{test_org[:org_name]}$'").and_return(false) + stub_command("chef-server-ctl org-list | grep '^#{test_org['org_name']}$'").and_return(false) stub_command("#{list_validator_client_keys} | grep 'name: populator$'").and_return(false) stub_command("#{list_validator_client_keys} | grep 'name: default$'").and_return(true) stub_command("#{list_client_keys_cmd} | grep 'name: default$'").and_return(false) - stub_command("/usr/bin/knife client list -s https://127.0.0.1/organizations/#{server_org} -c /etc/opscode/pivotal.rb| tr -d ' ' | grep '^#{test_org_user[:name]}$'").and_return(false) + stub_command("/usr/bin/knife client list -s https://127.0.0.1/organizations/#{server_org} -c /etc/opscode/pivotal.rb| tr -d ' ' | grep '^#{test_org_user['name']}$'").and_return(false) stub_command("#{list_client_keys_cmd} | grep 'name: populator$'").and_return(false) end @@ -62,12 +62,12 @@ context 'without a default_org specified' do before do - chef_run.node.set[:chef_server_populator][:default_org] = nil + chef_run.node.set['chef_server_populator']['default_org'] = nil chef_run.converge(described_recipe) end it 'assigns the server_org as the default org' do - expect(chef_run.node[:chef_server_populator][:default_org]).to eq(server_org) + expect(chef_run.node['chef_server_populator']['default_org']).to eq(server_org) end end @@ -88,7 +88,7 @@ # it 'overrides the chef-server default_orgname' do - expect(chef_run.node['chef-server'][:configuration]).to include(default_org) + expect(chef_run.node['chef-server']['configuration']).to include(default_org) end it 'creates the populator user' do @@ -97,12 +97,12 @@ context 'with a specified endpoint' do before do - chef_run.node.set[:chef_server_populator][:endpoint] = endpoint + chef_run.node.set['chef_server_populator']['endpoint'] = endpoint chef_run.converge(described_recipe) end it 'overrides the chef server endpoints to specified endpoint' do - expect(chef_run.node['chef-server'][:configuration]).to include(endpoint) + expect(chef_run.node['chef-server']['configuration']).to include(endpoint) end end @@ -133,7 +133,7 @@ context 'when the populator org is also the default org' do before do - chef_run.node.set[:chef_server_populator][:default_org] = test_org[:org_name] + chef_run.node.set['chef_server_populator']['default_org'] = test_org['org_name'] chef_run.converge(described_recipe) end @@ -178,8 +178,8 @@ context 'for each client defined in attributes' do before do - chef_run.node.set[:chef_server_populator][:clients] = { - test_org_user[:name] => "-----BEGIN PUBLIC KEY-----\n-----END PUBLIC KEY-----\n" + chef_run.node.set['chef_server_populator']['clients'] = { + test_org_user['name'] => "-----BEGIN PUBLIC KEY-----\n-----END PUBLIC KEY-----\n" } stub_command("#{list_client_keys_cmd} | grep 'name: default$'").and_return(false) @@ -187,7 +187,7 @@ end it 'creates a client for each client defined in attributes' do - expect(chef_run).to run_execute("create client: #{test_org_user[:name]}") + expect(chef_run).to run_execute("create client: #{test_org_user['name']}") end context 'when the client has a default key on the server' do @@ -198,13 +198,13 @@ end it 'removes the client\'s default public key' do - expect(chef_run).to run_execute("remove default public key for #{test_org_user[:name]}") + expect(chef_run).to run_execute("remove default public key for #{test_org_user['name']}") end end it 'sets the client\'s public key' do - expect(chef_run).to run_execute("set public key for: #{test_org_user[:name]}") + expect(chef_run).to run_execute("set public key for: #{test_org_user['name']}") end end