【问题标题】:Passing an integer value through a node attribute in chef通过厨师中的节点属性传递整数值
【发布时间】:2019-05-10 16:00:12
【问题描述】:

我是厨师新手。请让我知道如何将整数值作为节点属性 (chef-client -j) 传递。

尝试使用 json 输入,但我无法将哈希值转换为整数。 例如:如果我传递我的 -j count:"1" ,我需要输出 node['count'] 整数值而不是哈希值。

有人可以帮我在 Chef 中将其转换为整数值吗?或者有没有其他方法可以将我的整数输入发送给 Chef?

【问题讨论】:

    标签: ruby chef-infra chef-recipe


    【解决方案1】:

    您可以使用 --json-attribute 在 chef-client 执行中提供任何(原始)节点属性,只需确保您提供的 json 是有效的 json 文件或有效的 json 字符串。

    试试这个:

    $ chef-client -j '{"count": 1}'
    

    【讨论】: