Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mkdir -p /tmp/test_inv/{tools,inventory/vars/{template,g1/g2/g3},group_vars}
- cd /tmp/test_inv
- git clone https://github.com/jtyr/ansible-yaml_inventory.git tools/yaml_inventory
- ln -s ./tools/yaml_inventory/yaml_inventory.py ./hosts
- cat > ./site.yaml <<END
- ---
- - hosts: all
- connection: local
- gather_facts: no
- tasks:
- - debug:
- msg: Host from the group {{ xxx }} are using template {{ yyy + ((' and ' + zzz) if zzz is defined else '') }}
- END
- cat > ./inventory/main.yaml <<END
- ---
- g1:
- g2:
- :templates:
- - template-app1
- :hosts:
- - g2h1
- g3:
- :templates:
- - template-app1
- - template-app2
- :hosts:
- - g3h1
- END
- cat > ./inventory/vars/g1/g2/all <<END
- ---
- xxx: G2
- END
- cat > ./inventory/vars/g1/g2/g3/all <<END
- ---
- xxx: G3
- END
- cat > ./inventory/vars/template/app1 <<END
- ---
- yyy: APP1
- END
- cat > ./inventory/vars/template/app2 <<END
- ---
- zzz: APP2
- END
- ansible-playbook -i hosts -l g2h1 site.yaml
- ansible-playbook -i hosts -l g3h1 site.yaml
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement