ansible tag code example
Example 1: ansible tags
tasks:
- yum:
name:
- httpd
- memcached
state: present
tags:
- packages
- template:
src: templates/src.j2
dest: /etc/foo.conf
tags:
- configuration
Example 2: how to use tags in ansible
# Tags goes at same indentation as name or service:
- name: Create Postgres Container
tags: createcontainer
docker_container:
name: mypostgres
...
# Then in the command line:
ansible-playbook myplaybook.yaml --tags createcontainer