Reputation: 130
I am trying to configure chef-client to output logs to a file in a test kitchen run, but my configuration in .kitchen.yml
doesn't appear to be being reflected in the client.rb
prepared and injected into the test node.
I'm using ChefDK 0.3.6, the chef_zero provisioner and vagrant driver over virtualbox.
An extract from my .kitchen.yml
file:
...
provisioner:
name: chef_zero
...
- name: install-only
run_list:
- recipe[my_cookbook::test_recipe]
attributes:
chef_client:
config:
log_location: "/var/log/chef/chef-client.log"
...
Another extract, this from the output of kitchen diagnose
:
...
provisioner:
attributes:
chef_client:
config:
log_location: "/var/log/chef/chef-client.log"
chef_client_path: "/opt/chef/bin/chef-client"
chef_omnibus_install_options:
chef_omnibus_root: "/opt/chef"
...
And finally, the contents of /tmp/kitchen/client.rb
on the test node:
[root@TRSTWPRTSTAPV99 log]# cat /tmp/kitchen/client.rb
node_name "install-only-rhel65-x86-64"
checksum_path "/tmp/kitchen/checksums"
file_cache_path "/tmp/kitchen/cache"
file_backup_path "/tmp/kitchen/backup"
cookbook_path ["/tmp/kitchen/cookbooks", "/tmp/kitchen/site-cookbooks"]
data_bag_path "/tmp/kitchen/data_bags"
environment_path "/tmp/kitchen/environments"
node_path "/tmp/kitchen/nodes"
role_path "/tmp/kitchen/roles"
client_path "/tmp/kitchen/clients"
user_path "/tmp/kitchen/users"
validation_key "/tmp/kitchen/validation.pem"
client_key "/tmp/kitchen/client.pem"
chef_server_url "http://127.0.0.1:8889"
encrypted_data_bag_secret "/tmp/kitchen/encrypted_data_bag_secret"
As you can see, the expected log_location
entry is not being included in the client.rb
, which I guess is the reason why no log file is being created in the specified path.
Could you please help me understand how to correctly enable logging to a file through chef-client in kitchen?
References used so far:
client.rb
reference: https://docs.chef.io/config_rb_client.html.kitchen.yml
: https://docs.chef.io/config_yml_kitchen.html#chef-client-specific-settingsUpvotes: 2
Views: 7224
Reputation: 15784
According the chef-zero provisionner doc and reading the provisioner code:
It does not take in account the attributesand it sounds logic as they are attributes to be consumed by cookbooks in real world.
What could be done (I think from the code) is defining a log_file
in the provisioner definition along the chef_omnibus_url (line 42 of the provisioner code above):
you .kitche.yml could become:
...
provisioner:
name: chef_zero
log_file: "/var/log/chef/chef-client.log"
...
- name: install-only
run_list:
- recipe[my_cookbook::test_recipe]
...
or
...
provisioner:
name: chef_zero
...
- name: install-only
run_list:
- recipe[chef-client::config]
- recipe[my_cookbook::test_recipe]
attributes:
chef_client:
config:
log_location: "/var/log/chef/chef-client.log"
...
If you do use chef_client cookbook to configure chef on your node, I would include it in the runlist to match as close as possible the reality.
Upvotes: 2