Ansible Docker Module and JSON

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!