【发布时间】:2015-03-25 22:39:27
【问题描述】:
我正在尝试将 chef-client 配置为在测试厨房运行中将日志输出到文件,但我在 .kitchen.yml 中的配置似乎没有反映在准备并注入测试节点的 client.rb 中.
我在 virtualbox 上使用 ChefDK 0.3.6、chef_zero 供应商和 vagrant 驱动程序。
摘自我的.kitchen.yml 文件:
...
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"
...
另一个摘录,来自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"
...
最后,测试节点上/tmp/kitchen/client.rb的内容:
[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"
如您所见,client.rb 中没有包含预期的log_location 条目,我猜这就是在指定路径中没有创建日志文件的原因。
能否请您帮助我了解如何正确启用通过厨房的 chef-client 记录到文件的功能?
目前使用的参考资料:
-
client.rb参考:https://docs.chef.io/config_rb_client.html -
.kitchen.yml:https://docs.chef.io/config_yml_kitchen.html#chef-client-specific-settings 中的厨师客户特定设置
【问题讨论】:
-
您的运行列表中是否包含 chef_client 食谱? IIRC 提到的属性供
chef_client::config配方使用。 (我可能错了,因为我没有使用测试厨房) -
@Tensibai 我的运行列表中不包括
chef_client::config,因为供应商(chef_zero)自带。我试图为其配置日志记录的是嵌入在配置器中的厨师客户端。