# passing variable in another playbook

**URL:** <https://forum.ansible.com/t/passing-variable-in-another-playbook/32478>\
**Category:** Ansible Project\
**Created:** [March 17, 2020, 5:00am UTC](https://forum.ansible.com/t/passing-variable-in-another-playbook/32478 "2020-03-17T05:00:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahesh\_g\_o](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@mahesh\_g\_o](https://forum.ansible.com/u/mahesh_g_o)\
**Post date:** [March 17, 2020, 5:00am UTC](https://forum.ansible.com/t/passing-variable-in-another-playbook/32478/1 "2020-03-17T05:00:30Z")

</div>

i have created the list using set\_fact and i want use this list in another playbook.  
i have stored the value in the ouput.  
how do i use it in another playbook??

tasks:

- name: Initialize an empty list for our strings

set\_fact:

test:

- name: second

set\_fact:

my\_list: “test1”

- name: append

set\_fact:

test: “{{ test + [my\_list] }}”

register: output

- debug: msg=“{{ output }}”

---

<div class="post-metadata">

**Author:** ![mahesh\_g\_o](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@mahesh\_g\_o](https://forum.ansible.com/u/mahesh_g_o)\
**Post date:** [March 17, 2020, 6:11am UTC](https://forum.ansible.com/t/passing-variable-in-another-playbook/32478/2 "2020-03-17T06:11:38Z")

</div>

newbie to ansible

---

<div class="post-metadata">

**Author:** ![Gomathi\_Selvi\_Sriniv](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/gomathi_selvi_sriniv/32/11149_2.png) [@Gomathi\_Selvi\_Sriniv](https://forum.ansible.com/u/Gomathi_Selvi_Sriniv)\
**Post date:** [March 17, 2020, 1:32pm UTC](https://forum.ansible.com/t/passing-variable-in-another-playbook/32478/3 "2020-03-17T13:32:01Z")

</div>

You can use a global playbook, where you can import the 2 playbooks across which you want to use the variable. Something like this

- import\_playbook: play1.yaml
- import\_playbook:play2.yaml.

play2 can use the variables from play1 and vice versa. You can run the global playbook.
