我正在试着让一个食谱在厨师中发挥作用。然而,它正在失败...
我可以在属性中使用"default“,但我不能在配方中使用它,而且由于某些原因,它很难使用……看看有没有人知道我做错了什么。任何帮助都会很棒,谢谢!
我编辑了食谱/食谱/组的名称,以使代码保持匿名。
default['sssd']['simple']['allow_groups'] = 'GroupName' if node.chef_environment == 'production'
default['sssd']['simple']['allow_groups'] = 'GroupName' unless node.chef_environment == 'test'NameError
undefined local variable or method `default' for cookbook: COOKBOOK_NAME, recipe: RECIPE:NAME :Chef::Recipe食谱跟踪:
/var/chef/cache/cookbooks/COOKBOOK_NAME/recipes/RECIPE_NAME.rb:4:in `from_file'相关文件内容:
/var/chef/cache/cookbooks/COOKBOOK_NAME/recipes/RECIPE_NAME.rb
1: # Comments
2:
3: default['sssd']['simple']['allow_groups'] = 'GROUP_NAME' if node.chef_environment == 'production'
4>> default['sssd']['simple']['allow_groups'] = 'GROUP_NAME' unless node.chef_environment == 'production'
5:
6: if node.chef_environment == 'production'
7: sudo 'sudoers_file' do
8: group '%GROUP_NAME'
9: end
10: else
11: sudo 'sudoers_file' do
12: group '%GROUP_NAME'
13: end发布于 2019-08-06 13:54:14
您没有指定您使用的是哪个chef版本,因为存在a deprecation of methods of setting\reading the node attribute。
尝试使用node.default,而不是default。
在配方中设置节点属性通常是因为只有在chef-client会聚阶段才知道该值。如果不是这样,请考虑将节点属性移动到属性文件中。
请注意,我正在使用这本食谱,我对它没有任何问题。
https://stackoverflow.com/questions/57367687
复制相似问题