how to convince ansible to run a block of tasks only once?

Viewed 30

We are having a really large playbook for our systems. The whole playbook runs on every update cycle - which is sick.

A lot of tasks are things like installing basic apt packages (like git) which is only needed once until the task really changed, e.g. if we change the list of packages to be installed.

I thought about something like creating a block of those tasks and storing a version file somewhere, I would then compare the content of that file to the version of the block before running the block again, which unfortunately takes a real long time otherwise.

On the other hand, I could also imagine something like a incremental update playbook which only updates the things really needed based on the previous playbooks.

To me that issue feels very basic, therefore I wonder if something like that is maybe already implemented in ansible in one or another way - I would like to avoid reinventing the wheel.

1 Answers

If you take the call another yml file, you have to use

include_tasks module

because of using

run_once: true

accordingly.

Related