What Is the Syntax for Viewing ec2_instance_info Return Values in Ansible?

Problem scenario
You read about a supported data type (defined keys) in Ansible playbooks related to EC-2 servers in AWS. How do you view this data?

Solution

  1. Have a playbook (.yaml file) with the following syntax:

ec2_instance_info:
region: us-west-1
register: vara

  1. Refer to vara as a variable. Here is an example of how to see it:

debug:
msg: "{{ item.instance_id }}"
loop: "{{ vara.instances }}"

Leave a comment

Your email address will not be published. Required fields are marked *