Skip to content

Instantly share code, notes, and snippets.

@natefoo
Last active January 15, 2021 19:51
Show Gist options
  • Save natefoo/b476ab73fead9ed624b077b4b27f5810 to your computer and use it in GitHub Desktop.
Save natefoo/b476ab73fead9ed624b077b4b27f5810 to your computer and use it in GitHub Desktop.
(ansible)natefoo@fanboy% ansible-playbook -i localhost, tag_test_import.yml
PLAY [localhost] ************************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] ******************************************************************************************************************************************************************************************************************************
[WARNING]: Platform darwin on host localhost is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change the meaning of that path. See
https://docs.ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html for more information.
ok: [localhost]
TASK [debug] ****************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "this is include a"
}
TASK [debug] ****************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "this is include a again"
}
TASK [debug] ****************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "this is include b"
}
TASK [debug] ****************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "this is include b again"
}
PLAY RECAP ******************************************************************************************************************************************************************************************************************************************
localhost : ok=5 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
(ansible)natefoo@fanboy% ansible-playbook -i localhost, tag_test_import.yml -e run_tasks_a=false
PLAY [localhost] ************************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] ******************************************************************************************************************************************************************************************************************************
[WARNING]: Platform darwin on host localhost is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change the meaning of that path. See
https://docs.ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html for more information.
ok: [localhost]
TASK [debug] ****************************************************************************************************************************************************************************************************************************************
skipping: [localhost]
TASK [debug] ****************************************************************************************************************************************************************************************************************************************
skipping: [localhost]
TASK [debug] ****************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "this is include b"
}
TASK [debug] ****************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "this is include b again"
}
PLAY RECAP ******************************************************************************************************************************************************************************************************************************************
localhost : ok=3 changed=0 unreachable=0 failed=0 skipped=2 rescued=0 ignored=0
(ansible)natefoo@fanboy% ansible-playbook -i localhost, tag_test_include.yml
PLAY [localhost] ************************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] ******************************************************************************************************************************************************************************************************************************
[WARNING]: Platform darwin on host localhost is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change the meaning of that path. See
https://docs.ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html for more information.
ok: [localhost]
TASK [include_tasks] ********************************************************************************************************************************************************************************************************************************
included: /Users/natefoo/ansible/test/tasks_a.yml for localhost
TASK [debug] ****************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "this is include a"
}
TASK [debug] ****************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "this is include a again"
}
TASK [include_tasks] ********************************************************************************************************************************************************************************************************************************
included: /Users/natefoo/ansible/test/tasks_b.yml for localhost
TASK [debug] ****************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "this is include b"
}
TASK [debug] ****************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "this is include b again"
}
PLAY RECAP ******************************************************************************************************************************************************************************************************************************************
localhost : ok=7 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
(ansible)natefoo@fanboy% ansible-playbook -i localhost, tag_test_include.yml --tags=a
PLAY [localhost] ************************************************************************************************************************************************************************************************************************************
TASK [include_tasks] ********************************************************************************************************************************************************************************************************************************
included: /Users/natefoo/ansible/test/tasks_a.yml for localhost
TASK [debug] ****************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "this is include a"
}
TASK [debug] ****************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "this is include a again"
}
PLAY RECAP ******************************************************************************************************************************************************************************************************************************************
localhost : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
(ansible)natefoo@fanboy% ansible-playbook -i localhost, tag_test_include.yml -e run_tasks_a=false
PLAY [localhost] ************************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] ******************************************************************************************************************************************************************************************************************************
[WARNING]: Platform darwin on host localhost is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change the meaning of that path. See
https://docs.ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html for more information.
ok: [localhost]
TASK [include_tasks] ********************************************************************************************************************************************************************************************************************************
skipping: [localhost]
TASK [include_tasks] ********************************************************************************************************************************************************************************************************************************
included: /Users/natefoo/ansible/test/tasks_b.yml for localhost
TASK [debug] ****************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "this is include b"
}
TASK [debug] ****************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "this is include b again"
}
PLAY RECAP ******************************************************************************************************************************************************************************************************************************************
localhost : ok=4 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
---
- hosts: localhost
connection: local
vars:
run_tasks_a: true
run_tasks_b: true
tasks:
- import_tasks:
file: tasks_a.yml
when: run_tasks_a is true
tags: a
- import_tasks:
file: tasks_b.yml
when: run_tasks_b is true
tags: b
tags: test
---
- hosts: localhost
connection: local
vars:
run_tasks_a: true
run_tasks_b: true
tasks:
- include_tasks:
file: tasks_a.yml
apply:
tags: a
when: run_tasks_a is true
tags: a
- include_tasks:
file: tasks_b.yml
apply:
tags: b
when: run_tasks_b is true
tags: b
tags: test
---
- debug:
msg: this is include a
- debug:
msg: this is include a again
---
- debug:
msg: this is include b
- debug:
msg: this is include b again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment