![]() ![]() You add tags to includes the same way you add tags to any other task: See Selectively running tagged tasks in re-usable files for more details. If you add mytag to a dynamic include, then run that playbook with -tags mytag, Ansible runs the include itself, runs any tasks within the included file or role tagged with mytag, and skips any tasks within the included file or role without that tag. As with tags on an individual task, tags on an include_* task apply only to the include itself, not to any tasks within the included file or role. You can apply tags to dynamic includes in a playbook. If you ran these four tasks in a playbook with -tags ntp, Ansible would run the three tasks tagged ntp and skip the one task that does not have that tag. # file: roles/common/tasks/main.yml - name : Install ntp : name : ntp state : present tags : ntp - name : Configure ntp : src : 2 dest : /etc/ntp.conf notify : - restart ntpd tags : ntp - name : Enable and run ntpd : name : ntpd state : started enabled : true tags : ntp - name : Install NFS utils : name : - nfs-utils - nfs-util-lib state : present tags : filesharing Here is an example that tags two tasks with different tags: You can add tags to tasks in playbooks, in task files, or within a role. Adding tags to individual tasks Īt the simplest level, you can apply one or more tags to an individual task. See Selecting or skipping tags when you run a playbook for more details. You can only select or skip tasks based on tags at the command line when you run a playbook. The tags keyword always defines tags and adds them to tasks it does not select or skip tasks for execution. The keyword tags addresses all these use cases. You can also add tags to multiple tasks by defining them at the level of a block, play, role, or import. You can add tags to a single task or include. Selectively running tagged tasks in re-usable files Selecting or skipping tags when you run a playbook Tag inheritance for includes: blocks and the apply keyword Tag inheritance: adding tags to multiple tasks Select or skip tags when you run your playbook. Controlling how Ansible behaves: precedence rulesĪdd tags to your tasks, either individually or with tag inheritance from a block, play, role, or import.Virtualization and Containerization Guides. ![]() Protecting sensitive data with Ansible vault.Controlling playbook execution: strategies and more.Executing playbooks for troubleshooting.Selecting or skipping tags when you run a playbook.Understanding privilege escalation: become.Validating tasks: check mode and diff mode. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |