# Ansible Docker module not picking up variables

**URL:** <https://forum.ansible.com/t/ansible-docker-module-not-picking-up-variables/18974>\
**Category:** Ansible Developer\
**Created:** [August 8, 2015, 3:46pm UTC](https://forum.ansible.com/t/ansible-docker-module-not-picking-up-variables/18974 "2015-08-08T15:46:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kamesh\_Sampath](https://avatars.discourse-cdn.com/v4/letter/k/f17d59/32.png) [@Kamesh\_Sampath](https://forum.ansible.com/u/Kamesh_Sampath)\
**Post date:** [August 8, 2015, 3:46pm UTC](https://forum.ansible.com/t/ansible-docker-module-not-picking-up-variables/18974/1 "2015-08-08T15:46:50Z")

</div>

I am a newbie with ansible, I am trying to spin up a docker container with the following command

`

- name: Swarm node is running  
docker:  
docker\_api\_version: 1.18  
name: swarm-node  
image: swarm  
command: join --addr={{ ip }}:2375 token://{{ swarm\_cluster\_token }}  
state: restarted  
when: not swarm\_master is defined  
register: docker\_cmd  
tags: [swarm]  
`

I see that the variables are not expand for {{ ip }} and {{ swarm\_cluster\_token }}, when i tried debug the variables i see they are available inside the playbook.

I tried doing the following options:

`'join --addr="{{ ip }}":2375 token://"{{ swarm_cluster_token }}"'`

I am using the ansible 1.9.2 , docker v1.7.1, docker-py: 1.3.1 but pinned the version of the docker api to 1.18 to circumvent the issue posted [https://github.com/ansible/ansible-modules-core/issues/1707](https://github.com/ansible/ansible-modules-core/issues/1707)

Still with the same result, any thoughts why the variables are not getting expanded inside the docker command ?

Cheers,  
Kamesh

---

<div class="post-metadata">

**Author:** ![Kamesh\_Sampath](https://avatars.discourse-cdn.com/v4/letter/k/f17d59/32.png) [@Kamesh\_Sampath](https://forum.ansible.com/u/Kamesh_Sampath)\
**Post date:** [August 8, 2015, 8:03pm UTC](https://forum.ansible.com/t/ansible-docker-module-not-picking-up-variables/18974/2 "2015-08-08T20:03:42Z")

</div>

Sorry for this issue, after debugging i understood for docker-swarm the ip is just used for addressing and its not listed with docker ps , when I inspected the node I see the IP getting passed correctly.
