passing variable in another playbook

12 views
Skip to first unread message

mahesh g o

unread,
Mar 17, 2020, 1:00:30 AM3/17/20
to Ansible Project
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 }}"


mahesh g o

unread,
Mar 17, 2020, 2:11:38 AM3/17/20
to Ansible Project
newbie to ansible

Gomathi Selvi Srinivasan

unread,
Mar 17, 2020, 9:32:01 AM3/17/20
to Ansible Project
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.
Reply all
Reply to author
Forward
0 new messages