How to run commands on a host created by add_host in a role run on localhost

34 views
Skip to first unread message

Zhu Wayne

unread,
Mar 12, 2017, 11:30:30 AM3/12/17
to Ansible Project
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.
---
...
- name: Create AWS Jump Host
  hosts: localhost
  connection: local
  gather_facts: no
  vars_files:
    - "derived_vars/{{ vpc_name }}.yml"
  roles:   
    - ec2jumphost


Brian Coca

unread,
Mar 13, 2017, 7:14:05 PM3/13/17
to Ansible Project
You can use delegate_to , or add 2nd play that uses the new group and
put the tasks there.

----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages