name: find an ami if none is given
ec2_ami_find:
name: “{{ ami_search_string }}”
region: “{{ region }}”
virtualization_type: hvm
owner: aws-marketplace
sort: creationDate
sort_order: descending
sort_end: 1
register: os_image
when:
lc_ami is not defined
name: set the ami
set_fact:
lc_ami: “{{ os_image.results[0].ami_id }}”
when:
lc_ami is not defined
os_image is defined
name: Delete previous launch configuration and auto scaling group if they exist
include: delete_previous.yml
when: delete_previous
TASK [aws/asg : set the ami] ***************************************************
13:41:56
22
efatal: [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 element 0\n\nThe error appears to have been in ‘/var/lib/awx/projects/_1067__production_us/roles/aws/asg/tasks/main.yml’: line 14, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: set the ami\n ^ here\n”}e
What specific AMI did you expect your code to find?
Did you manually locate that AMI in the available AMIs for that region?
I.e., do you know for a fact that the AMI you seek does exist and does match that search string? Please tell us the specific AMI ID that you think matches your search string.
Also, you have provided two different search strings - which one is being used by your code?