Make Ansible included playbooks run on same hosts as their parent -


helllo, best way make included playbook run on same hosts playbook called him? i've tried declaring variable in parent playbook host name , passing included playbook, error telling me variable undefined.

below playbook:

---    # main staging configuration playbook - vars:      host_name: "stage_ansible"   hosts: "{{ host_name }}"   remote_user: ubuntu   tasks:       - name: test connection       ping:       remote_user: ubuntu  - include: nginxdefinitions.yml   vars:     service_name: "interaction.qmerce.com"     env_name: "stage4"     host_name_pass: "{{ host_name }}" ... 

and error i'm receiving:

`error! 'host_name' undefined 

if want define hosts runtime , avoid hard coding them on playbook, can pass hosts as variables on command line.

to so, remove vars definition first play , add following ansible-playbook command line:

--extra-vars host_name=localhost 

or when have multiple hosts:

--extra-vars '{"host_name":["host1","host2","host3"]}' 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -