# Ansible Docker Module and JSON

**URL:** <https://forum.ansible.com/t/ansible-docker-module-and-json/21233>\
**Category:** Ansible Project\
**Created:** [April 21, 2016, 4:02pm UTC](https://forum.ansible.com/t/ansible-docker-module-and-json/21233 "2016-04-21T16:02:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Albert](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Mike\_Albert](https://forum.ansible.com/u/Mike_Albert)\
**Post date:** [April 21, 2016, 4:02pm UTC](https://forum.ansible.com/t/ansible-docker-module-and-json/21233/1 "2016-04-21T16:02:25Z")

</div>

Hi,

I’m running into an issue with how the Ansible Docker module handles JSON data passed in as an environment variable. I’m currently running Ansible 2.0.2.0. My docker env variable is defined like this:

`dockerhub_auth: {"https://index.docker.io/v1/": {"auth": "foo", "email": "bar" }}`

The above var is then referenced like this  
`

- name: Start ecs-agent container  
docker:  
name: ecs-agent  
image: amazon/amazon-ecs-agent:v{{ ecs\_agent\_version }}  
state: reloaded # asserts containers are running and restarts any that have any images or configs out of date.  
pull: always # the registry will be checked for a newer version of the image’ each time the task executes  
detach: true  
restart\_policy: on-failure  
restart\_policy\_retry: 10  
net: bridge  
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/log/ecs/:/log # Z mount option for SELinux available in Ansible 2.1
- /var/lib/ecs/data:/data
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /var/run/docker/execdriver/native:/var/lib/docker/execdriver/native:ro  
ports:
- 127.0.0.1:51678:51678  
expose:
- 51678  
env:  
ECS\_LOGFILE: /log/ecs-agent.log  
ECS\_LOGLEVEL: info  
ECS\_DATADIR: /data  
ECS\_CLUSTER: “{{ ecs\_cluster }}”  
ECS\_ENGINE\_AUTH\_TYPE: dockercfg  
ECS\_ENGINE\_AUTH\_DATA: “{{ dockerhub\_auth | to\_json }}”

`

When I do a debug on “{{ dockerhub\_auth | to\_json }|” the data shows as properly formatted json. However, when I run the above task, the variable seems to be passed in with single quotes. See below:

`[root@localhost ~]# docker inspect 3ae5048a8b03|grep ECS_ENGINE_AUTH_DATA "ECS_ENGINE_AUTH_DATA={'url': {'email': 'bar', 'auth': 'foo'}}",`

Am I encountering a limitation in the Docker module or is there another way I can pass JSON data through to the container? I saw that the env\_file flag for Docker is coming in Ansible 2.1, so that’s a possible solution, but I encountered other Docker errors when trying to use the ansible 2.1 devel branch.

Thanks in advance for the help!
