molecule syntax depends on Docker sanity check

Created on 20 Mar 2020  ·  2Comments  ·  Source: ansible-community/molecule

Issue Type

  • Bug report

Molecule and Ansible details

$ ansible --version
 ansible 2.9.4
   config file = None
   configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
   ansible python module location = /usr/lib/python3.8/site-packages/ansible
   executable location = /usr/bin/ansible
   python version = 3.8.1 (default, Jan 19 2020, 11:48:03) [GCC 9.2.0]

$ molecule --version
 molecule 3.0.2
    ansible==2.9.4 python==3.8

Molecule installation method (one of):

Ansible installation method (one of):

Detail any linters or test runners used:

  • GitLab Pipeline where GitLab Runners run on Kubernetes which use Docker-in-Docker for Molecule

Desired Behavior

I want to implement two pipelines:

  • A small one which only needs a few seconds for linting, deprecation and syntax checking (for every push to every branch)
  • And a "big" pipeline with all tests and rollouts on different platforms which needs a few minutes (only for merge requests and stable branches)

That's why only one pipeline needs to actually be 'Docker ready'

With molecule 2.20 - Syntax check is working and doesn't depends on docker.

molecule syntax
 --> Validating schema /builds/bsp/roles/ntp/molecule/default/molecule.yml.
 Validation completed successfully.
 --> Test matrix

 └── default
     └── syntax

 --> Scenario: 'default'
 --> Action: 'syntax'

     playbook: /builds/bsp/roles/ntp/molecule/default/converge.yml

Actual Behaviour

With molecule 3+ - Syntax check is no longer working if driver: docker is used and Docker daemon is not reachable

molecule --debug syntax
 --> Test matrix

 └── default
     └── syntax

 --> Scenario: 'default'
 --> Action: 'syntax'
 --> Sanity checks: 'docker'
 ERROR: Unable to contact the Docker daemon. Please refer to https://docs.docker.com/config/daemon/ for managing the daemon

Sanity checks: 'docker' seems to come from the driver: docker.
While using driver: delegated it's working again.

Unfortunately it seems not possible to use variables for the driver option.

$ molecule syntax
ERROR: Failed to pre-validate.
{'driver': [{'name': ['unallowed value $MOLECULE_DRIVER:-docker']}]}
---
driver:
  name: ${MOLECULE_DRIVER:-docker}
[...]

Workarounds:

  • Using two scenarios probably
  • Using Ansbile syntax checking:
    - ln -s ../../.. molecule/default/roles
    - ansible-playbook -i "localhost," molecule/default/converge.yml --syntax-check
bug

All 2 comments

I kinda knew about this issue but is more complex because syntax also depends on the driver being used, so it needs to be instantiated. Also drives do have this sanity check which is very useful for failing fast when they are not setup correctly.

Feel free to propose a fix.

Molecule no longer depends on docker plugin, nor its sanity check.

Was this page helpful?
0 / 5 - 0 ratings