Using ec2_facts inside a playbook syntax

72 views
Skip to first unread message

Vasiliy Boulytchev

unread,
Dec 14, 2015, 8:39:19 PM12/14/15
to Ansible Project
Folks, consider the following playbook:

##
- name: Gather facts
  action: ec2_facts

- debug: msg="{{ ec2_facts }}"
##

Produces a fatal error: `fatal: [10.1.15.119] => One or more undefined variables: 'ec2_facts' is undefined`

However, It does seem to be pulling in the ec2 metadata:

ok: [10.1.15.119] => {"ansible_facts": {"ansible_ec2_ami_id": "ami-f0091d...


How does one access this metadata instance a playbook?  I guess I need help with correct syntax.

Is this correct?  {{ ansible_facts.ansible_ec2_ami_id }} ?

Thanks!

Alexey Vazhnov

unread,
Dec 15, 2015, 12:38:22 AM12/15/15
to Ansible Project
ec2_facts return variables with name ansible_ec2*.
If you want to see all variables, try to use https://github.com/f500/ansible-dumpall
«{{ ansible_facts.ansible_ec2_ami_id }}» is wrong, use «{{ ansible_ec2_ami_id }}».
Reply all
Reply to author
Forward
0 new messages