ansible - two plays with two different host in same playbook with dependency -


senario:

1. need run 2 plays in single playbook. 2. second play should run after first play. 3. first play create few instance , update inventory file making new group. 4. second play uses updated group , install few packages. 

problem: if running both plays separately success. but, need them in same scripts.

the problem think both play executing in parallel.

and in advance.

---  - name: ec2    hosts: localhost    connection: local    roles:    - launchec2  - hosts: ansible    gather_facts: fasle    become: yes       roles:    - python 

output:

play [ec2] *********************************************************************  task [setup] ******************************************************************* ok: [127.0.0.1]  task [launchec2 : include_vars] ************************************************ ok: [127.0.0.1]  task [launchec2 : launch new ec2 instance] ************************************* changed: [127.0.0.1]  task [launchec2 : add ec2 ip hostgroup] ********************************* changed: [127.0.0.1] => (item={.....})  task [launchec2 : wait ssh come up] ************************************* ok: [127.0.0.1] => (item={.....})  play [ansible] *****************************************************************  task [python : install python] ************************************************* skipping: [34.203.228.19]  play recap ********************************************************************* 127.0.0.1                  : ok=5    changed=2    unreachable=0    failed=0    34.203.228.19              : ok=0    changed=0    unreachable=0    failed=0 

ansible loads inventory before processing playbook.

in case second play has same inventory before modification in first play.

generally when provision cloud hosts may want use add_host dynamically add new hosts in memory inventory, available subsequent plays.

you may try call meta: refresh_inventory after inventory modification, i'm not sure wether work updating static inventory.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -