I have seen others ask for this. Hopefully, there will eventually be a more elegant method. However, I believe that the only way to do this is, as you said, use a variable. I do this for debug or testing tasks that I don't want to run normally, but if I pass -e '{"run_tests":true}' when I run the playbook they will execute.
#roles/stuff/tasks/main.yml --- - name: Run Tests (when run_tests is true) include: tests.yml when: run_tests|default(false) and then you can either pass run_tests as an extra-var, or define it in a playbook: - name: Testing stuff hosts: things vars: run_tests: true roles: - { "role":"stuff", "tags":["logit"] } or - name: Testing stuff hosts: things roles: - { "role":"stuff", "tags":["logit"], "run_tests": true } -- 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/f549d22a-fdee-4e44-a554-664a943e97bf%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.