Setting a variable in one playbook and using that in another

31 views
Skip to first unread message

Akshay Kumar

unread,
Dec 15, 2020, 11:54:35 AM12/15/20
to Ansible Project
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.

Dick Visser

unread,
Dec 15, 2020, 12:27:52 PM12/15/20
to ansible...@googlegroups.com
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
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0a29e9b7-3ba0-4540-a31b-ed0cdfeb4607n%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Akshay Kumar

unread,
Dec 16, 2020, 8:32:20 AM12/16/20
to ansible...@googlegroups.com
Thanks a lot D.Visser , appreciate it :-)

Reply all
Reply to author
Forward
0 new messages