tags in ansible

[root@workstation ~]# vim tags.yaml

– name: installing postfix and stopping from starting service
hosts: localhost
tasks:
– name: installing postfix package
yum: name=postfix state=latest
tags: packageonly
– name: starting service
service: name=postfix state=started
[root@workstation ~]# ansible-playbook –syntax-check tags.yaml

playbook: tags.yaml
[root@workstation ~]# ansible-playbook -C tags.yaml

PLAY [installing postfix and stopping from starting service] *******************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [installing postfix package] **********************************************
changed: [localhost]

TASK [starting service] ********************************************************
fatal: [localhost]: FAILED! => {“changed”: false, “failed”: true, “msg”: “Could not find the requested service postfix: cannot check nor set state”}
to retry, use: –limit @/root/tags.retry

PLAY RECAP *********************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=1

[root@workstation ~]#
[root@workstation ~]# ansible-playbook -C tags.yaml –tags ‘packageonly’

PLAY [installing postfix and stopping from starting service] *******************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [installing postfix package] **********************************************
changed: [localhost]

PLAY RECAP *********************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0

[root@workstation ~]# ansible-playbook tags.yaml –tags ‘packageonly’

PLAY [installing postfix and stopping from starting service] *******************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [installing postfix package] **********************************************
changed: [localhost]

PLAY RECAP *********************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0

[root@workstation ~]# ansible-playbook tags.yaml –skip-tags ‘packageonly’

PLAY [installing postfix and stopping from starting service] *******************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [starting service] ********************************************************
changed: [localhost]

PLAY RECAP *********************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0

 

Advertisements

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 )

Google+ photo

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

Connecting to %s