3

From Ansible's official doc

Ansible modules normally return a data structure that can be registered into a variable, or seen directly when output by the ansible program

and

Ansible modules normally return a data structure that can be registered into a variable, or seen directly when output by the ansible program

However, the document on aws_ec2 module

  1. Doesn't document return values
  2. Has this example, which seems like it actually has some specific return values
# Stripped version

# Launch instances, runs some tasks
# and then terminate them

- name: Create a sandbox instance
  ... # hosts, vars...
  tasks:
    - name: Launch instance
      ec2:
      ... # ec2 module specs
      register: ec2 #This seems to be one of the specific return structure by this module

    - name: Wait for SSH to come up
      ... # some module
      with_items: "{{ ec2.instances }}" # This is where the registered return value is used

Question: How to see all possible return values of a module, even without documentation

5

if you do something like:

- name: Launch instance
  ec2:
  register: data_struct

You can then output all the values returned by doing this below the above code:

- name: print all returned values
  debug:
    msg: "{{ data_struct }}"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.