Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when there are no docker volumes present yet #28145

merged 2 commits into from Oct 30, 2017


Copy link

@underwaynyc underwaynyc commented Aug 14, 2017


The existing code will attempt to iterate over None. A quick if statement protects the for loop and returns None. Return of None because there are no volumes.

  • Bugfix Pull Request

In the cloud module, in the docker module, the docker_volume command

ansible 2.4.0 (devel cd32ed1929) last updated 2017/08/14 04:01:47 (GMT +000)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/underway/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/underway/underway-server/ansible-fork/lib/ansible
  executable location = /home/underway/underway-server/ansible-fork/bin/ansible
  python version = 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170118]

Attempt to create a volume, where there isn't one on the server yet. Manually do docker volume ls -q | xargs docker volume rm if needed

- name: Install pip
    name: pip
    ��state: present

- name: Install docker-py via pip
    name: docker-py
    state: present

- name: Create docker volume
     name: volume_name
     state: present


TASK [Create docker volume] *******************************************************************************************fatal: [HOST_NAME]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to HOST_NAME closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_wJEYrH/\", line 254, in <module>\r\n    main()\r\n  File \"/tmp/ansible_wJEYrH/\", line 249, in main\r\n    cm = DockerVolumeManager(client)\r\n  File \"/tmp/ansible_wJEYrH/\", line 138, in __init__\r\n    self.existing_volume = self.get_existing_volume()\r\n  File \"/tmp/ansible_wJEYrH/\", line 152, in get_existing_volume\r\n    for volume in volumes[u'Volumes']:\r\nTypeError: 'NoneType' object is not iterable\r\n", "msg": "MODULE FAILURE", "rc": 0}
        to retry, use: --limit @RETRY_FILE.retry


TASK [Create docker volume ] ****************************************************************************************************changed: [HOSTNAME]
Copy link

@ansibot ansibot commented Aug 14, 2017

Copy link

@ansibot ansibot commented Aug 14, 2017

The test ansible-test sanity --test pep8 failed with the following errors:

lib/ansible/modules/cloud/docker/ E711 comparison to None should be 'if cond is None:'
lib/ansible/modules/cloud/docker/ W293 blank line contains whitespace

click here for bot help

Dev at
Copy link

@danramteke danramteke commented Sep 6, 2017

@chouseknecht @alikins Any word on this? Would love to get this fix in (or someone else's fix for the same error) so I can go back to using Ansible's master branch.

Copy link

@agronholm agronholm commented Sep 21, 2017

@chouseknecht it's too bad this didn't make it into, but it should be merged ASAP. I could not imagine that the Docker API would give a None instead of an empty list when there are no volumes.

Copy link

@s-hertel s-hertel commented Oct 30, 2017


@ansibot ansibot removed the stale_ci label Oct 30, 2017
@ansibot ansibot merged commit 11faafc into ansible:devel Oct 30, 2017
1 check passed
1 check passed
Shippable Run 42461 status is SUCCESS.
@ansibot ansibot added bug and removed bugfix_pull_request labels Mar 6, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants