ansible-auto-scaling-tutorial icon indicating copy to clipboard operation
ansible-auto-scaling-tutorial copied to clipboard

build-ami variable not defined

Open 4id3y opened this issue 9 years ago • 2 comments

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

4id3y avatar Oct 12 '16 14:10 4id3y

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

manicminer avatar Oct 13 '16 16:10 manicminer

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

jsteinich avatar Nov 05 '16 22:11 jsteinich