Passing One Item Through Entire Playbook Instead of All Items

Hi,

I want to pass only one item from a list of variables throughout the entire playbook.

For Example, I have six action tasks within the playbook and from the first action task output data using jinja2 template defined a variable using “set_fact” and appended the required values into a list.Now using “with_items” I could able to pass all the values into other five action tasks. And each action task is getting executed with items defined for that play.

But instead of passing all the values once, can I have a possibility like first item should pass through the five action tasks and second item should pass through the same five action tasks again and so on.Even I have checked with “loop_control” for passing each item through the five action tasks.

Can we have an item to be passed through the entire playbook instead of using with_items where for each play we define this with_items to be passed as an item and get the output of all the items.

Thanks,
Acharya Tejaswi Indurthy.

Its hard to understand without seeing your playbook tasks but it sounds like you want to loop through a set of tasks, which you can do by looping over include_role or import_role However it is well worth reading through this thread https://github.com/ansible/ansible/issues/13262

Depending on what you are trying to achieve there might be another way to go about it which doesn’t involve complex looping and making a playbook that might be hard for others to understand.

You might, for example, be able to use handlers to trigger certain tasks only when another has reported that it is changed.

Or if you have some very specific requirements maybe some parts might be best written as a script or a custom module.

Hope this helps but its hard to make useful suggestions without seeing the detail of what you are trying to achieve.

Jon