Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to use a custom driver #3783

Closed
gciavarrini opened this issue Dec 14, 2022 · 3 comments
Closed

Impossible to use a custom driver #3783

gciavarrini opened this issue Dec 14, 2022 · 3 comments
Labels

Comments

@gciavarrini
Copy link
Contributor

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.

@apatard
Copy link
Contributor

apatard commented Dec 15, 2022

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 ].

@gciavarrini
Copy link
Contributor Author

@apatard Thank you for pointing out #3689: I missed it!

Since the proposed solution in #3765 is still under development, and it seems a bit complex, I'd like to propose to the community my idea of allowing driver name with prefixes molecule or custom.
I created a draft PR #3795 to demonstrate and, hopefully, discuss the idea.

Feel free to close this issue if you think it's best :)

@gciavarrini
Copy link
Contributor Author

Resolved by PR #3795.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants