CentOS 7.x Running an ansible task only once

From Notes_Wiki
Revision as of 14:24, 27 January 2017 by Saurabh (talk | contribs) (Created page with "<yambe:breadcrumb>CentOS_7.x_ansible_tips_and_tricks|CentOS 7.x ansible tips and tricks</yambe:breadcrumb> =CentOS 7.x Running an ansible task only once= ==Running a task onl...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<yambe:breadcrumb>CentOS_7.x_ansible_tips_and_tricks|CentOS 7.x ansible tips and tricks</yambe:breadcrumb>

CentOS 7.x Running an ansible task only once

Running a task only once per run

To run task only once per playbook run (ie not again and again for every host), use:

     run_once: true

Refer http://stackoverflow.com/questions/22070232/how-to-get-an-ansible-check-to-run-only-once-in-a-playbook


Running a task only once even among re-run of the same playbook

To run task only once even if playbook is re-run use creates option of shell module such as:

     shell: <thing to be done only once>; touch /root/thing_done
     args:
       creates: /root/thing_done

Refer http://stackoverflow.com/questions/26409164/ansible-ignore-the-run-once-configuration-on-task


<yambe:breadcrumb>CentOS_7.x_ansible_tips_and_tricks|CentOS 7.x ansible tips and tricks</yambe:breadcrumb>