Passing variables between playbooks on Workflow Templates

4,823 views
Skip to first unread message

Pablo Ilarragorri

unread,
Jan 24, 2018, 4:14:13 PM1/24/18
to AWX Project
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!

Graham Mainwaring

unread,
Jan 24, 2018, 9:40:31 PM1/24/18
to Pablo Ilarragorri, AWX Project
Pablo,

It's set_stats, not set_status.

Thanks,

-Graham



--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project+unsubscribe@googlegroups.com.
To post to this group, send email to awx-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/86f9a5c3-2fe1-449f-948e-2f8bb1ab8651%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pablo Ilarragorri

unread,
Jan 25, 2018, 5:39:38 AM1/25/18
to AWX Project
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?


El miércoles, 24 de enero de 2018, 23:40:31 (UTC-3), Graham Mainwaring escribió:
Pablo,

It's set_stats, not set_status.

Thanks,

-Graham


On Jan 24, 2018 4:14 PM, "Pablo Ilarragorri" <pilarr...@gmail.com> wrote:
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!

--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project...@googlegroups.com.

Michael Abashian

unread,
Jan 25, 2018, 8:07:24 AM1/25/18
to AWX Project
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 which I hope is helpful.

Best,
Mike

Vinod Patil

unread,
Feb 15, 2018, 11:56:46 PM2/15/18
to AWX Project
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

Danny Lai

unread,
Dec 19, 2018, 5:41:06 PM12/19/18
to AWX Project
Hi there - 

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

Playbook 1
~~~~~~~
---
- hosts: localhost
gather_facts: yes

vars:
var1: value1
var2: value2

tasks:
- name: Do nothing, just that ansible ran, and ping
ping:

- name: Debug user_gecos
debug:
var: ansible_facts.user_gecos

- name: Set some data to pass down to the 2nd AWS Job template
set_stats:
data:
my_personal_variable: "{{ ansible_facts.user_gecos }}-blah"

~~~~~~~

Playbook 2
~~~~~~~
---
- hosts: localhost
gather_facts: yes

vars:
var1: value1
var2: value2

tasks:
- name: Do nothing, just that ansible ran, and ping
ping:

- name: Debug my_personal_variable
debug:
var: my_personal_variable

~~~~~~~

and the var "my_personal_variable" did get passed from play1, to play2, within AWX's Workflow template.

Thanks 

Kosala Atapattu

unread,
Dec 19, 2018, 8:02:53 PM12/19/18
to Danny Lai, AWX Project
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

--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project...@googlegroups.com.
To post to this group, send email to awx-p...@googlegroups.com.

Pablo Ilarragorri

unread,
Dec 21, 2018, 11:43:17 AM12/21/18
to Graham Mainwaring, AWX Project
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).



El mié., ene. 24, 2018 11:40 PM, Graham Mainwaring <gmai...@redhat.com> escribió:
Pablo,

It's set_stats, not set_status.

Thanks,

-Graham



On Jan 24, 2018 4:14 PM, "Pablo Ilarragorri" <pilarr...@gmail.com> wrote:
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!

--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages