简体   繁体   English

厨师新错误

[英]ERROR new to chef

New to Chef, bare wi/ me. 刚接触厨师,不认识我。 Building my cookbook. 建立我的食谱。

How did you set the databag? 您是如何设置数据包的?

are you able to get the credential out using : 您是否可以使用以下方式获取证书:

$ knife vault show nameOfVault nameOfItem

or 要么

$ knife data bag show nameOfVault nameOfItem_keys

Glad you have your data bag loading and indeed, with Test Kitchen you do not need to use knife to upload to Chef Server, as Test Kitchen uses Chef Zero / Solo. 很高兴您可以装载数据包,事实上,通过Test Kitchen,您不需要使用刀子就可以上传到Chef Server,因为Test Kitchen使用Chef Zero / Solo。

The issue you have here is that you have not correctly formatted reading from the data bag object once you have read. 这里的问题是,一旦读取,您就无法正确格式化从数据包对象读取的数据。 You need to do this instead: 您需要这样做:

ruby_block "insert_line" do
  block do
    file = Chef::Util::FileEdit.new('/var/lib/net-snmp/snmpd.conf')
    file.insert_line_if_no_match("/www.example.com/", "createUser 
       #{snmp3usercreds['user']} 
       SHA #{snmp3usercreds['auth_pssword']} 
       AES #{snmp3usercreds['enc_password']} ")
    file.write_file
  end
end

So, you will see I have changed snmp3usercreds[user] to snmp3usercreds['user'] with quotes around the user to show it is a string (rather than a variable as is the case with your code). 因此,您将看到我已将snmp3usercreds[user]更改为snmp3usercreds['user']并在user snmp3usercreds['user']加上引号,以表明它是字符串(而不是像代码中那样是变量)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM