My playbook (/home/user/Ansible/dist/playbooks/test.yml
):
- hosts: regional_clients
tasks:
- shell: /export/home/user/ansible_scripts/test.sh
register: shellout
- debug: var=shellout
- hosts: web_clients
tasks:
- shell: /var/www/html/webstart/release/ansible_scripts/test.sh
register: shellout
- debug: var=shellout
- command: echo catalina.sh start
register: output
- debug: var=output
The [regional_clients]
group is specified in /home/user/Ansible/webproj/hosts
and the [web_clients]
group is specified in /home/user/Ansible/regions/hosts
.
Is there a way I could make the above work? Currently, running the playbook will fail since neither [regional_clients]
or [web_clients]
are defined in the default inventory file /home/user/Ansible/dist/hosts
.
Yes, you can write a simple shell script:
#!/bin/sh
cat /home/user/Ansible/webproj/hosts /home/user/Ansible/regions/hosts
and call it as a dynamic inventory in Ansible:
ansible-playbook -i my_script test.yml
This question, however, looks to me like a problem with your organisation, not a technical one. If your environment is so complex and maintained by different parties, then use some kind of configuration database (and a dynamic inventory in Ansible which would retrieve the data), instead of individual files in user's paths.