简体   繁体   English

与厨师独奏一起使用lwrp

[英]use lwrp with chef-solo

I'm using chef-solo with librarian-chef to manage my servers. 我正在将chef-solo和librarian-chef一起使用来管理服务器。 Here's the structure I have locally: 这是我本地的结构:

Cheffile Cheffile.lock cookbooks data_bags Gemfile Gemfile.lock .git .gitignore nodes README.md roles tmp

Each node from the nodes/ dir has a role defined and I've added most of the generic attributes in the roles. nodes/目录中的每个节点都有一个定义的角色,我在角色中添加了大多数通用属性。

I've included the nrpe cookbook in one of the roles and it's working for the generic part: 我已经将nrpe食谱包括在其中一个角色中,并且它适用于通用部分:

``` ```

"apache" => {

    "timeout" => 5,
    "keep_alive" => 'On',
    "max_keep_alive_requests" => 100,
    "keep_alive_timeout" => 5,

    "prefork" => {
        "start_servers" => 5,
        "min_spare_servers" => 5,
        "max_spare_servers" => 10,
        "max_clients" => 100,
        "max_requests_per_child" => 1000
    }
},
"nrpe" => {
    "server_port" => 5666,
    "connection_timeout" => 300,
    "dont_blame_nrpe" => 1,
    "command_timeout" => 60,
    "allowed_hosts" => ["10.1.1.10,10.11.1.11"],

 }

} override_attributes(attrs) } Override_attributes(attrs)

``` ```

I'm now trying to use the LWRP provided by the cookbook to set up checks in the chef created nrpe.cfg 我现在正在尝试使用食谱提供LWRP在厨师创建的nrpe.cfg中设置检查

Any syntax I was able to think about doesn't seem to work though. 我能想到的任何语法似乎都没有用。 The knife solo bootstrap nodename either exits with syntax errors or completes, but nothing is added on the node. knife solo bootstrap nodename要么因语法错误而退出,要么完成,但节点上未添加任何内容。 Any insight on how to add this: 关于如何添加此内容的任何见解:

nagios_nrpecheck 'check_load' do command "#{node['nagios']['plugin_dir']}/check_load" warning_condition '6' critical_condition '10' action :add end

in the nrpe block from the role file above will be much appreciated. 上面角色文件中的nrpe块中的nrpe将不胜感激。

Thanks! 谢谢!

You can't add an LWRP to a runlist in a role. 您不能将LWRP添加到角色的运行列表中。 You must wrap the LWRP declaration in a recipe and then add the recipe to the role's runlist or the nodes runlist. 您必须将LWRP声明包装在配方中,然后将配方添加到角色的运行列表或节点运行列表中。

my_wrapper_cookbook/recipes/nrpecheck.rb

nagios_nrpecheck 'check_load' do
  command "#{node['nagios']['plugin_dir']}/check_load"
  warning_condition '6'
  critical_condition '10'
  action :add
end

role

....
  run_list: {
    "recipe[my_wrapper_cookbook::nrpecheck]"
  }
....

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

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