另一个测试食谱我能够成功地得到以下工作:
env =test dsTemplateBag = data_bag_item('configTemplates',#{env})请问有人可以告诉我如何使这个工作吗?
解决方案经过一点调试,我意识到有一个防止错字数据包要正确使用;因此发行。
dsTemplateBag = data_bag_item('configTemplates',#{node [:env]} _ ls)这对我有用。而如同Tensibai在上述评论中建议的,混合连接和插值不是一个很好的做法(我绝望地使它工作!在我的防御)。
I am trying to figure out a way to get the below code work; I have tried various methods but the chef-client run breaks at the 3rd line.
lsf = "#{node[:env]}"+"_ls" dsf = "#{node[:env]}"+"_ds" dsTemplateBag = data_bag_item('configTemplates', "#{dsf}") lcTemplateBag = data_bag_item('configTemplates', "#{lsf}")However on another test recipe I was able to successfully get the following working:
env = "test" dsTemplateBag = data_bag_item('configTemplates', "#{env}")I am quite new to Chef and please can someone advise me on how to get this working ?
解决方案After a little bit debugging I realised there was a typo preventing the data bag to be properly used; hence issue.
dsTemplateBag = data_bag_item('configTemplates', "#{node[:env]}_ls")this worked for me. And as Tensibai suggested in the above comment mixing concatenation and interpolation is not a good practice (I was desperate to make it work! In my defense).
更多推荐
厨师数据袋和动态变量传递
发布评论