Python Pychef : Not able to search attributes using class chef. 搜索

标签 python chef-infra pychef

我正在尝试获取我的 Chef 服务器上具有特定名称的 Recipe 的节点列表。

 nodes_list = Search('node', 'cookbooks:<cookbook_name')
 for row in nodes_list:
      print(row['ipaddress'])

它不返回任何结果。我如何搜索其中包含特定 Recipe 名称的节点。

最佳答案

您可以使用 bash 单行 for 循环来完成此操作:

for nodes in $(knife node list); do knife node show $nodes -r; done

如果您只想查看具有特定 Recipe 的节点:

for nodes in $(knife node list); do knife node show $nodes -r | grep COOKBOOK; done

关于Python Pychef : Not able to search attributes using class chef. 搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57923640/

相关文章:

python - 获取 Chef.Exceptions.ChefServerError : Method Not Allowed while creating Role in chef

python - KeyError : 'driver' in print(response. request.meta ['driver' ].title)

python - 如果通过配置管理调用,getfilesystemencoding() 会有所不同

python请求json返回单引号

python - `<>` 在 Python 中是什么意思?

windows - 如何在没有 Chef 服务器的情况下运行 Chef ( Chef solo/Chef 零)

tomcat - 如何在我不修改的本地 mac 上运行多个支持应用程序 (tomcat)?

amazon-ec2 - 无法使用 FQDN 为 Chef 客户端配置创建节点