<p>Your molecule run is failing in a very early stage, when it first tries to delete a possibly existing container before starting everything over.</p>

<p>Since you have a default configuration and your make a normal run of molecule, there is absolutely no valuable output in your log.</p>

<p>You have to run molecule in <code>--debug</code> mode to get something usable. And I'd bet a case of champagne that the error you will see poping out is that ansible is not able to find <code>docker or docker-py</code>.</p>

<p>If I'm right, your solution will then be <code>pip install docker</code></p>

CC BY-SA 4.0
2019-03-28T20:22:21.960Z
2019-03-28T20:22:21.960Z
Zeitounator
<p>When molecule is run on travis, the build is successful:</p>

<pre><code>$ molecule test
--&gt; Validating schema /home/travis/build/030/ansible-firefox/molecule/default/molecule.yml.
Validation completed successfully.
--&gt; Test matrix

└── default
    ├── lint
    ├── destroy
    ├── dependency
    ├── syntax
    ├── create
    ├── prepare
    ├── converge
    ├── idempotence
    ├── side_effect
    ├── verify
    └── destroy

--&gt; Scenario: 'default'
--&gt; Action: 'lint'
--&gt; Executing Yamllint on files found in /home/travis/build/030/ansible-firefox/...
Lint completed successfully.
--&gt; Executing Flake8 on files found in /home/travis/build/030/ansible-firefox/molecule/default/tests/...
Lint completed successfully.
--&gt; Executing Ansible Lint on /home/travis/build/030/ansible-firefox/molecule/default/playbook.yml...

Lint completed successfully.
--&gt; Scenario: 'default'
--&gt; Action: 'destroy'

    PLAY [Destroy] *****************************************************************

    TASK [Destroy molecule instance(s)] ********************************************
    changed: [localhost] =&gt; (item=None)
    changed: [localhost]

    TASK [Wait for instance(s) deletion to complete] *******************************
    ok: [localhost] =&gt; (item=None)
    ok: [localhost]

    TASK [Delete docker network(s)] ************************************************

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


--&gt; Scenario: 'default'
--&gt; Action: 'dependency'
Skipping, missing the requirements file.
--&gt; Scenario: 'default'
--&gt; Action: 'syntax'

    playbook: /home/travis/build/030/ansible-firefox/molecule/default/playbook.yml

--&gt; Scenario: 'default'
--&gt; Action: 'create'

    PLAY [Create] ******************************************************************

    TASK [Log into a Docker registry] **********************************************
    skipping: [localhost] =&gt; (item=None) 

    TASK [Create Dockerfiles from image names] *************************************
    changed: [localhost] =&gt; (item=None)
    changed: [localhost]

    TASK [Discover local Docker images] ********************************************
    ok: [localhost] =&gt; (item=None)
    ok: [localhost]

    TASK [Build an Ansible compatible image] ***************************************
    changed: [localhost] =&gt; (item=None)
    changed: [localhost]

    TASK [Create docker network(s)] ************************************************

    TASK [Create molecule instance(s)] *********************************************
    changed: [localhost] =&gt; (item=None)
    changed: [localhost]

    TASK [Wait for instance(s) creation to complete] *******************************
    changed: [localhost] =&gt; (item=None)
    changed: [localhost]

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


--&gt; Scenario: 'default'
--&gt; Action: 'prepare'
Skipping, prepare playbook not configured.
--&gt; Scenario: 'default'
--&gt; Action: 'converge'

    PLAY [Converge] ****************************************************************

    TASK [Gathering Facts] *********************************************************
    ok: [instance]

    TASK [ansible-firefox : Download.] *********************************************
    changed: [instance]

    TASK [ansible-firefox : remove the Firefox package] ****************************
    ok: [instance]

    TASK [ansible-firefox : Dependencies.] *****************************************
    changed: [instance] =&gt; (item=bzip2)
    changed: [instance] =&gt; (item=gtk3)
    changed: [instance] =&gt; (item=libXt)

    TASK [ansible-firefox : Create directory.] *************************************
    changed: [instance]

    TASK [ansible-firefox : Unarchive.] ********************************************
    changed: [instance]

    TASK [ansible-firefox : Symlink.] **********************************************
    changed: [instance]

    TASK [ansible-firefox : Create icons directory.] *******************************
    skipping: [instance]

    TASK [ansible-firefox : Copy firefox logo.] ************************************
    skipping: [instance]

    TASK [ansible-firefox : Create desktop icon.] **********************************
    skipping: [instance]

    RUNNING HANDLER [ansible-firefox : Check version.] *****************************
    changed: [instance]

    PLAY RECAP *********************************************************************
    instance                   : ok=8    changed=6    unreachable=0    failed=0


