Ansible - run_once parameter

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 Buy Me A Coffee

Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





Please enter 79329 in the box below so that we can be sure you are a human.