# Using docker\_containers return value in a different role

**URL:** <https://forum.ansible.com/t/using-docker-containers-return-value-in-a-different-role/14850>\
**Category:** Ansible Project\
**Created:** [March 25, 2014, 9:58am UTC](https://forum.ansible.com/t/using-docker-containers-return-value-in-a-different-role/14850 "2014-03-25T09:58:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mitchellgayner](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@mitchellgayner](https://forum.ansible.com/u/mitchellgayner)\
**Post date:** [March 25, 2014, 9:58am UTC](https://forum.ansible.com/t/using-docker-containers-return-value-in-a-different-role/14850/1 "2014-03-25T09:58:06Z")

</div>

Hi All,

I am running a role “run\_docker\_containers” which creates a series of docker containers using the docker module.

`

- name: Run containers  
docker: state=present name={{ item }} ports=80 image=myimage command=‘blah’  
with\_sequence: start=1 end=‘5’ format=mycontainer\_%d  
`

The containers are created OK, and I can display the output of the module by using a debug statement (from the documentation examples) if I put the debug statement inside the role “run\_docker\_containers”.

`

- debug: msg={{inventory\_hostname}}:{{item}}  
with\_items: docker\_containers  
`

I am currently trying to pass the information returned by the docker module to a different role. The other role is part of setting up load balancing, so I am trying to get IP and port settings of the containers.

I have tried using the debug statement above inside “load\_balance” but could not get it to display any information. Here is what the output looks like inside the other role:

`  
[mytest.host] =\> (item=docker\_containers) =\> {

“item”: “docker\_containers”,

“msg”: “mytest.host:docker\_containers”

}  
`

Here is what the list of roles looks like:

`

- hosts: testhosts  
roles:
- run\_docker\_containers
- load\_balance  
`

Any ideas how I can pass the information between roles?

Thanks

Mitch

---

<div class="post-metadata">

**Author:** ![Paul\_Durivage](https://avatars.discourse-cdn.com/v4/letter/p/94ad74/32.png) [@Paul\_Durivage](https://forum.ansible.com/u/Paul_Durivage)\
**Post date:** [March 26, 2014, 3:16pm UTC](https://forum.ansible.com/t/using-docker-containers-return-value-in-a-different-role/14850/2 "2014-03-26T15:16:35Z")

</div>

I think what you want to use is the set\_fact module to set variables from your provisioning roles that you later recall when provisioning your LBs.

[http://docs.ansible.com/set\_fact\_module.html](http://docs.ansible.com/set_fact_module.html)
