Molecule: Init error trying to create a test instance

Created on 5 Jul 2018  路  1Comment  路  Source: ansible-community/molecule

Issue Type

  • Bug report
  • Feature request

Molecule and Ansible details

(my_env) vagrant@ubuntu-xenial:~/httpd$ ansible --version
ansible 2.6.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/vagrant/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /home/vagrant/my_env/local/lib/python2.7/site-packages/ansible
executable location = /home/vagrant/my_env/bin/ansible
python version = 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609]

(my_env) vagrant@ubuntu-xenial:~/httpd$ molecule --version
molecule, version 2.15.0

Molecule installation method

  • pip

Ansible installation method (one of):

  • pip

Desired Behavior

Followed the following document https://www.digitalocean.com/community/tutorials/how-to-test-ansible-roles-with-molecule to install, test molecule on an Ubuntu 16.04 VM running in VirtualBox.

When I ran molecule test I got an error when it was building the docker instance. A re-run with --debug gives me this error:

    TASK [Wait for instance(s) creation to complete] *******************************
    task path: /home/vagrant/my_env/local/lib/python2.7/site-packages/molecule/provisioner/ansible/playbooks/docker/create.yml:77
    <127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: vagrant
    <127.0.0.1> EXEC /bin/sh -c 'echo ~vagrant && sleep 0'
    <127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/vagrant/.ansible/tmp/ansible-tmp-1530797587.78-280389381509764 `" && echo ansible-tmp-1530797587.78-280389381509764="` echo /home/vagrant/.ansible/tmp/ansible-tmp-1530797587.78-280389381509764 `" ) && sleep 0'
    Using module file /home/vagrant/my_env/local/lib/python2.7/site-packages/ansible/modules/utilities/logic/async_status.py
    <127.0.0.1> PUT /home/vagrant/.ansible/tmp/ansible-local-3043U0O_dV/tmpb4Lmay TO /home/vagrant/.ansible/tmp/ansible-tmp-1530797587.78-280389381509764/async_status.py
    <127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1530797587.78-280389381509764/ /home/vagrant/.ansible/tmp/ansible-tmp-1530797587.78-280389381509764/async_status.py && sleep 0'
    <127.0.0.1> EXEC /bin/sh -c '/home/vagrant/my_env/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1530797587.78-280389381509764/async_status.py && sleep 0'
    <127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/vagrant/.ansible/tmp/ansible-tmp-1530797587.78-280389381509764/ > /dev/null 2>&1 && sleep 0'
    failed: [localhost] (item={'_ansible_parsed': True, '_ansible_item_result': True, '_ansible_item_label': {'image': u'milcom/centos7-systemd', 'name': u'centos7', 'privileged': True}, u'ansible_job_id': u'749343066003.3176', 'failed': False, u'started': 1, 'changed': True, 'item': {'image': u'milcom/centos7-systemd', 'name': u'centos7', 'privileged': True}, u'finished': 0, u'results_file': u'/home/vagrant/.ansible_async/749343066003.3176', '_ansible_ignore_errors': None, '_ansible_no_log': False}) => {
        "ansible_job_id": "749343066003.3176",
        "attempts": 1,
        "changed": false,
        "cmd": "/home/vagrant/.ansible/tmp/ansible-tmp-1530797586.42-107697817974781/docker_container.py",
        "data": "",
        "finished": 1,
        "invocation": {
            "module_args": {
                "jid": "749343066003.3176",
                "mode": "status"
            }
        },
        "item": {
            "ansible_job_id": "749343066003.3176",
            "changed": true,
            "failed": false,
            "finished": 0,
            "item": {
                "image": "milcom/centos7-systemd",
                "name": "centos7",
                "privileged": true
            },
            "results_file": "/home/vagrant/.ansible_async/749343066003.3176",
            "started": 1
        },
        "msg": "Traceback (most recent call last):\n  File \"/home/vagrant/.ansible/tmp/ansible-tmp-1530797586.42-107697817974781/async_wrapper.py\", line 150, in _run_module\n    (filtered_outdata, json_warnings) = _filter_non_json_lines(outdata)\n  File \"/home/vagrant/.ansible/tmp/ansible-tmp-1530797586.42-107697817974781/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_9o85SF/ansible_module_docker_container.py\", line 2081, in <module>\n    main()\n  File \"/tmp/ansible_9o85SF/ansible_module_docker_container.py\", line 2076, in main\n    cm = ContainerManager(client)\n  File \"/tmp/ansible_9o85SF/ansible_module_docker_container.py\", line 1703, in __init__\n    self.present(state)\n  File \"/tmp/ansible_9o85SF/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_9o85SF/ansible_module_docker_container.py\", line 825, in create_parameters\n    host_config=self._host_config(),\n  File \"/tmp/ansible_9o85SF/ansible_module_docker_container.py\", line 931, in _host_config\n    return self.client.create_host_config(**params)\n  File \"/home/vagrant/my_env/local/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_9o85SF/ansible_module_docker_container.py\", line 2081, in <module>",
            "    main()",
            "  File \"/tmp/ansible_9o85SF/ansible_module_docker_container.py\", line 2076, in main",
            "    cm = ContainerManager(client)",
            "  File \"/tmp/ansible_9o85SF/ansible_module_docker_container.py\", line 1703, in __init__",
            "    self.present(state)",
            "  File \"/tmp/ansible_9o85SF/ansible_module_docker_container.py\", line 1723, in present",
            "    new_container = self.container_create(self.parameters.image, self.parameters.create_parameters)",
            "  File \"/tmp/ansible_9o85SF/ansible_module_docker_container.py\", line 825, in create_parameters",
            "    host_config=self._host_config(),",
            "  File \"/tmp/ansible_9o85SF/ansible_module_docker_container.py\", line 931, in _host_config",
            "    return self.client.create_host_config(**params)",
            "  File \"/home/vagrant/my_env/local/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'"
        ]
    }
    fatal: [localhost]: FAILED! => {
        "censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result",
        "changed": false
    }

    PLAY RECAP *********************************************************************
    localhost                  : ok=4    changed=3    unreachable=0    failed=1


ERROR:
An error occured during the test sequence.  Cleaning up.

Any clue whats going on?
Thanks
Louis

Most helpful comment

Please ignore.

It was a lucky search but I found this issue: https://github.com/metacloud/molecule/issues/1353 following it I removed docker-py and installed docker via pip. That fixed my problem.

Thanks,
Louis

>All comments

Please ignore.

It was a lucky search but I found this issue: https://github.com/metacloud/molecule/issues/1353 following it I removed docker-py and installed docker via pip. That fixed my problem.

Thanks,
Louis

Was this page helpful?
0 / 5 - 0 ratings