# Passing variables between playbooks on Workflow Templates

**URL:** <https://forum.ansible.com/t/passing-variables-between-playbooks-on-workflow-templates/26560>\
**Category:** AWX Project\
**Created:** [January 24, 2018, 9:14pm UTC](https://forum.ansible.com/t/passing-variables-between-playbooks-on-workflow-templates/26560 "2018-01-24T21:14:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pablo\_Ilarragorri](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@Pablo\_Ilarragorri](https://forum.ansible.com/u/Pablo_Ilarragorri)\
**Post date:** [January 24, 2018, 9:14pm UTC](https://forum.ansible.com/t/passing-variables-between-playbooks-on-workflow-templates/26560/1 "2018-01-24T21:14:12Z")

</div>

Hi,

I’m creating a Workflow template that include several playbooks, what I’m trying to do is to generate a variable from one of the playbooks (let’s say capture the output of a task) and pass it or make it available for the ollowing playbook to be used.

I’ve been looking for some examples on this online and the only one I could find mentioned the use of set\_status , but I couldn’t make it work for me. Is this doable? Maybe I’m approaching the issue the wrong way?

Thanks!

---

<div class="post-metadata">

**Author:** ![Graham\_Mainwaring](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Graham\_Mainwaring](https://forum.ansible.com/u/Graham_Mainwaring)\
**Post date:** [January 25, 2018, 2:40am UTC](https://forum.ansible.com/t/passing-variables-between-playbooks-on-workflow-templates/26560/2 "2018-01-25T02:40:28Z")

</div>

Pablo,

It’s set\_stats, not set\_status.

Thanks,

-Graham

---

<div class="post-metadata">

**Author:** ![Pablo\_Ilarragorri](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@Pablo\_Ilarragorri](https://forum.ansible.com/u/Pablo_Ilarragorri)\
**Post date:** [January 25, 2018, 10:39am UTC](https://forum.ansible.com/t/passing-variables-between-playbooks-on-workflow-templates/26560/3 "2018-01-25T10:39:38Z")

</div>

Graham,

Yes, it was a typo. Still, I’m not able to pass variables between playbooks. Have you done that yourself? Is it the right approach?

---

<div class="post-metadata">

**Author:** ![mabashia](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@mabashia](https://forum.ansible.com/u/mabashia)\
**Post date:** [January 25, 2018, 1:07pm UTC](https://forum.ansible.com/t/passing-variables-between-playbooks-on-workflow-templates/26560/4 "2018-01-25T13:07:24Z")

</div>

Hey Pablo,

I think you’re taking the right approach. set\_stats (referred to as artifacts in awx) allow workflow jobs to inherit variables from a parent job. There’s some documentation about the hierarchy [here](https://docs.ansible.com/ansible-tower/latest/html/userguide/workflows.html#extra-variables) which I hope is helpful.

Best,  
Mike

---

<div class="post-metadata">

**Author:** ![Vinod\_Patil](https://avatars.discourse-cdn.com/v4/letter/v/ce73a5/32.png) [@Vinod\_Patil](https://forum.ansible.com/u/Vinod_Patil)\
**Post date:** [February 16, 2018, 4:56am UTC](https://forum.ansible.com/t/passing-variables-between-playbooks-on-workflow-templates/26560/5 "2018-02-16T04:56:46Z")

</div>

Hi Pablo,

Has it worked ? I am trying that same example from last day but not working. Is that a bug? Has it worked for anybody?

Regards,  
Vinod

---

<div class="post-metadata">

**Author:** ![Danny\_Lai](https://avatars.discourse-cdn.com/v4/letter/d/35a633/32.png) [@Danny\_Lai](https://forum.ansible.com/u/Danny_Lai)\
**Post date:** [December 19, 2018, 10:41pm UTC](https://forum.ansible.com/t/passing-variables-between-playbooks-on-workflow-templates/26560/6 "2018-12-19T22:41:05Z")

</div>

Hi there -

FWIW, i did get this to work in my AWX Instance. Here are my playbooks:

Playbook 1

---

<div class="post-metadata">

**Author:** ![Kosala\_Atapattu1](https://avatars.discourse-cdn.com/v4/letter/k/7feea3/32.png) [@Kosala\_Atapattu1](https://forum.ansible.com/u/Kosala_Atapattu1)\
**Post date:** [December 20, 2018, 1:02am UTC](https://forum.ansible.com/t/passing-variables-between-playbooks-on-workflow-templates/26560/7 "2018-12-20T01:02:33Z")

</div>

Not sure set\_stats works the way you’re trying to use it. Have a look at set\_facts instead. I’ve used set\_facts with delegated to and local actions, without any problems. Haven’t really tried caching facts in AWX, but that should work too… meaning the variable will be preserved across job runs.

Cheers,  
Ko

---

<div class="post-metadata">

**Author:** ![Pablo\_Ilarragorri](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@Pablo\_Ilarragorri](https://forum.ansible.com/u/Pablo_Ilarragorri)\
**Post date:** [December 21, 2018, 4:42pm UTC](https://forum.ansible.com/t/passing-variables-between-playbooks-on-workflow-templates/26560/8 "2018-12-21T16:42:44Z")

</div>

Hi Graham

Yeah, it was a typo on my part.

But that wasn’t the bottom line problem, it was a mix of not setting gather\_facts and the hash\_behaviour settings of the ansible.cfg (which by default was on replace).