--&gt; Scenario: 'default'
--&gt; Action: 'idempotence'
Idempotence completed successfully.
--&gt; Scenario: 'default'
--&gt; Action: 'side_effect'
Skipping, side effect playbook not configured.
--&gt; Scenario: 'default'
--&gt; Action: 'verify'
--&gt; Executing Testinfra tests found in /home/travis/build/030/ansible-firefox/molecule/default/tests/...
    ============================= test session starts ==============================
    platform linux2 -- Python 2.7.14, pytest-3.3.0, py-1.5.2, pluggy-0.6.0
    rootdir: /home/travis/build/030/ansible-firefox/molecule/default, inifile:
    plugins: testinfra-1.16.0
collected 1 item                                                               

    tests/test_default.py .                                                  [100%]

    =========================== 1 passed in 4.16 seconds ===========================
Verifier completed successfully.
--&gt; Scenario: 'default'
--&gt; Action: 'destroy'

    PLAY [Destroy] *****************************************************************

    TASK [Destroy molecule instance(s)] ********************************************
    changed: [localhost] =&gt; (item=None)
    changed: [localhost]

    TASK [Wait for instance(s) deletion to complete] *******************************
    changed: [localhost] =&gt; (item=None)
    changed: [localhost]

    TASK [Delete docker network(s)] ************************************************

    PLAY RECAP *********************************************************************
    localhost                  : ok=2    changed=2    unreachable=0    failed=0


The command "molecule test" exited with 0.
Done. Your build exited with 0.
</code></pre>

<p>When run locally, it is able to test, but it fails on the last step:</p>

<pre><code>[username@localhost ansible-firefox]$ docker run --rm -it -v $(pwd):/tmp/$(basename "${PWD}") -w /tmp/$(basename "${PWD}") retr0h/molecule:latest molecule test
--&gt; Validating schema /tmp/ansible-firefox/molecule/default/molecule.yml.
Validation completed successfully.
--&gt; Test matrix

└── default
    ├── lint
    ├── destroy
    ├── dependency
    ├── syntax
    ├── create
    ├── prepare
    ├── converge
    ├── idempotence
    ├── side_effect
    ├── verify
    └── destroy

--&gt; Scenario: 'default'
--&gt; Action: 'lint'
--&gt; Executing Yamllint on files found in /tmp/ansible-firefox/...
Lint completed successfully.
--&gt; Executing Flake8 on files found in /tmp/ansible-firefox/molecule/default/tests/...
Lint completed successfully.
--&gt; Executing Ansible Lint on /tmp/ansible-firefox/molecule/default/playbook.yml...

