November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Tags in ansible

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

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>