ansible / molecule

Molecule aids in the development and testing of Ansible content: collections, playbooks and roles
https://ansible.readthedocs.io/projects/molecule/
MIT License
3.88k stars 663 forks source link

molecule syntax depends on Docker sanity check #2614

Closed He3chai closed 3 years ago

He3chai commented 4 years ago

Issue Type

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:

Desired Behavior

I want to implement two pipelines:

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:

ssbarnea commented 4 years ago

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.

ssbarnea commented 3 years ago

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