# How to run commands on a host created by add\_host in a role run on localhost

**URL:** <https://forum.ansible.com/t/how-to-run-commands-on-a-host-created-by-add-host-in-a-role-run-on-localhost/23942>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [March 12, 2017, 4:25am UTC](https://forum.ansible.com/t/how-to-run-commands-on-a-host-created-by-add-host-in-a-role-run-on-localhost/23942 "2017-03-12T04:25:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zhu\_Wayne](https://avatars.discourse-cdn.com/v4/letter/z/ecc23a/32.png) [@Zhu\_Wayne](https://forum.ansible.com/u/Zhu_Wayne)\
**Post date:** [March 12, 2017, 4:25am UTC](https://forum.ansible.com/t/how-to-run-commands-on-a-host-created-by-add-host-in-a-role-run-on-localhost/23942/1 "2017-03-12T04:25:48Z")

</div>

Here is my ansible playbook. I want to use role ec2\_jumphost to create an EC2 instance and format / mount attached EBS volumes. I used add\_host in the role to add the new EC2 instance as a host. How can I run commands in the role on the new EC2 instance?

Here is my ansible playbook - aws.yml.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [March 13, 2017, 11:13pm UTC](https://forum.ansible.com/t/how-to-run-commands-on-a-host-created-by-add-host-in-a-role-run-on-localhost/23942/2 "2017-03-13T23:13:50Z")

</div>

You can use delegate\_to , or add 2nd play that uses the new group and  
put the tasks there.
