{"id":7327,"date":"2018-04-06T09:04:04","date_gmt":"2018-04-06T01:04:04","guid":{"rendered":"http:\/\/rmohan.com\/?p=7327"},"modified":"2018-04-06T09:04:04","modified_gmt":"2018-04-06T01:04:04","slug":"tags-in-ansible","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=7327","title":{"rendered":"Tags in ansible"},"content":{"rendered":"<p>Tags in ansible<\/p>\n<p>[root@workstation ~]# vim tags.yaml<br \/>\n\u2014<br \/>\n\u2013 name: installing postfix and stopping from starting service<br \/>\nhosts: localhost<br \/>\ntasks:<br \/>\n\u2013 name: installing postfix package<br \/>\nyum: name=postfix state=latest<br \/>\ntags: packageonly<br \/>\n\u2013 name: starting service<br \/>\nservice: name=postfix state=started<br \/>\n[root@workstation ~]# ansible-playbook \u2013syntax-check tags.yaml<\/p>\n<p>playbook: tags.yaml<br \/>\n[root@workstation ~]# ansible-playbook -C tags.yaml<\/p>\n<p>PLAY [installing postfix and stopping from starting service] *******************<\/p>\n<p>TASK [setup] *******************************************************************<br \/>\nok: [localhost]<\/p>\n<p>TASK [installing postfix package] **********************************************<br \/>\nchanged: [localhost]<\/p>\n<p>TASK [starting service] ********************************************************<br \/>\nfatal: [localhost]: FAILED! =&gt; {\u201cchanged\u201d: false, \u201cfailed\u201d: true, \u201cmsg\u201d: \u201cCould not find the requested service postfix: cannot check nor set state\u201d}<br \/>\nto retry, use: \u2013limit @\/root\/tags.retry<\/p>\n<p>PLAY RECAP *********************************************************************<br \/>\nlocalhost : ok=2 changed=1 unreachable=0 failed=1<\/p>\n<p>[root@workstation ~]#<br \/>\n[root@workstation ~]# ansible-playbook -C tags.yaml \u2013tags \u2018packageonly\u2019<\/p>\n<p>PLAY [installing postfix and stopping from starting service] *******************<\/p>\n<p>TASK [setup] *******************************************************************<br \/>\nok: [localhost]<\/p>\n<p>TASK [installing postfix package] **********************************************<br \/>\nchanged: [localhost]<\/p>\n<p>PLAY RECAP *********************************************************************<br \/>\nlocalhost : ok=2 changed=1 unreachable=0 failed=0<\/p>\n<p>[root@workstation ~]# ansible-playbook tags.yaml \u2013tags \u2018packageonly\u2019<\/p>\n<p>PLAY [installing postfix and stopping from starting service] *******************<\/p>\n<p>TASK [setup] *******************************************************************<br \/>\nok: [localhost]<\/p>\n<p>TASK [installing postfix package] **********************************************<br \/>\nchanged: [localhost]<\/p>\n<p>PLAY RECAP *********************************************************************<br \/>\nlocalhost : ok=2 changed=1 unreachable=0 failed=0<\/p>\n<p>[root@workstation ~]# ansible-playbook tags.yaml \u2013skip-tags \u2018packageonly\u2019<\/p>\n<p>PLAY [installing postfix and stopping from starting service] *******************<\/p>\n<p>TASK [setup] *******************************************************************<br \/>\nok: [localhost]<\/p>\n<p>TASK [starting service] ********************************************************<br \/>\nchanged: [localhost]<\/p>\n<p>PLAY RECAP *********************************************************************<br \/>\nlocalhost : ok=2 changed=1 unreachable=0 failed=0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tags in ansible<\/p>\n<p>[root@workstation ~]# vim tags.yaml \u2014 \u2013 name: installing postfix and stopping from starting service hosts: localhost tasks: \u2013 name: installing postfix package yum: name=postfix state=latest tags: packageonly \u2013 name: starting service service: name=postfix state=started [root@workstation ~]# ansible-playbook \u2013syntax-check tags.yaml<\/p>\n<p>playbook: tags.yaml [root@workstation ~]# ansible-playbook -C tags.yaml<\/p>\n<p>PLAY [installing postfix and stopping from [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[91],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7327"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7327"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7327\/revisions"}],"predecessor-version":[{"id":7328,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7327\/revisions\/7328"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7327"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7327"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7327"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}