How can I capture chef-client log output to a file in a kitchen run?

Allan Lang

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:

  1. client.rb reference: https://docs.chef.io/config_rb_client.html
  2. chef-client specific settings in .kitchen.yml: https://docs.chef.io/config_yml_kitchen.html#chef-client-specific-settings
Tensibai

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to capture Curl output to a file?

From Dev

Capture nethogs output in log file

From Dev

How can I know a file's content with chef

From Dev

How to specify the version of Chef Solo in Test Kitchen .kitchen.yml file?

From Dev

How can I get Gradle to add file deletion to the log output?

From Dev

In Unix, how can I capture output in the terminal and dump it into a file that's not been created?

From Dev

How can I run a cookbook with a specific version using chef-client?

From Dev

How can I capture chef-client log output to a file in a kitchen run?

From Dev

How can I get test kitchen run same chef recipe multiple times?

From Dev

How to capture Chef::Log.info in kitchen test

From Dev

How do I get Test Kitchen to cache the chef-client RPM?

From Dev

How can I output the name of the current java.util.logging.Logger log file name?

From Dev

How can I run FIO for windows and redirect output to file and console simultaneously

From Dev

How do I get log output in test kitchen?

From Dev

How can I capture a file downloaded in an iframe?

From Dev

How can I use grep command to capture correlation ID along with java stacktrace and multiline message from log file

From Dev

How can I see my .csv file data in the output client area of Visual C++?

From Dev

How to specify the version of Chef Solo in Test Kitchen .kitchen.yml file?

From Dev

How can I capture two columns of ls output in a bash script

From Dev

How can I capture the audio output with GStreamer?

From Dev

how can i capture the output of an echoed string

From Dev

How can I shred all disks but /dev/sda and log the output to a file?

From Dev

How can I output the name of the current java.util.logging.Logger log file name?

From Dev

How can I conditionally run a block of resources or a recipe in chef?

From Dev

How can I capture this computer output with a txr query?

From Dev

How can I tail a file and capture the output for one minute?

From Dev

How can I capture the output?

From Dev

How can i capture Browser console log using selenium and java

From Dev

How can I capture and format on output nested format tags?

Related Related

  1. 1

    How to capture Curl output to a file?

  2. 2

    Capture nethogs output in log file

  3. 3

    How can I know a file's content with chef

  4. 4

    How to specify the version of Chef Solo in Test Kitchen .kitchen.yml file?

  5. 5

    How can I get Gradle to add file deletion to the log output?

  6. 6

    In Unix, how can I capture output in the terminal and dump it into a file that's not been created?

  7. 7

    How can I run a cookbook with a specific version using chef-client?

  8. 8

    How can I capture chef-client log output to a file in a kitchen run?

  9. 9

    How can I get test kitchen run same chef recipe multiple times?

  10. 10

    How to capture Chef::Log.info in kitchen test

  11. 11

    How do I get Test Kitchen to cache the chef-client RPM?

  12. 12

    How can I output the name of the current java.util.logging.Logger log file name?

  13. 13

    How can I run FIO for windows and redirect output to file and console simultaneously

  14. 14

    How do I get log output in test kitchen?

  15. 15

    How can I capture a file downloaded in an iframe?

  16. 16

    How can I use grep command to capture correlation ID along with java stacktrace and multiline message from log file

  17. 17

    How can I see my .csv file data in the output client area of Visual C++?

  18. 18

    How to specify the version of Chef Solo in Test Kitchen .kitchen.yml file?

  19. 19

    How can I capture two columns of ls output in a bash script

  20. 20

    How can I capture the audio output with GStreamer?

  21. 21

    how can i capture the output of an echoed string

  22. 22

    How can I shred all disks but /dev/sda and log the output to a file?

  23. 23

    How can I output the name of the current java.util.logging.Logger log file name?

  24. 24

    How can I conditionally run a block of resources or a recipe in chef?

  25. 25

    How can I capture this computer output with a txr query?

  26. 26

    How can I tail a file and capture the output for one minute?

  27. 27

    How can I capture the output?

  28. 28

    How can i capture Browser console log using selenium and java

  29. 29

    How can I capture and format on output nested format tags?

HotTag

Archive