Reputation: 8897
I didn't see a great solution for this elsewhere and I think integration testing is necessary because:
chef-client
and get buggy configurationUpvotes: 0
Views: 515
Reputation: 424
chef Zero is the answer to this very old question. It does handle encrypted databags.
In the suite you can provide the below
data_bags_path: <<Data_Bags_PATH>>
encrypted_data_bag_secret_key_path: <<Secret_Key_PATH>>
Upvotes: 1
Reputation: 271
You are probably looking for linting + integration testing.
Linting : Use Foodcritic. It also goes well with your CI tool. If you would like to be more adventurous and would like to test it against ruby best practices, use Rubocop.
Unit Testing : Chef Spec as you mentioned
Test Kitchen: This is purely integration testing. Its actually a framework and you could choose which driver to use (vm, cloud etc.) which provisioner to use (chef, pupept, ansible etc. ) , and which test suite to use (bash/bats, serverspec) etc.
Apart from this, Chef Zero is awesome to test against chef-server when you dont have access to a real one. Its in memory, ephemeral server simulator of types logically.
Upvotes: 4
Reputation: 8897
CHEF_TEST=true
export CHEF_TEST=true
./update_all.bash
knife bootstrap
as per usual to test with vagrant.knife.rb
current_dir = File.dirname(__FILE__)
log_level :info
log_location STDOUT
if ENV['CHEF_TEST'] == 'true'
puts 'Running knife on test chef server...'
node_name "acmetest"
client_key "#{current_dir}/acmetest.pem"
validation_client_name "acmetest-validator"
validation_key "#{current_dir}/acmetest-validator.pem"
chef_server_url "https://api.opscode.com/organizations/acmetest"
cache_type 'BasicFile'
cache_options( :path => "#{ENV['HOME']}/.chef/checksums" )
cookbook_path ["#{current_dir}/../cookbooks"]
else
puts 'Running knife on production chef server...'
node_name "acme"
client_key "#{current_dir}/acme.pem"
validation_client_name "acme-validator"
validation_key "#{current_dir}/acme-validator.pem"
chef_server_url "https://api.opscode.com/organizations/acme"
cache_type 'BasicFile'
cache_options path: "#{ENV['HOME']}/.chef/checksums"
cookbook_path ["#{current_dir}/../cookbooks"]
end
update_all.bash
#!/bin/bash
knife cookbook upload --all
knife role from file roles/*.rb
knife data bag from file --all
knife environment from file --all
Upvotes: 0