Setting a variable in one playbook and using that in another

Hi Everyone,

Hope all are well .

I have a small query where in i want to know if i can set a variable in one playbook and use that in another playbook.

For eg
Playbook1 : setting a var with output of shell
set_fact:
var1: test

Playbook2

  • debug:
    msg: “{{ var1 }}”

Note : i found one way that i can write these two playbooks and import both using one main playbook , that seems to perform the scenario(still need to test this though :-))

Other than this if anyone has had this scenario before or can provide some insight on this , please do share.

Thanks a lot.

When you need to persist a variable between playbooks, you can use a
dummy host to tie the variable to:
https://stackoverflow.com/a/47811099

Thanks a lot D.Visser , appreciate it :slight_smile: