Issue 1:
From @guenhter on 2016-10-13T15:58:27Z

ISSUE TYPE

Bug Report

COMPONENT NAME

docker_network

ANSIBLE VERSION

ansible 2.2.0.0 (detached HEAD 44faad0593) last updated 2016/10/13 13:41:31 (GMT +000)
lib/ansible/modules/core: (detached HEAD d66983b43e) last updated 2016/10/13 13:41:31 (GMT +000)
lib/ansible/modules/extras: (detached HEAD 35132b892f) last updated 2016/10/13 13:41:31 (GMT +000)
config file =
configured module search path = Default w/o overrides

CONFIGURATION

no changes in environment

OS / ENVIRONMENT

Debian 8.6

Linux machine0 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u1 (2016-09-03) x86_64 GNU/Linux

SUMMARY

Docker network can't be created with driver overlay.

STEPS TO REPRODUCE

Setup docker in swarm mode (e.g. with https://github.com/atosatto/ansible-dockerswarm)

Just execute this task in a environment where docker 1.12.1 runs in swarm mode.

- name: Sample network
docker_network:
name: my-net1
driver: overlay

EXPECTED RESULTS

New network is created

ACTUAL RESULTS

Runtime error when playbook is executed and task is reached

TASK [ansible-dockerswarm : Sample network] ************************************
task path: /vagrant/service-playbooks/roles/ansible-dockerswarm/tasks/swarm_cluster.yml:15
Using module file /home/vagrant/ansible/lib/ansible/modules/core/cloud/docker/docker_network.py
<192.168.77.202> ESTABLISH SSH CONNECTION FOR USER: deploy
<192.168.77.202> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=deploy -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.77.202 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1476374253.85-52715585730759 `" && echo ansible-tmp-1476374253.85-52715585730759="` echo $HOME/.ansible/tmp/ansible-tmp-1476374253.85-52715585730759 `" ) && sleep 0'"'"''
Using module file /home/vagrant/ansible/lib/ansible/modules/core/cloud/docker/docker_network.py
<192.168.77.203> ESTABLISH SSH CONNECTION FOR USER: deploy
<192.168.77.203> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=deploy -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.77.203 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1476374253.86-156181693682119 `" && echo ansible-tmp-1476374253.86-156181693682119="` echo $HOME/.ansible/tmp/ansible-tmp-1476374253.86-156181693682119 `" ) && sleep 0'"'"''
Using module file /home/vagrant/ansible/lib/ansible/modules/core/cloud/docker/docker_network.py
<192.168.77.201> ESTABLISH SSH CONNECTION FOR USER: deploy
<192.168.77.201> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=deploy -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.77.201 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1476374253.86-87520848410690 `" && echo ansible-tmp-1476374253.86-87520848410690="` echo $HOME/.ansible/tmp/ansible-tmp-1476374253.86-87520848410690 `" ) && sleep 0'"'"''
<192.168.77.203> PUT /tmp/tmpHAeuPH TO /home/deploy/.ansible/tmp/ansible-tmp-1476374253.86-156181693682119/docker_network.py
<192.168.77.203> SSH: EXEC sftp -b - -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=deploy -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r '[192.168.77.203]'
<192.168.77.202> PUT /tmp/tmptFUA_b TO /home/deploy/.ansible/tmp/ansible-tmp-1476374253.85-52715585730759/docker_network.py
<192.168.77.202> SSH: EXEC sftp -b - -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=deploy -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r '[192.168.77.202]'
<192.168.77.201> PUT /tmp/tmpDZd6Bx TO /home/deploy/.ansible/tmp/ansible-tmp-1476374253.86-87520848410690/docker_network.py
<192.168.77.201> SSH: EXEC sftp -b - -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=deploy -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r '[192.168.77.201]'
<192.168.77.203> ESTABLISH SSH CONNECTION FOR USER: deploy
<192.168.77.203> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=deploy -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.77.203 '/bin/sh -c '"'"'chmod u+x /home/deploy/.ansible/tmp/ansible-tmp-1476374253.86-156181693682119/ /home/deploy/.ansible/tmp/ansible-tmp-1476374253.86-156181693682119/docker_network.py && sleep 0'"'"''
<192.168.77.202> ESTABLISH SSH CONNECTION FOR USER: deploy
<192.168.77.202> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=deploy -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.77.202 '/bin/sh -c '"'"'chmod u+x /home/deploy/.ansible/tmp/ansible-tmp-1476374253.85-52715585730759/ /home/deploy/.ansible/tmp/ansible-tmp-1476374253.85-52715585730759/docker_network.py && sleep 0'"'"''
<192.168.77.201> ESTABLISH SSH CONNECTION FOR USER: deploy
<192.168.77.201> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=deploy -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.77.201 '/bin/sh -c '"'"'chmod u+x /home/deploy/.ansible/tmp/ansible-tmp-1476374253.86-87520848410690/ /home/deploy/.ansible/tmp/ansible-tmp-1476374253.86-87520848410690/docker_network.py && sleep 0'"'"''
<192.168.77.203> ESTABLISH SSH CONNECTION FOR USER: deploy
<192.168.77.201> ESTABLISH SSH CONNECTION FOR USER: deploy
<192.168.77.201> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=deploy -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r -tt 192.168.77.201 '/bin/sh -c '"'"'/usr/bin/python /home/deploy/.ansible/tmp/ansible-tmp-1476374253.86-87520848410690/docker_network.py; rm -rf "/home/deploy/.ansible/tmp/ansible-tmp-1476374253.86-87520848410690/" > /dev/null 2>&1 && sleep 0'"'"''
<192.168.77.202> ESTABLISH SSH CONNECTION FOR USER: deploy
<192.168.77.202> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=deploy -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r -tt 192.168.77.202 '/bin/sh -c '"'"'/usr/bin/python /home/deploy/.ansible/tmp/ansible-tmp-1476374253.85-52715585730759/docker_network.py; rm -rf "/home/deploy/.ansible/tmp/ansible-tmp-1476374253.85-52715585730759/" > /dev/null 2>&1 && sleep 0'"'"''
<192.168.77.203> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=deploy -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r -tt 192.168.77.203 '/bin/sh -c '"'"'/usr/bin/python /home/deploy/.ansible/tmp/ansible-tmp-1476374253.86-156181693682119/docker_network.py; rm -rf "/home/deploy/.ansible/tmp/ansible-tmp-1476374253.86-156181693682119/" > /dev/null 2>&1 && sleep 0'"'"''
fatal: [machine_3]: FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_name": "docker_network"
},
"module_stderr": "OpenSSH_6.7p1 Debian-5+deb8u3, OpenSSL 1.0.1t 3 May 2016\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 10854\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 192.168.77.203 closed.\r\n",
"module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_UmI8My/ansible_module_docker_network.py\", line 378, in <module>\r\n main()\r\n File \"/tmp/ansible_UmI8My/ansible_module_docker_network.py\", line 371, in main\r\n cm = DockerNetworkManager(client)\r\n File \"/tmp/ansible_UmI8My/ansible_module_docker_network.py\", line 211, in __init__\r\n self.present()\r\n File \"/tmp/ansible_UmI8My/ansible_module_docker_network.py\", line 335, in present\r\n self.create_network()\r\n File \"/tmp/ansible_UmI8My/ansible_module_docker_network.py\", line 283, in create_network\r\n ipam=ipam_config)\r\n File \"/usr/local/lib/python2.7/dist-packages/docker/utils/decorators.py\", line 35, in wrapper\r\n return f(self, *args, **kwargs)\r\n File \"/usr/local/lib/python2.7/dist-packages/docker/api/network.py\", line 62, in create_network\r\n return self._result(res, json=True)\r\n File \"/usr/local/lib/python2.7/dist-packages/docker/client.py\", line 178, in _result\r\n self._raise_for_status(response)\r\n File \"/usr/local/lib/python2.7/dist-packages/docker/client.py\", line 174, in _raise_for_status\r\n raise errors.APIError(e, response, explanation=explanation)\r\ndocker.errors.APIError: 500 Server Error: Internal Server Error (\"{\"message\":\"datastore for scope \\\"global\\\" is not initialized \"}\")\r\n",
"msg": "MODULE FAILURE"
}
fatal: [machine_2]: FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_name": "docker_network"
},
"module_stderr": "OpenSSH_6.7p1 Debian-5+deb8u3, OpenSSL 1.0.1t 3 May 2016\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 10849\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 192.168.77.202 closed.\r\n",
"module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_gJEa7t/ansible_module_docker_network.py\", line 378, in <module>\r\n main()\r\n File \"/tmp/ansible_gJEa7t/ansible_module_docker_network.py\", line 371, in main\r\n cm = DockerNetworkManager(client)\r\n File \"/tmp/ansible_gJEa7t/ansible_module_docker_network.py\", line 211, in __init__\r\n self.present()\r\n File \"/tmp/ansible_gJEa7t/ansible_module_docker_network.py\", line 335, in present\r\n self.create_network()\r\n File \"/tmp/ansible_gJEa7t/ansible_module_docker_network.py\", line 283, in create_network\r\n ipam=ipam_config)\r\n File \"/usr/local/lib/python2.7/dist-packages/docker/utils/decorators.py\", line 35, in wrapper\r\n return f(self, *args, **kwargs)\r\n File \"/usr/local/lib/python2.7/dist-packages/docker/api/network.py\", line 62, in create_network\r\n return self._result(res, json=True)\r\n File \"/usr/local/lib/python2.7/dist-packages/docker/client.py\", line 178, in _result\r\n self._raise_for_status(response)\r\n File \"/usr/local/lib/python2.7/dist-packages/docker/client.py\", line 174, in _raise_for_status\r\n raise errors.APIError(e, response, explanation=explanation)\r\ndocker.errors.APIError: 500 Server Error: Internal Server Error (\"{\"message\":\"datastore for scope \\\"global\\\" is not initialized \"}\")\r\n",
"msg": "MODULE FAILURE"
}
fatal: [machine_1]: FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_name": "docker_network"
},
"module_stderr": "OpenSSH_6.7p1 Debian-5+deb8u3, OpenSSL 1.0.1t 3 May 2016\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 10754\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 192.168.77.201 closed.\r\n",
"module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_kgQpcW/ansible_module_docker_network.py\", line 378, in <module>\r\n main()\r\n File \"/tmp/ansible_kgQpcW/ansible_module_docker_network.py\", line 371, in main\r\n cm = DockerNetworkManager(client)\r\n File \"/tmp/ansible_kgQpcW/ansible_module_docker_network.py\", line 211, in __init__\r\n self.present()\r\n File \"/tmp/ansible_kgQpcW/ansible_module_docker_network.py\", line 335, in present\r\n self.create_network()\r\n File \"/tmp/ansible_kgQpcW/ansible_module_docker_network.py\", line 283, in create_network\r\n ipam=ipam_config)\r\n File \"/usr/local/lib/python2.7/dist-packages/docker/utils/decorators.py\", line 35, in wrapper\r\n return f(self, *args, **kwargs)\r\n File \"/usr/local/lib/python2.7/dist-packages/docker/api/network.py\", line 62, in create_network\r\n return self._result(res, json=True)\r\n File \"/usr/local/lib/python2.7/dist-packages/docker/client.py\", line 178, in _result\r\n self._raise_for_status(response)\r\n File \"/usr/local/lib/python2.7/dist-packages/docker/client.py\", line 174, in _raise_for_status\r\n raise errors.APIError(e, response, explanation=explanation)\r\ndocker.errors.APIError: 500 Server Error: Internal Server Error (\"{\"message\":\"rpc error: code = 3 desc = driver name: if driver is specified name is required\"}\")\r\n",
"msg": "MODULE FAILURE"
}

Copied from original issue: ansible/ansible-modules-core#5254

Issue 2:
Feature Idea

ANSIBLE VERSION

ansible 2.0.1.0
config file = /Users/do3cc/dev/ansible/ansible.cfg
configured module search path = Default w/o overrides

CONFIGURATION

OS / ENVIRONMENT

N/A

SUMMARY

It would be nice to be able to provide a seed for random, so that I get a predictible random number

Use case:

- name: Periodic restart of workers
cron:
name: "restart worker {{item}}"
minute: "{{60|random(item)}}"
hour: */4
job: "restart {{item}}"

Given that the item name does not change with each invocation, I would always get the same random number, and my cronjob would not be changed with each invocation.