Hi all,
How do you play just the tasks with set tags in your playbook? From the command line you would do something like:
ansible-playbook -i staging deploy.yml --tags “do_stop, do_health_check”
I would expect do be able to do the same from the playbook like:
- hosts: somehosts
roles:
- { role: connect, tags: [ ‘do_stop’, ‘do_health_check’ ] }
However this is not working and it plays all the tasks in my role.
Regards,
Brendon
Pass the “–tags” option to ansible-playbook to run only the tags you want to run.
What you did above, BTW, is apply the tag “do_stop” and “do_health_check” to every task in your role. This isn’t what you want, I’m guessing.
Thanks all. I know that I can call tags from the command line and that my example will apply new tags in my playbook. But to me a playbook by design should be able to run all the tasks that you need to run by calling the tags you have set in tasks/*.yml. Instead we are now presented with 2 options:
- Write a wrapper script (oh no)
- Further dismantle tasks into separate yml files so that you can call these with include in your playbook.
Surely a playbook by design should be a playbook?
Many thanks.
“Surely a playbook by design should be a playbook?”
All ducks must quack, except when they are elephants.
This is why I generally don’t join forums. Clearly your experience is limited to a small component stack and I should have gone with Chef.