[Ansible] – How to use tags?

Tags is an attribute which can be used to allow or not run some tasks when just some specific tag is informed. It can be useful when is required some specific action when the script will be executed in a development environment for example. Following an example.

- hosts: all
  - name: Install postgresql 
      name: postgresql
      state: latest
      - development
  - name: Start postgresql 
      name: postgresql 
      state: started

Then, if the above playbook is executed with the following command the task to install the postgresql will be performed. 

$ ansible-playbook playbook.yml –tags ‘development’

Also, it is possible to skype the execution of some tags via the parameter –skip-tags  as the following example.

$ ansible-playbook playbook.yml –skip-tags ‘test’

For further information check the Tags Ansible documentation  

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s