build-ami variable not defined
Hi There. Loving this tutorial, however I have come accross an error when trying to build the ami.
The error I receive is:
TASK [build-ami : Create AMI] ************************************************** 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: 'ec2_id' is undefined\n\nThe error appears to have been in '/etc/ansible/roles/build-ami/tasks/main.yml': line 4, 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: Create AMI\n ^ here\n"}
Do you know where this variable is supposed to be set?
Adrian
Hi @4id3y, the ec2_id variable should be set by the launch role -- https://github.com/atplanet/ansible-auto-scaling-tutorial/blob/master/roles/launch/tasks/main.yml#L29-L34
I got the same error (though I have made some other modifications) running ansible 2.1.2.0 I solved by added another task to the launch role:
- name: Keep track of new instance id
set_fact:
ec2_id: "{{ item.id }}"
with_items: '{{ec2.instances}}'
I then got:
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_date_time' is undefined
which I solved by removing the gather_facts: no from the playbook calling build-ami