ansible --version
ansible-2.6.0
molecule --version
molecule-2.15.0
Molecule installation method (one of):
Ansible installation method (one of):
With testing the new Ansible 2.6 version, a failure can be seen in travis. This same build with a previous version of Ansible is not seen.
The error complains about the Ansible module docker_container which contains a new feature init since Ansible 2.6.
TASK [Wait for instance(s) creation to complete] *******************************
task path: /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/molecule/provisioner/ansible/playbooks/docker/create.yml:77
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: travis
<127.0.0.1> EXEC /bin/sh -c 'echo ~travis && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/travis/.ansible/tmp/ansible-tmp-1530339080.01-82067774028806 `" && echo ansible-tmp-1530339080.01-82067774028806="` echo /home/travis/.ansible/tmp/ansible-tmp-1530339080.01-82067774028806 `" ) && sleep 0'
Using module file /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/ansible/modules/utilities/logic/async_status.py
<127.0.0.1> PUT /home/travis/.ansible/tmp/ansible-local-4271ntsaec/tmpg4fcvH TO /home/travis/.ansible/tmp/ansible-tmp-1530339080.01-82067774028806/async_status.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/travis/.ansible/tmp/ansible-tmp-1530339080.01-82067774028806/ /home/travis/.ansible/tmp/ansible-tmp-1530339080.01-82067774028806/async_status.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/home/travis/virtualenv/python2.7.14/bin/python /home/travis/.ansible/tmp/ansible-tmp-1530339080.01-82067774028806/async_status.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/travis/.ansible/tmp/ansible-tmp-1530339080.01-82067774028806/ > /dev/null 2>&1 && sleep 0'
failed: [localhost] (item={'_ansible_parsed': True, '_ansible_item_result': True, '_ansible_item_label': {'image': u'alpine:latest', 'name': u'bootstrap-alpine-latest'}, u'ansible_job_id': u'925561229929.4525', 'failed': False, u'started': 1, 'changed': True, 'item': {'image': u'alpine:latest', 'name': u'bootstrap-alpine-latest'}, u'finished': 0, u'results_file': u'/home/travis/.ansible_async/925561229929.4525', '_ansible_ignore_errors': None, '_ansible_no_log': False}) => {
"ansible_job_id": "925561229929.4525",
"attempts": 1,
"changed": false,
"cmd": "/home/travis/.ansible/tmp/ansible-tmp-1530339078.73-54806992101010/docker_container.py",
"data": "",
"finished": 1,
"invocation": {
"module_args": {
"jid": "925561229929.4525",
"mode": "status"
}
},
"item": {
"ansible_job_id": "925561229929.4525",
"changed": true,
"failed": false,
"finished": 0,
"item": {
"image": "alpine:latest",
"name": "bootstrap-alpine-latest"
},
"results_file": "/home/travis/.ansible_async/925561229929.4525",
"started": 1
},
"msg": "Traceback (most recent call last):\n File \"/home/travis/.ansible/tmp/ansible-tmp-1530339078.73-54806992101010/async_wrapper.py\", line 150, in _run_module\n (filtered_outdata, json_warnings) = _filter_non_json_lines(outdata)\n File \"/home/travis/.ansible/tmp/ansible-tmp-1530339078.73-54806992101010/async_wrapper.py\", line 91, in _filter_non_json_lines\n raise ValueError('No start of json char found')\nValueError: No start of json char found\n",
"stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_6AF3tt/ansible_module_docker_container.py\", line 2081, in <module>\n main()\n File \"/tmp/ansible_6AF3tt/ansible_module_docker_container.py\", line 2076, in main\n cm = ContainerManager(client)\n File \"/tmp/ansible_6AF3tt/ansible_module_docker_container.py\", line 1703, in __init__\n self.present(state)\n File \"/tmp/ansible_6AF3tt/ansible_module_docker_container.py\", line 1723, in present\n new_container = self.container_create(self.parameters.image, self.parameters.create_parameters)\n File \"/tmp/ansible_6AF3tt/ansible_module_docker_container.py\", line 825, in create_parameters\n host_config=self._host_config(),\n File \"/tmp/ansible_6AF3tt/ansible_module_docker_container.py\", line 931, in _host_config\n return self.client.create_host_config(**params)\n File \"/home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/docker/api/container.py\", line 157, in create_host_config\n return utils.create_host_config(*args, **kwargs)\nTypeError: create_host_config() got an unexpected keyword argument 'init'\n",
"stderr_lines": [
"Traceback (most recent call last):",
" File \"/tmp/ansible_6AF3tt/ansible_module_docker_container.py\", line 2081, in <module>",
" main()",
" File \"/tmp/ansible_6AF3tt/ansible_module_docker_container.py\", line 2076, in main",
" cm = ContainerManager(client)",
" File \"/tmp/ansible_6AF3tt/ansible_module_docker_container.py\", line 1703, in __init__",
" self.present(state)",
" File \"/tmp/ansible_6AF3tt/ansible_module_docker_container.py\", line 1723, in present",
" new_container = self.container_create(self.parameters.image, self.parameters.create_parameters)",
" File \"/tmp/ansible_6AF3tt/ansible_module_docker_container.py\", line 825, in create_parameters",
" host_config=self._host_config(),",
" File \"/tmp/ansible_6AF3tt/ansible_module_docker_container.py\", line 931, in _host_config",
" return self.client.create_host_config(**params)",
" File \"/home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/docker/api/container.py\", line 157, in create_host_config",
" return utils.create_host_config(*args, **kwargs)",
"TypeError: create_host_config() got an unexpected keyword argument 'init'"
]
}
The stack trace looks like this is happening in code external to Molecule. Could this be an issue with docker-py vs docker pip module? I have been using docker-py since docker didn't work in all cases with Ansible. Especially around building images. Could it be 2.6 requires docker?
You are right, it's a bug in Ansible 2.6.0
@retr0h It shouldn't require docker, but it seems that for docker_container, it does (maybe even some docker versions won't work). I don't think it was intentional, though...
For reference, I used pip install docker-py and switched to pip install docker, which solved the issue for me.
Now testing Ansible 2.6 as part of unit and functional tests (#1360). Thanks as always @robertdebock !
So it should be noted that the docker_login module and docker_container are at odds as it relates to the docker-py vs docker library. Both libraries can't be installed at the same time. Yet docker_login requires the older docker-py library and the docker_container module requires the newer library.
Either docker_container needs to be reverted or docker_library needs to be updated.
I'm running into this problem using the molecule docker container, is there a work around for this?
Upgrade to Ansible 2.6.2 or 2.6.3, they should no longer have this problem.
@felixfontein just updated my docker image with the latest ansible and molecule, and it worked. Thanks for the help.
Most helpful comment
For reference, I used
pip install docker-pyand switched topip install docker, which solved the issue for me.