Yaniv Hakim
Yaniv Hakim

Reputation: 87

Ansible support for docker module

Deploying Ansible Docker with Redis Sentinel container drop an error on limited environment Supported parameters.

I wrote environment to the Redis Sentinel container I get error message. Does this module should support those envoirments variables?

versions:
- ansible 2.4.2.0
- Docker version 1.13.1, build 07f3374/1.13.1

Here is the configuration:

   - name: run sentinel one container (sentinel1)
     docker:
       name: sentonel1
       image: docker-registry.xxxx.xxxx.com/redis/sentinel:v1.0.1
       environment:
         - MASTER_ADDR=${HOST_PUBLIC_IP}
         - MASTER_PORT=6379
         - SENTINEL_ANNOUNCE_IP=${HOST_PUBLIC_IP}
         - SENTINEL_ANNOUNCE_PORT=26379
         - SENTINEL_QUORUM=2
         - SENTINEL_FAILOVER=5000
         - SENTINEL_DOWN_AFTER=18000
       ports:
         - "26379:26379"

Here is the error I get:

TASK [run sentinel two container (sentinel2)] ****************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (docker_container) module: environment Supported parameters include: api_version,auto_remove,blkio_weight,cacert_path,capabilities,cert_path,cleanup,command,cpu_period,cpu_quota,cpu_shares,cpuset_cpus,cpuset_mems,debug,detach,devices,dns_opts,dns_search_domains,dns_servers,docker_host,entrypoint,env,env_file,etc_hosts,exposed_ports,filter_logger,force_kill,groups,hostname,ignore_image,image,interactive,ipc_mode,keep_volumes,kernel_memory,key_path,kill_signal,labels,links,log_driver,log_options,mac_address,memory,memory_reservation,memory_swap,memory_swappiness,name,network_mode,networks,oom_killer,oom_score_adj,paused,pid_mode,privileged,published_ports,pull,purge_networks,read_only,recreate,restart,restart_policy,restart_retries,security_opts,shm_size,ssl_version,state,stop_signal,stop_timeout,sysctls,timeout,tls,tls_hostname,tls_verify,tmpfs,trust_image_content,tty,ulimits,user,uts,volume_driver,volumes,volumes_from,working_dir"}
    to retry, use: --limit @/ansible/ansible.retry

PLAY RECAP ***************************************************************************************************************************************************
localhost                  : ok=28   changed=2    unreachable=0    failed=1   

Upvotes: 0

Views: 852

Answers (1)

sklemmer
sklemmer

Reputation: 71

The Ansible Docker Module is deprecated since ansible 2.2 you should use docker_container instead.

Replace the environment key with env and it should work but note that variables with ${} are not supported you should use {{ ansible_env.MY_VARIABLE }} to access any environment variable on the system.

see https://docs.ansible.com/ansible/2.4/docker_container_module.html for your ansible version

Upvotes: 2

Related Questions