0
我是Ansible的新手。Ansible | ec2_asg_facts |
我簡單ansible劇本它得到使用ec2_asg_facts並獲取有關特定AWS自動縮放組的每一件事情。假設目前,我只有一個Auto縮放組。
我能夠獲得實例ID,我們已經運行在那些ID ec2_remote_facts。
問題:
現在我想混帳實例的私有IP地址,我有如下粘貼錯誤。請任何人都可以幫助我。
---
- name: Create a new Demo EC2 instance
hosts: localhost
connection: local
gather_facts: False
tasks:
- name: Find ASG in AWS
ec2_asg_facts:
aws_access_key: ------------------------
aws_secret_key: ----------------------
region: us-east-1
register: auto_scaling_group
register: ec2_asg_facts_results
- name: Create list of instance_ids
set_fact:
ec2_asg_instance_ids: "{{ ec2_asg_facts_results.results[0].instances | map(attribute='instance_id') | list }}"
- name: EC2 facts
ec2_remote_facts:
region: us-east-1
aws_access_key: ---------------------------------
aws_secret_key: ---------------------------------
filters:
instance-id: "{{ ec2_asg_instance_ids.instances[0].interfaces | map(attribute='id') }}"
**ERROR**
TASK [EC2 facts] ********************************************************************************************************************************************************************
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: 'list object' has no attribute 'instances'\n\nThe error appears to have been in '/root/ec2-asg.yml': line 25, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n ec2_asg_instance_ids: \"{{ ec2_asg_facts_results.results[0].instances | map(attribute='instance_id') | list }}\"\n - name: EC2 facts\n
沒關係我解決了它。 –