{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3864","repository_url":"https://api.github.com/repos/ansible/ansible-modules-core","labels_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3864/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3864/comments","events_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3864/events","html_url":"https://github.com/ansible/ansible-modules-core/issues/3864","id":158480659,"number":3864,"title":"docker_container: When using restart_policy, Ansible restarts running container","user":{"login":"dcbishop","id":284268,"avatar_url":"https://avatars.githubusercontent.com/u/284268?v=3","gravatar_id":"","url":"https://api.github.com/users/dcbishop","html_url":"https://github.com/dcbishop","followers_url":"https://api.github.com/users/dcbishop/followers","following_url":"https://api.github.com/users/dcbishop/following{/other_user}","gists_url":"https://api.github.com/users/dcbishop/gists{/gist_id}","starred_url":"https://api.github.com/users/dcbishop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcbishop/subscriptions","organizations_url":"https://api.github.com/users/dcbishop/orgs","repos_url":"https://api.github.com/users/dcbishop/repos","events_url":"https://api.github.com/users/dcbishop/events{/privacy}","received_events_url":"https://api.github.com/users/dcbishop/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-04T01:31:12Z","updated_at":"2016-06-04T01:40:38Z","closed_at":"2016-06-04T01:40:38Z","body":"##### ISSUE TYPE\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\ndocker_container\r\n\r\n##### ANSIBLE VERSION\r\n```\r\nansible 2.1.0.0\r\n  config file = /etc/ansible/ansible.cfg\r\n  configured module search path = Default w/o overrides\r\n```\r\n\r\n##### CONFIGURATION\r\nNo changes.\r\n\r\n##### OS / ENVIRONMENT\r\nHost: Arch\r\nManaged: Ubuntu 16.04\r\n\r\n##### SUMMARY\r\nWhen the restart_policy is used, the container restarts each Ansible run.\r\n\r\nThis happens with both `restart_policy=on-failure` and `restart_policy=always`.\r\n\r\nEven with `restart_policy=always`, that shouldn't happen as its a [setting telling docker how to manage the container](https://docs.docker.com/engine/reference/run/#restart-policies-restart), not telling Ansible to restart the container each run (if that was desired it would probably be in `state=restart`).\r\n\r\nSetting `restart=no` doesn't help either.\r\n\r\nSide note: It's a separate bug, the `restart_policy=unless-stopped` and `restart_policy=no` options are missing in `docker_container`, but present in `docker`.\r\n\r\n\r\n##### STEPS TO REPRODUCE\r\n```\r\n---\r\n- name: Jupyter notebook container\r\n  docker_container:\r\n    image: jupyter/all-spark-notebook\r\n    name: notebook\r\n    ports: \"8888:8888\"\r\n    volumes: \"{{data_location}}:/home/jovyan/work:rw\"\r\n    state: started\r\n    restart_policy: on-failure\r\n    restart_retries: 5\r\n    restart: no\r\n    network_mode: \"host\"\r\n  tags: jupyter\r\n```\r\n\r\n##### EXPECTED RESULTS\r\nDockers RestartPolicy should be set, but container shouldn't actually be restarted.\r\n\r\n##### ACTUAL RESULTS\r\nAnsible restarts the docker container every run.\r\nDockers restart policy is correctly set though.\r\n\r\n```\r\nTASK [docker-jupyter : Jupyter notebook container] *****************************\r\nchanged: [hextor]\r\n```\r\n\r\n\r\n\r\nMore detail.\r\n```\r\nTASK [docker-jupyter : Jupyter notebook container] *****************************\r\ntask path: /home/hegemon/programming/ansible/roles/docker-jupyter/tasks/main.yml:3\r\n<hextor> ESTABLISH SSH CONNECTION FOR USER: None\r\n<hextor> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthenticat\r\nion=no -o ConnectTimeout=10 -o ControlPath=/home/hegemon/.ansible/cp/ansible-ssh-%h-%p-%r hextor '/bin/sh -c '\"'\"'( umask 77 && mkdir -p \"` echo $HOME/.ansible/tmp/ansible-tmp-1465003680.83-100689233037855 `\" \r\n&& echo ansible-tmp-1465003680.83-100689233037855=\"` echo $HOME/.ansible/tmp/ansible-tmp-1465003680.83-100689233037855 `\" ) && sleep 0'\"'\"''\r\n<hextor> PUT /tmp/tmpaNXfnK TO /home/hegemon/.ansible/tmp/ansible-tmp-1465003680.83-100689233037855/docker_container\r\n<hextor> SSH: EXEC sftp -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthe\r\nntication=no -o ConnectTimeout=10 -o ControlPath=/home/hegemon/.ansible/cp/ansible-ssh-%h-%p-%r '[hextor]'\r\n<hextor> ESTABLISH SSH CONNECTION FOR USER: None\r\n<hextor> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthenticat\r\nion=no -o ConnectTimeout=10 -o ControlPath=/home/hegemon/.ansible/cp/ansible-ssh-%h-%p-%r -tt hextor '/bin/sh -c '\"'\"'sudo -H -S -n -u root /bin/sh -c '\"'\"'\"'\"'\"'\"'\"'\"'echo BECOME-SUCCESS-bvvrebckovfdmiopwszdr\r\nfpftnrsibyu; LANG=en_AU.UTF-8 LC_ALL=en_AU.UTF-8 LC_MESSAGES=en_AU.UTF-8 /usr/bin/python2 /home/hegemon/.ansible/tmp/ansible-tmp-1465003680.83-100689233037855/docker_container; rm -rf \"/home/hegemon/.ansible/t\r\nmp/ansible-tmp-1465003680.83-100689233037855/\" > /dev/null 2>&1'\"'\"'\"'\"'\"'\"'\"'\"' && sleep 0'\"'\"''\r\nchanged: [hextor] => {\"ansbile_facts\": {\"ansible_docker_container\": {\"AppArmorProfile\": \"\", \"Args\": [\"--\", \"start-notebook.sh\"], \"Config\": {\"AttachStderr\": false, \"AttachStdin\": false, \"AttachStdout\": false, \"\r\nCmd\": [\"start-notebook.sh\"], \"Domainname\": \"\", \"Entrypoint\": [\"tini\", \"--\"], \"Env\": [\"PATH=/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\", \"DEBIAN_FRONTEND=noninteractive\", \"CONDA\r\n_DIR=/opt/conda\", \"SHELL=/bin/bash\", \"NB_USER=jovyan\", \"NB_UID=1000\", \"HOME=/home/jovyan\", \"LC_ALL=en_US.UTF-8\", \"LANG=en_US.UTF-8\", \"LANGUAGE=en_US.UTF-8\", \"APACHE_SPARK_VERSION=1.6.1\", \"SPARK_HOME=/usr/local\r\n/spark\", \"PYTHONPATH=/usr/local/spark/python:/usr/local/spark/python/lib/py4j-0.9-src.zip\", \"MESOS_NATIVE_LIBRARY=/usr/local/lib/libmesos.so\", \"SPARK_OPTS=--driver-java-options=-Xms1024M --driver-java-options=\r\n-Xmx4096M --driver-java-options=-Dlog4j.logLevel=info\", \"R_LIBS_USER=/usr/local/spark/R/lib\"], \"ExposedPorts\": {\"8888/tcp\": {}}, \"Hostname\": \"hextor\", \"Image\": \"jupyter/all-spark-notebook\", \"Labels\": {}, \"OnBu\r\nild\": null, \"OpenStdin\": false, \"StdinOnce\": false, \"Tty\": false, \"User\": \"jovyan\", \"Volumes\": {\"/mnt/storage3/data/jupyter-all-spark\": {}}, \"WorkingDir\": \"/home/jovyan/work\"}, \"Created\": \"2016-06-04T01:28:05.\r\n309498256Z\", \"Driver\": \"btrfs\", \"ExecIDs\": null, \"GraphDriver\": {\"Data\": null, \"Name\": \"btrfs\"}, \"HostConfig\": {\"AutoRemove\": false, \"Binds\": [\"/mnt/storage3/data/jupyter-all-spark:/home/jovyan/work:rw\"], \"Blk\r\nioBps\": 0, \"BlkioDeviceReadBps\": null, \"BlkioDeviceReadIOps\": null, \"BlkioDeviceWriteBps\": null, \"BlkioDeviceWriteIOps\": null, \"BlkioIOps\": 0, \"BlkioWeight\": 0, \"BlkioWeightDevice\": null, \"CapAdd\": null, \"CapD\r\nrop\": null, \"Cgroup\": \"\", \"CgroupParent\": \"\", \"ConsoleSize\": [0, 0], \"ContainerIDFile\": \"\", \"CpuCount\": 0, \"CpuPercent\": 0, \"CpuPeriod\": 0, \"CpuQuota\": 0, \"CpuShares\": 0, \"CpusetCpus\": \"\", \"CpusetMems\": \"\", \"D\r\nevices\": null, \"DiskQuota\": 0, \"Dns\": null, \"DnsOptions\": null, \"DnsSearch\": null, \"ExtraHosts\": null, \"GroupAdd\": null, \"IpcMode\": \"\", \"Isolation\": \"\", \"KernelMemory\": 0, \"Links\": null, \"LogConfig\": {\"Config\"\r\n: {}, \"Type\": \"json-file\"}, \"Memory\": 0, \"MemoryReservation\": 0, \"MemorySwap\": 0, \"MemorySwappiness\": -1, \"NetworkMode\": \"host\", \"OomKillDisable\": false, \"OomScoreAdj\": 0, \"PidMode\": \"\", \"PidsLimit\": 0, \"PortB\r\nindings\": {\"8888/tcp\": [{\"HostIp\": \"0.0.0.0\", \"HostPort\": \"8888\"}]}, \"Privileged\": false, \"PublishAllPorts\": false, \"ReadonlyRootfs\": false, \"RestartPolicy\": {\"MaximumRetryCount\": 5, \"Name\": \"on-failure\"}, \"Sa\r\nndboxSize\": 0, \"SecurityOpt\": null, \"ShmSize\": 67108864, \"StorageOpt\": null, \"UTSMode\": \"\", \"Ulimits\": null, \"UsernsMode\": \"\", \"VolumeDriver\": \"\", \"VolumesFrom\": null}, \"HostnamePath\": \"/var/lib/docker/contain\r\ners/8a98bb4ac722d46f7509c8ac72223572c977f3bd9e133361c28bbbaeaf3f5c78/hostname\", \"HostsPath\": \"/var/lib/docker/containers/8a98bb4ac722d46f7509c8ac72223572c977f3bd9e133361c28bbbaeaf3f5c78/hosts\", \"Id\": \"8a98bb4a\r\nc722d46f7509c8ac72223572c977f3bd9e133361c28bbbaeaf3f5c78\", \"Image\": \"sha256:f27c18eb757025cde813b65ba845be58b6cca0ed24339bbec5ad1ba574c4a3f9\", \"LogPath\": \"/var/lib/docker/containers/8a98bb4ac722d46f7509c8ac722\r\n23572c977f3bd9e133361c28bbbaeaf3f5c78/8a98bb4ac722d46f7509c8ac72223572c977f3bd9e133361c28bbbaeaf3f5c78-json.log\", \"MountLabel\": \"\", \"Mounts\": [{\"Destination\": \"/home/jovyan/work\", \"Mode\": \"rw\", \"Propagation\": \r\n\"rprivate\", \"RW\": true, \"Source\": \"/mnt/storage3/data/jupyter-all-spark\"}, {\"Destination\": \"/mnt/storage3/data/jupyter-all-spark\", \"Driver\": \"local\", \"Mode\": \"\", \"Name\": \"0ae4dc63b4566e675990f8d0ed763611e10687\r\nc914826f4ff3e3d6b23a874456\", \"Propagation\": \"\", \"RW\": true, \"Source\": \"/var/lib/docker/volumes/0ae4dc63b4566e675990f8d0ed763611e10687c914826f4ff3e3d6b23a874456/_data\"}], \"Name\": \"/notebook\", \"NetworkSettings\":\r\n {\"Bridge\": \"\", \"EndpointID\": \"\", \"Gateway\": \"\", \"GlobalIPv6Address\": \"\", \"GlobalIPv6PrefixLen\": 0, \"HairpinMode\": false, \"IPAddress\": \"\", \"IPPrefixLen\": 0, \"IPv6Gateway\": \"\", \"LinkLocalIPv6Address\": \"\", \"Link\r\nLocalIPv6PrefixLen\": 0, \"MacAddress\": \"\", \"Networks\": {\"host\": {\"Aliases\": null, \"EndpointID\": \"8234d6355e6786f32231a7918a870dfeda73dd1cf5d0df0db0fe392fbd1773e1\", \"Gateway\": \"\", \"GlobalIPv6Address\": \"\", \"Globa\r\nlIPv6PrefixLen\": 0, \"IPAMConfig\": null, \"IPAddress\": \"\", \"IPPrefixLen\": 0, \"IPv6Gateway\": \"\", \"Links\": null, \"MacAddress\": \"\", \"NetworkID\": \"1746a0b39f24f90c291afb013f1770b50e15195946f261937d93d6774ff9dec8\"}},\r\n \"Ports\": {}, \"SandboxID\": \"1f0148cb9c044be2522a8e5a9f2c5694ed8087d6446b1cf7361b222c1cbcfff3\", \"SandboxKey\": \"/var/run/docker/netns/default\", \"SecondaryIPAddresses\": null, \"SecondaryIPv6Addresses\": null}, \"Pat\r\nh\": \"tini\", \"ProcessLabel\": \"\", \"ResolvConfPath\": \"/var/lib/docker/containers/8a98bb4ac722d46f7509c8ac72223572c977f3bd9e133361c28bbbaeaf3f5c78/resolv.conf\", \"RestartCount\": 0, \"State\": {\"Dead\": false, \"Error\":\r\n \"\", \"ExitCode\": 0, \"FinishedAt\": \"0001-01-01T00:00:00Z\", \"OOMKilled\": false, \"Paused\": false, \"Pid\": 17074, \"Restarting\": false, \"Running\": true, \"StartedAt\": \"2016-06-04T01:28:08.519949445Z\", \"Status\": \"runn\r\ning\"}}}, \"changed\": true, \"invocation\": {\"module_args\": {\"api_version\": null, \"blkio_weight\": null, \"cacert_path\": null, \"capabilities\": null, \"cert_path\": null, \"command\": null, \"cpu_period\": null, \"cpu_quota\": null, \"cpu_shares\": null, \"cpuset_cpus\": null, \"cpuset_mems\": null, \"debug\": false, \"detach\": true, \"devices\": null, \"dns_opts\": null, \"dns_search_domains\": null, \"dns_servers\": null, \"docker_host\": null, \"\r\nentrypoint\": null, \"env\": null, \"etc_hosts\": null, \"exposed_ports\": null, \"filter_logger\": false, \"force_kill\": false, \"groups\": null, \"hostname\": null, \"image\": \"jupyter/all-spark-notebook\", \"interactive\": fa\r\nlse, \"ipc_mode\": null, \"keep_volumes\": true, \"kernel_memory\": null, \"key_path\": null, \"kill_signal\": null, \"labels\": null, \"links\": null, \"log_driver\": \"json-file\", \"log_options\": null, \"mac_address\": null, \"m\r\nemory\": \"0\", \"memory_reservation\": null, \"memory_swap\": null, \"memory_swappiness\": null, \"name\": \"notebook\", \"network_mode\": \"host\", \"networks\": null, \"oom_killer\": null, \"paused\": false, \"pid_mode\": null, \"po\r\nrts\": \"8888:8888\", \"privileged\": false, \"published_ports\": [\"8888:8888\"], \"pull\": false, \"read_only\": false, \"recreate\": false, \"restart\": false, \"restart_policy\": \"on-failure\", \"restart_retries\": 5, \"security\r\n_opts\": null, \"shm_size\": null, \"ssl_version\": null, \"state\": \"started\", \"stop_signal\": null, \"stop_timeout\": null, \"timeout\": null, \"tls\": null, \"tls_hostname\": null, \"tls_verify\": null, \"trust_image_content\"\r\n: false, \"tty\": false, \"ulimits\": null, \"user\": null, \"uts\": null, \"volume_driver\": null, \"volumes\": [\"/mnt/storage3/data/jupyter-all-spark:/home/jovyan/work:rw\"], \"volumes_from\": null}, \"module_name\": \"docker\r\n_container\"}}\r\n```"},"comment":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/comments/223728907","html_url":"https://github.com/ansible/ansible-modules-core/issues/3864#issuecomment-223728907","issue_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3864","id":223728907,"user":{"login":"sivel","id":39340,"avatar_url":"https://avatars.githubusercontent.com/u/39340?v=3","gravatar_id":"","url":"https://api.github.com/users/sivel","html_url":"https://github.com/sivel","followers_url":"https://api.github.com/users/sivel/followers","following_url":"https://api.github.com/users/sivel/following{/other_user}","gists_url":"https://api.github.com/users/sivel/gists{/gist_id}","starred_url":"https://api.github.com/users/sivel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sivel/subscriptions","organizations_url":"https://api.github.com/users/sivel/orgs","repos_url":"https://api.github.com/users/sivel/repos","events_url":"https://api.github.com/users/sivel/events{/privacy}","received_events_url":"https://api.github.com/users/sivel/received_events","type":"User","site_admin":false},"created_at":"2016-06-04T01:40:38Z","updated_at":"2016-06-04T01:40:38Z","body":"Duplicate of the already merged https://github.com/ansible/ansible-modules-core/pull/3785"}}
{"actor":{"display_login":"sivel"}}