amazon web services - Ansible use ec2 public ip of one play in another play -
i have following ansible playbook.
--- - name: ansible playbook create new aws dev instance hosts: localhost roles: - aws - name: set dev server hosts: roles: - services
in aws
role, creating ec2 instance , registering ec2_instance
. how use public ip of newly created instance in hosts of second play.
should use hosts: ec2_instance.public_ip
?
you may consider using add_host. put in first play (after getting ip of new vm):
- name: adding new host in inventory file. add_host: name=somename ansible_ssh_host="{{your_ip}}" ansible_ssh_pass=*** groups=new_group
and use group in second play:
- name: set dev server hosts: new_group
Comments
Post a Comment