Ansible - run_once parameter
by
Jeremy Canfield |
Updated: January 04 2021
| Ansible articles
The run_once parameter can be used to run a task one time. This is typically used when you are doing something on the control node (that's your Ansible server). In this example, the set_fact module and the lookup plugin are used to store the contents of the foo.txt file into a variable named foo, and run_once is used to ensure this task is only ran one time.
- set_fact:
foo: "{{ lookup('file', 'foo.txt') }}"
run_once: true
Did you find this article helpful?
If so, consider buying me a coffee over at