简体   繁体   English

如何正确使用Roles与Chef-solo

[英]How to properly use Roles with Chef-solo

I am not sure that I understand how roles should be used with chef-solo. 我不确定我是否理解角色应该如何与chef-solo一起使用。 More specifically I am looking for answers to the following questions: 更具体地说,我正在寻找以下问题的答案:

(i) What is the syntax for telling chef-solo to run with a certain role? (i)告诉chef-solo以某个角色运行的语法是什么? I managed to use: 我设法使用:

chef-solo --override-runlist "role["oracle"]"

but is it the "right" way to do it (I'd expect I wouldn't need to "override" anything in a standard use of a chef role)? 但它是“正确”的方式吗(我希望在标准使用厨师角色时我不需要“覆盖”任何东西)? Also, if I use this command does it also load all the attributes from the role I specify and not only the runlist? 另外,如果我使用此命令,它还会加载我指定的角色的所有属性,而不仅仅是运行列表?

(ii) Is there a way to have a "default" runlist referenced from solo.rb and then have some (or all) roles somehow "reference" it? (ii)是否有办法从solo.rb引用“默认”运行列表,然后让某些(或所有)角色以某种方式“引用”它? I have a few recipes I need to run under all roles and environments and I rather not copy them to all of my role json files (for maintainability reasons). 我需要在所有角色和环境下运行一些配方,而不是将它们复制到我的所有角色json文件中(出于可维护性原因)。

(PS I am running chef-solo on windows, in case it somehow matters...) (PS我在Windows上运行厨师独奏,万一它在某种程度上很重要......)

You can use the JSON Attributes argument to chef-solo. 您可以将jSON Attributes参数用于chef-solo。

Run

chef-solo -c conf.rb -j conf.json

Where conf.rb sets the cookbook path, file cache path, and any other global settings you want to twiddle, and conf.json looks something like this: conf.rb设置cookbook路径,文件缓存路径以及您想要旋转的任何其他全局设置, conf.json看起来像这样:

{
  "some_attr": true,
  "run_list": [
    "role[solo_provisioned_node]",
    "recipe[mycookbook::myrecipe]"
  ]
}

or in the example you gave, just 或者在你给出的例子中,只是

{
  "run_list": [
    "role[oracle]"
  ]
}

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

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