gpt4 book ai didi

amazon-web-services - ansible.vars.unsafe_proxy.AnsibleUnsafeText 对象'没有属性 'public_ip'

转载 作者:行者123 更新时间:2023-12-01 10:28:37 28 4
gpt4 key购买 nike

为什么这个任务(来自 Best way to launch aws ec2 instances with ansible ):

  - name: Add the newly created EC2 instance(s) to the local host group (located inside the directory)
local_action: lineinfile
dest="./hosts"
regexp={{ item.public_ip }}
insertafter="[webserver]" line={{ item.public_ip }}
with_items: ec2.instances

创建这个错误?
TASK [Add the newly created EC2 instance(s) to the local host group (located inside the directory)] ********************************************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'ansible.vars.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'public_ip'\n\nThe error appears to have been in '/Users/snowcrash/ansible-ec2/ec2_launch.yml': line 55, column 9, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: Add the newly created EC2 instance(s) to the local host group (located inside the directory)\n ^ here\n"}

最佳答案

问题在这里

with_items: ec2.instances

它应该是:
with_items: '{{ ec2.instances }}'

ec2 是引用字典的变量,因此您需要使用正确的语法来引用它

关于amazon-web-services - ansible.vars.unsafe_proxy.AnsibleUnsafeText 对象'没有属性 'public_ip',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45259207/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com