Hi, I was trying out a few sample playbooks to understand the difference between static n dynamic imports, and i am stuck at a point where i am not sure what am i doing wrong.
*hosts.info* [docker] docker1 ansible_host=0.0.0.0 *include_with_vars.yaml* --- - hosts: docker tasks: - include_tasks: "{{ condition | ternary ('docker1.yaml', 'docker2.yaml') }}" *import_with_vars.yaml* --- - hosts: docker tasks: - import_tasks: "{{ condition | ternary ('docker1.yaml', 'docker2.yaml') }}" (docker1.yaml prints "msg": "Tasks 1 Host 1" and docker2.yaml prints "msg": "Tasks 2 Host 2") No matter how i execute this, it always includes/import docker1.yaml [root@8a98ab1d7dea include]# ansible --version ansible 2.4.3.0 config file = /etc/ansible/ansible.cfg configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible-2.4.3.0-py2.7.egg/ansible executable location = /usr/bin/ansible python version = 2.7.5 (default, Aug 4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] [root@8a98ab1d7dea include]# ansible-playbook -i hosts.info include_with_vars.yaml -e condition=false PLAY [docker] *************************************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************************************** ok: [docker1] TASK [include_tasks] ******************************************************************************************************************************************************************************** included: /opt/include/docker1.yaml for docker1 TASK [debug] **************************************************************************************************************************************************************************************** ok: [docker1] => { "msg": "Tasks 1 Host 1" } PLAY RECAP ****************************************************************************************************************************************************************************************** docker1 : ok=3 changed=0 unreachable=0 failed=0 [root@8a98ab1d7dea include]# ansible-playbook -i hosts.info include_with_vars.yaml -e condition=true PLAY [docker] *************************************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************************************** ok: [docker1] TASK [include_tasks] ******************************************************************************************************************************************************************************** included: /opt/include/docker1.yaml for docker1 TASK [debug] **************************************************************************************************************************************************************************************** ok: [docker1] => { "msg": "Tasks 1 Host 1" } PLAY RECAP ****************************************************************************************************************************************************************************************** docker1 : ok=3 changed=0 unreachable=0 failed=0 [root@8a98ab1d7dea include]# ansible-playbook -i hosts.info import_with_vars.yaml -e condition=false PLAY [docker] *************************************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************************************** ok: [docker1] TASK [debug] **************************************************************************************************************************************************************************************** ok: [docker1] => { "msg": "Tasks 1 Host 1" } PLAY RECAP ****************************************************************************************************************************************************************************************** docker1 : ok=2 changed=0 unreachable=0 failed=0 [root@8a98ab1d7dea include]# ansible-playbook -i hosts.info import_with_vars.yaml -e condition=true PLAY [docker] *************************************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************************************** ok: [docker1] TASK [debug] **************************************************************************************************************************************************************************************** ok: [docker1] => { "msg": "Tasks 1 Host 1" } PLAY RECAP ****************************************************************************************************************************************************************************************** docker1 : ok=2 changed=0 unreachable=0 failed=0 -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/8c53bf99-30ae-4cb4-96cc-1d6fdfd97d77%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.