Lint completed successfully.
--&gt; Scenario: 'default'
--&gt; Action: 'destroy'

    PLAY [Destroy] *****************************************************************

    TASK [Destroy molecule instance(s)] ********************************************
    changed: [localhost] =&gt; (item=None)
    changed: [localhost]

    TASK [Wait for instance(s) deletion to complete] *******************************
    failed: [localhost] (item=None) =&gt; {"attempts": 1, "censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result", "changed": false}
    fatal: [localhost]: FAILED! =&gt; {"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=1    changed=1    unreachable=0    failed=1   


ERROR: 
An error occurred during the test sequence action: 'destroy'. Cleaning up.
--&gt; Scenario: 'default'
--&gt; Action: 'destroy'

    PLAY [Destroy] *****************************************************************

    TASK [Destroy molecule instance(s)] ********************************************
    changed: [localhost] =&gt; (item=None)
    changed: [localhost]

    TASK [Wait for instance(s) deletion to complete] *******************************
    failed: [localhost] (item=None) =&gt; {"attempts": 1, "censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result", "changed": false}
    fatal: [localhost]: FAILED! =&gt; {"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=1    changed=1    unreachable=0    failed=1   


ERROR:
</code></pre>

<p>How do other people run molecule inside docker on their local machines?</p>

CC BY-SA 4.0
2018-11-11T14:36:41.083Z
I haven't tested it, but this should be a job for [Docker-in-docker](https://github.com/jpetazzo/dind). You need to be able to run the container with `--privileged`. For what it's worth, I consider this a bad idea, since it's very easy to end up with corrupt data or other problems... but it's technically feasible. You may need to change the `driver/docker.py` bit of molecule to start the containers properly.
Bruce Becker
<docker><ansible><molecule>
How to test an ansible playbook using molecule inside docker locally?
030
# How to test an ansible playbook using molecule inside docker locally?

(Asked by: username_0 on 2018-11-10)

When molecule is run on travis, the build is successful:
$ molecule test
--> Validating schema /home/travis/build/username_0/ansible-firefox/molecule/default/molecule.yml.
Validation completed successfully.
--> Test matrix

└── default
    ├── lint
    ├── destroy
    ├── dependency
    ├── syntax
    ├── create
    ├── prepare
    ├── converge
    ├── idempotence
    ├── side_effect
    ├── verify
    └── destroy

--> Scenario: 'default'
--> Action: 'lint'
--> Executing Yamllint on files found in /home/travis/build/username_0/ansible-firefox/...
Lint completed successfully.
--> Executing Flake8 on files found in /home/travis/build/username_0/ansible-firefox/molecule/default/tests/...
Lint completed successfully.
--> Executing Ansible Lint on /home/travis/build/username_0/ansible-firefox/molecule/default/playbook.yml...

Lint completed successfully.
--> Scenario: 'default'
--> Action: 'destroy'

    PLAY [Destroy] *****************************************************************

    TASK [Destroy molecule instance(s)] ********************************************
    changed: [localhost] => (item=None)
    changed: [localhost]

    TASK [Wait for instance(s) deletion to complete] *******************************
    ok: [localhost] => (item=None)
    ok: [localhost]

    TASK [Delete docker network(s)] ************************************************

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


--> Scenario: 'default'
--> Action: 'dependency'
Skipping, missing the requirements file.
--> Scenario: 'default'
--> Action: 'syntax'

    playbook: /home/travis/build/username_0/ansible-firefox/molecule/default/playbook.yml

--> Scenario: 'default'
--> Action: 'create'

    PLAY [Create] ******************************************************************

    TASK [Log into a Docker registry] **********************************************
    skipping: [localhost] => (item=None) 

    TASK [Create Dockerfiles from image names] *************************************
    changed: [localhost] => (item=None)
    changed: [localhost]

    TASK [Discover local Docker images] ********************************************
    ok: [localhost] => (item=None)
    ok: [localhost]

    TASK [Build an Ansible compatible image] ***************************************
    changed: [localhost] => (item=None)
    changed: [localhost]

    TASK [Create docker network(s)] ************************************************

    TASK [Create molecule instance(s)] *********************************************
    changed: [localhost] => (item=None)
    changed: [localhost]

    TASK [Wait for instance(s) creation to complete] *******************************
    changed: [localhost] => (item=None)
    changed: [localhost]

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


--> Scenario: 'default'
--> Action: 'prepare'
Skipping, prepare playbook not configured.
--> Scenario: 'default'
--> Action: 'converge'

    PLAY [Converge] ****************************************************************

    TASK [Gathering Facts] *********************************************************
    ok: [instance]

    TASK [ansible-firefox : Download.] *********************************************
    changed: [instance]

    TASK [ansible-firefox : remove the Firefox package] ****************************
    ok: [instance]

    TASK [ansible-firefox : Dependencies.] *****************************************
    changed: [instance] => (item=bzip2)
    changed: [instance] => (item=gtk3)
    changed: [instance] => (item=libXt)

    TASK [ansible-firefox : Create directory.] *************************************
    changed: [instance]

    TASK [ansible-firefox : Unarchive.] ********************************************
    changed: [instance]

    TASK [ansible-firefox : Symlink.] **********************************************
    changed: [instance]

    TASK [ansible-firefox : Create icons directory.] *******************************
    skipping: [instance]

    TASK [ansible-firefox : Copy firefox logo.] ************************************
    skipping: [instance]

    TASK [ansible-firefox : Create desktop icon.] **********************************
    skipping: [instance]

    RUNNING HANDLER [ansible-firefox : Check version.] *****************************
    changed: [instance]

    PLAY RECAP *********************************************************************
    instance                   : ok=8    changed=6    unreachable=0    failed=0


--> Scenario: 'default'
--> Action: 'idempotence'
Idempotence completed successfully.
--> Scenario: 'default'
--> Action: 'side_effect'
Skipping, side effect playbook not configured.
--> Scenario: 'default'
--> Action: 'verify'
--> Executing Testinfra tests found in /home/travis/build/username_0/ansible-firefox/molecule/default/tests/...
    ============================= test session starts ==============================
    platform linux2 -- Python 2.7.14, pytest-3.3.0, py-1.5.2, pluggy-0.6.0
    rootdir: /home/travis/build/username_0/ansible-firefox/molecule/default, inifile:
    plugins: testinfra-1.16.0
collected 1 item                                                               

    tests/test_default.py .                                                  [100%]

    =========================== 1 passed in 4.16 seconds ===========================
Verifier completed successfully.
--> Scenario: 'default'
--> Action: 'destroy'

    PLAY [Destroy] *****************************************************************

    TASK [Destroy molecule instance(s)] ********************************************
    changed: [localhost] => (item=None)
    changed: [localhost]

    TASK [Wait for instance(s) deletion to complete] *******************************
    changed: [localhost] => (item=None)
    changed: [localhost]

    TASK [Delete docker network(s)] ************************************************

    PLAY RECAP *********************************************************************
    localhost                  : ok=2    changed=2    unreachable=0    failed=0


The command "molecule test" exited with 0.
Done. Your build exited with 0.

When run locally, it is able to test, but it fails on the last step:
[username@localhost ansible-firefox]$ docker run --rm -it -v $(pwd):/tmp/$(basename "${PWD}") -w /tmp/$(basename "${PWD}") retr0h/molecule:latest molecule test
--> Validating schema /tmp/ansible-firefox/molecule/default/molecule.yml.
Validation completed successfully.
--> Test matrix

└── default
    ├── lint
    ├── destroy
    ├── dependency
    ├── syntax
    ├── create
    ├── prepare
    ├── converge
    ├── idempotence
    ├── side_effect
    ├── verify
    └── destroy

--> Scenario: 'default'
--> Action: 'lint'
--> Executing Yamllint on files found in /tmp/ansible-firefox/...
Lint completed successfully.
--> Executing Flake8 on files found in /tmp/ansible-firefox/molecule/default/tests/...
Lint completed successfully.
--> Executing Ansible Lint on /tmp/ansible-firefox/molecule/default/playbook.yml...

Lint completed successfully.
--> Scenario: 'default'
--> Action: 'destroy'

    PLAY [Destroy] *****************************************************************

    TASK [Destroy molecule instance(s)] ********************************************
    changed: [localhost] => (item=None)
    changed: [localhost]

    TASK [Wait for instance(s) deletion to complete] *******************************
    failed: [localhost] (item=None) => {"attempts": 1, "censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result", "changed": false}
    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=1    changed=1    unreachable=0    failed=1   


ERROR: 
An error occurred during the test sequence action: 'destroy'. Cleaning up.
--> Scenario: 'default'
--> Action: 'destroy'

    PLAY [Destroy] *****************************************************************

    TASK [Destroy molecule instance(s)] ********************************************
    changed: [localhost] => (item=None)
    changed: [localhost]

    TASK [Wait for instance(s) deletion to complete] *******************************
    failed: [localhost] (item=None) => {"attempts": 1, "censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result", "changed": false}
    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=1    changed=1    unreachable=0    failed=1   


ERROR:

How do other people run molecule inside docker on their local machines?

**Tags:** docker, ansible, molecule

> **Comments:**
> **username_1**: I haven't tested it, but this should be a job for [Docker-in-docker](https://github.com/jpetazzo/dind). You need to be able to run the container with `--privileged`. For what it's worth, I consider this a bad idea, since it's very easy to end up with corrupt data or other problems... but it's technically feasible. You may need to change the `driver/docker.py` bit of molecule to start the containers properly.  

---

## 1 answers

### Answer by username_2 on 2019-03-28. Score: 1 | Accepted answer

Your molecule run is failing in a very early stage, when it first tries to delete a possibly existing container before starting everything over.

Since you have a default configuration and your make a normal run of molecule, there is absolutely no valuable output in your log.

You have to run molecule in `--debug` mode to get something usable. And I'd bet a case of champagne that the error you will see poping out is that ansible is not able to find `docker or docker-py`.

If I'm right, your solution will then be `pip install docker`


---

