Commas in Docker env option for values of environment variables?

1,683 views
Skip to first unread message

James Webster

unread,
Feb 18, 2015, 1:24:20 AM2/18/15
to ansible...@googlegroups.com
I'm using Consul in combination with a service registration framework (progrium/registrator Docker image) to play around with distributed service discovery. Plus Ansible to start up my Docker containers, etc. However I'm running into a limitation with the 'env' option of the Docker module. The registration framework can allow me to set multiple 'tags' for a service, but requires them to be expressed as a single environment variable with comma-separate values, eg.

env="SERVICE_80_TAGS=master,http"

of course, this falls over because the Docker module is expecting multiple environment variables to be comma separated;

env="SOME_ENV_A=valueA,SOME_ENV_B=valueB"

Can I get this to work with escaping, or would it be possible to support an alternative separator in env?

env="SERVICE_80_TAGS=master,http:SOME_ENV_A=valueA:SOME_ENV_B=valueB"

ppo...@greenlancer.com

unread,
Aug 24, 2016, 10:48:26 AM8/24/16
to Ansible Project
I'm affected by this as well using the new docker_container ansible module.

ppo...@greenlancer.com

unread,
Aug 24, 2016, 10:54:40 AM8/24/16
to Ansible Project
James,

Just in case you're still stuck on this for whatever reason, we figured out how to make this work with the docker_container module. Ansible doesn't have this documented.

- name:  Start Webhook
  docker_container
:
    image
: "company/webhook:{{microservice_webhook_tag}}"
    name
: "webhook"
    state
: started
    detach
: true
    restart_policy
: on-failure
    env
:
      CONSUL_LOCATION
: "{{ (ansible_docker0.ipv4|default(ansible_default_ipv4)).address }}:8500"
      LOG_LEVEL
: "{{microservice_webhook_env_loglevel}}"
      SERVICE_NAME
: "webhook"
      SERVICE_TAGS
:
       
- "{{microservice_webhook_tag}}"
       
- "{{microservice_some_other_tag}}"



Reply all
Reply to author
Forward
0 new messages