snippetdockerMinor
How to test an ansible playbook using molecule inside docker locally?
Viewed 0 times
moleculedockerlocallyplaybookusingtesthowansibleinside
Problem
When molecule is run on travis, the build is successful:
```
$ molecule test
--> Validating schema /home/travis/build/030/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/030/ansible-firefox/...
Lint completed successfully.
--> Executing Flake8 on files found in /home/travis/build/030/ansible-firefox/molecule/default/tests/...
Lint completed successfully.
--> Executing Ansible Lint on /home/travis/build/030/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/030/ansible-firefox/molecule/default/playbook.yml
--> Scenario: 'default'
--> Action: 'create'
PLAY [Create]
TASK [Log into a Docker registry]
skipping: [localhost] => (item=None)
```
$ molecule test
--> Validating schema /home/travis/build/030/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/030/ansible-firefox/...
Lint completed successfully.
--> Executing Flake8 on files found in /home/travis/build/030/ansible-firefox/molecule/default/tests/...
Lint completed successfully.
--> Executing Ansible Lint on /home/travis/build/030/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/030/ansible-firefox/molecule/default/playbook.yml
--> Scenario: 'default'
--> Action: 'create'
PLAY [Create]
TASK [Log into a Docker registry]
skipping: [localhost] => (item=None)
Solution
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
If I'm right, your solution will then be
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 dockerContext
StackExchange DevOps Q#5403, answer score: 1
Revisions (0)
No revisions yet.