Repository: ansible/molecule

Issue #3689: Move Driver JSONSchema Validation to Drivers.
Created: 2022-10-19T19:10:04Z
Issue Type

Bug report

Molecule and Ansible details
ansible [core 2.13.5]
  config file = None
  configured module search path = ['/home/dmlb2000/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/dmlb2000/.virtualenvs/ansible-azure/lib/python3.10/site-packages/ansible
  ansible collection location = /home/dmlb2000/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/dmlb2000/.virtualenvs/ansible-azure/bin/ansible
  python version = 3.10.7 (main, Sep  7 2022, 00:00:00) [GCC 12.2.1 20220819 (Red Hat 12.2.1-1)]
  jinja version = 3.0.3
  libyaml = True
molecule 4.0.1 using python 3.10
    ansible:2.13.5
    azurevm:0.3.1.dev4 from molecule_azurevm
    delegated:4.0.1 from molecule
    podman:2.0.3 from molecule_podman requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0

Molecule installation method (one of):

pip

Ansible installation method (one of):

pip

Detail any linters or test runners used:
Desired Behavior
Internal or private drivers are useful for companies and organizations to test against their internal services and configurations. These drivers often embed internal names and services to access credentials that will never be available for open source usage. However, these drivers are very useful internally standardizing testing environments.
Actual Behaviour
The JSONSchema validation is insufficient to include JSONSchema provided by private or internal molecule drivers and in its current (4.0.2) implementation breaks the usage of these drivers.

Duplicate issue #3783: Impossible to use a custom driver
Created: 2022-12-14T17:00:45Z
Issue Type

Bug report

Molecule and Ansible details
ansible --version && molecule --version

ansible [core 2.12.10]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/gloria/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.10/site-packages/ansible
  ansible collection location = /home/gloria/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.8 (main, Nov 14 2022, 00:00:00) [GCC 12.2.1 20220819 (Red Hat 12.2.1-2)]
  jinja version = 3.1.2
  libyaml = True
molecule 4.0.0 using python 3.10 
    ansible:2.12.10
    delegated:4.0.0 from molecule
    custom-driver-name:0.0.4 from custom_driver_name
Molecule installation method (one of):

pip

Ansible installation method (one of):

pip

Detail any linters or test runners used:
Desired Behavior
We are developing a custom molecule driver.
Unfortunately, at the moment, it seems no possible to use it.
The reasons that pushed us to create a custom driver are:

It is possible to import a driver in multiple project (no code duplication)
The delegated driver needs to be re-implemented every time
If the custom driver needs to be modified, all the modifications will be available in all the projects that use it.

Actual Behaviour
First, we install the custom driver:
pip install custom_driver_name
Then, we check that it is listed among the molecule drivers
>> molecule drivers
╶───────────────────────────────────────────────────────── 
delegated 
custom_driver_name                                                                                                                                                                                                                                                                                                                   
But then, when we try to use it from molecule <command> -d custom_driver_name the following error is shown:
Error: Invalid value for '--driver-name' / '-d': 'custom_driver_name is not one of 'delegated', 'docker', 'podman'.
This is error is due to a validation fail
Possible solution
A possible solution is to define a prefix (e.g. custom-) or a set of prefix (e.g. custom-, molecule-, ... ) that make possible the validation. This will make the validation more flexible while maintaining the guarantee that the user is not misspelling standard driver names.

Closing comment (2022-12-15T08:40:11Z): Looks like a duplicate of #3689. Look at #3765 which tries to improve things [ I hoped to find time to look at this PR but still -ENOTIME ].