Using docker_containers return value in a different role

250 views
Skip to first unread message

mitchel...@gmail.com

unread,
Mar 25, 2014, 5:58:06 AM3/25/14
to ansible...@googlegroups.com
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


Paul Durivage

unread,
Mar 26, 2014, 11:16:35 AM3/26/14
to ansible...@googlegroups.com
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.




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6b7417ab-9a90-4aab-8075-3352cc71e7be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages