How to write host-specific configuration information to a host I spin up using ec2

I’ve got a playbook that looks like this:

Does anybody have any idea about the question below, or how to answer it? Is there a better place to ask for help?

Hi Chris,

The item you used to create the EC2 instance in the loop should be registered in the corresponding result object as “item”. What about:

  • name: Execute script
    shell: /opt/comp/scripts/init/{{ item[0].item.script }}.sh

with_subelements:

  • ec2.results
  • instances

There are other ways to address some of the issues you ran into (just for future reference):

  • Try copy with delegate_to to drop custom facts (delegate_to will copy from the control machine to the delegated host).
  • Fetch (and/or run) your scripts or dump custom facts during instance creation with ec2 user_data scripting

Good luck!

  • Matt Davis
    Senior Solutions Architect @ Ansible