chef-infra - 数据包 'aws_opsworks_instance' 不可用

标签 chef-infra aws-cloudformation aws-opsworks

有谁知道为什么

instance = search('aws_opsworks_instance', 'self:true').first

# ...

    instance_host: instance['hostname']

会间歇性地导致

undefined method `[]' for nil:NilClass

在 OpsWorks 上?

我已经搜索了几个小时,但没有找到任何东西,所以我开始认为这是一个副产品,而不是真正的问题。

由于这种情况每隔一段时间就会发生一次,我认为这可能是一种“竞争条件”。也许 OpsWorks 需要一段时间才能注入(inject),所以需要让 Chef 等待?如果是这样,我在文档中找不到任何类似的内容。

有什么想法为什么会发生这种情况以及如何修复/避免它吗?

最佳答案

这是特定于 aws opswork 的。这是 aws documentation 的摘录:

Chef search with self:true finds the data bag item that contains information related to the instance that the recipe is being executed on.

从帖子的输出中,instancenull,这是 search() 在没有搜索时返回的值结果。

也许使用 --log_level debug 运行 Chef-client 将揭示更多信息或尝试联系 AWS 支持团队。

关于chef-infra - 数据包 'aws_opsworks_instance' 不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58223822/

相关文章:

chef-infra - Chef,如何在创建服务之前运行创建 init.d 脚本的模板

ruby - 您如何模块化 Chef Recipe ?

aws-cloudformation - 调用CreateChangeSet操作时发生错误(ValidationError): Parameters: [UserDataS3script] must have values

redis - 如何使用 Chef JSON 设置 redis 和 sidekiq 配置

ruby - OpsWorks Chef : Cannot compile yum cookbook due to old Ruby (1. 8.7)

chef-infra - 使用修改后的 opsworks 部署 cookbook 不可变对象(immutable对象)错误

chef-infra - 如何将 InSpec 测试限制为特定的操作系统版本

amazon-web-services - 让 CloudFormation Stack 自删除的最佳方法是什么?

amazon-web-services - 使用 CloudFormation 将 LoadBalancer 批量添加到 AutoScaling 组

mysql - AWS Mysql 5.5.40 安全组问题 强制更新