---
- name: superduper playbook
hosts: aws-region1
remote_user: mesrine
pre_tasks:
- include_vars: "{{ env }}/group_vars/vancouver"
when: region is defined and region == 'van'
...snipped...
I want the include_vars
task to execute regardless of whatever tags that are passed in. Right now, any tags that are passed in, are filtering out my include_vars
pre task.
If you assign the always tag to a task or play, Ansible will always run that task or play, unless you specifically skip it ( --skip-tags always ). Fact gathering is tagged with 'always' by default. It is only skipped if you apply a tag and then use a different tag in --tags or the same tag in --skip-tags .
Using the --limit parameter of the ansible-playbook command is the easiest option to limit the execution of the code to only one host. The advantage is that you don't need to edit the Ansible Playbook code before executing to only one host.
Along with ansible-playbook command, use --tags or -t flag and pass the tag name to run only that particular task. You can also pass more than one tags to --tags flag by separating the values with commas. To skip particular tags and run all other tags, you can use --skip-tags flag.
The easiest way to run only one task in Ansible Playbook is using the tags statement parameter of the “ansible-playbook” command. The default behavior is to execute all the tags in your Playbook with --tags all .
You can always use the special tag - always
- to force a task to always run regardless of the tags specified.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With