Skip to content

Commit

Permalink
Merge pull request #56 from bkw/resurrectChefSolo
Browse files Browse the repository at this point in the history
bring back support for chef-solo
  • Loading branch information
chris-rock committed Oct 14, 2014
2 parents 71f4021 + 8af0ee9 commit f1dd867
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
8 changes: 8 additions & 0 deletions recipes/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,16 @@
notifies :restart, 'service[sshd]'
end

def chef_solo_search_installed?
klass = ::Search.const_get('Helper')
return klass.is_a?(Class)
rescue NameError
return false
end

# authorized_key management will be deprecated in the next major release:
def get_key_from(field)
return [] if Chef::Config[:solo] && !chef_solo_search_installed?
return [] unless Chef::DataBag.list.key?('users')
search('users', "#{field}:*").map do |v| # ~FC003 ignore footcritic violation
Chef::Log.info "ssh_server: installing ssh-keys for root access of user #{v['id']}"
Expand Down
10 changes: 10 additions & 0 deletions spec/recipes/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,14 @@
end
end
end

context 'chef-solo' do
cached(:chef_run) do
ChefSpec::SoloRunner.new.converge(described_recipe)
end

it 'does not raise an error' do
expect { chef_run }.not_to raise_error
end
end
end
9 changes: 9 additions & 0 deletions spec/recipes/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,13 @@
expect(chef_run).to include_recipe('ssh-hardening::client')
end

context 'chef-solo' do
cached(:chef_run) do
ChefSpec::SoloRunner.new.converge(described_recipe)
end

it 'does not raise an error' do
expect { chef_run }.not_to raise_error
end
end
end
10 changes: 10 additions & 0 deletions spec/recipes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,14 @@
expect(chef_run).not_to write_log('deprecated-databag')
end
end

context 'chef-solo' do
cached(:chef_run) do
ChefSpec::SoloRunner.new.converge(described_recipe)
end

it 'does not raise an error' do
expect { chef_run }.not_to raise_error
end
end
end

0 comments on commit f1dd867

Please sign in to comment.