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

**URL:** <https://forum.ansible.com/t/how-to-write-host-specific-configuration-information-to-a-host-i-spin-up-using-ec2/18110>\
**Category:** Ansible Project\
**Created:** [April 28, 2015, 5:10pm UTC](https://forum.ansible.com/t/how-to-write-host-specific-configuration-information-to-a-host-i-spin-up-using-ec2/18110 "2015-04-28T17:10:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris8](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@chris8](https://forum.ansible.com/u/chris8)\
**Post date:** [April 28, 2015, 5:10pm UTC](https://forum.ansible.com/t/how-to-write-host-specific-configuration-information-to-a-host-i-spin-up-using-ec2/18110/1 "2015-04-28T17:10:38Z")

</div>

I’ve got a playbook that looks like this:

---

<div class="post-metadata">

**Author:** ![chris8](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@chris8](https://forum.ansible.com/u/chris8)\
**Post date:** [April 29, 2015, 3:15pm UTC](https://forum.ansible.com/t/how-to-write-host-specific-configuration-information-to-a-host-i-spin-up-using-ec2/18110/2 "2015-04-29T15:15:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Matt\_Davis](https://forum.ansible.com/u/Matt_Davis)\
**Post date:** [April 29, 2015, 5:24pm UTC](https://forum.ansible.com/t/how-to-write-host-specific-configuration-information-to-a-host-i-spin-up-using-ec2/18110/3 "2015-04-29T17:24:23Z")

</div>

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
