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

Add support for global molecule configuration #89

Merged
merged 1 commit into from
May 17, 2021

Conversation

strider
Copy link
Contributor

@strider strider commented May 6, 2021

This patch adds the support for molecule base configuration. It will
allow us to use a global molecule configuration file[1] or to pass one
or multiple base configuration file(s) according to ansible-molecule
through the tox.ini file.

By default, if not passing base configuration file(s) in the tox.ini
file but if there is a global configuration file[1], this will be the
reference to determine the driver name if the scenarios configuration
files didn't override the default one coming from the global one[1].

If there is [1] at the project level and passing base configuration
file(s) in the tox.ini file, those latter will take precedence over the
global one[1].

Note that tox-ansible will now raise a RuntimeError if it finds out
multiple driver name declaration when using multiple molecule base
configuration.

[1] - <PROJECT_ABSPATH>/.config/molecule/config.yml

Fixes #88

Signed-off-by: Gael Chamoulaud (Strider) gchamoul@redhat.com

@strider
Copy link
Contributor Author

strider commented May 6, 2021

@ssbarnea @greg-hellings

Ready for reviews ;-)

@strider strider force-pushed the master branch 3 times, most recently from ea8181e to 291dfa5 Compare May 10, 2021 09:03
@ssbarnea ssbarnea added the enhancement This issue/PR relates to a feature request. label May 12, 2021
src/tox_ansible/ansible/__init__.py Outdated Show resolved Hide resolved
src/tox_ansible/ansible/scenario.py Outdated Show resolved Hide resolved
tests/fixtures/collection/tox.ini Outdated Show resolved Hide resolved
This patch adds the support for molecule base configuration. It will
allow us to use a global molecule configuration file[1] or to pass one
or multiple base configuration file(s) according to ansible-molecule
through the tox.ini file and the `molecule_config_files` option.

By default, if not passing base configuration file(s) in the tox.ini
file but if there is a global configuration file[1], this will be the
reference to determine the driver name if the scenarios configuration
files didn't override the default one coming from the global one[1].

If there is [1] at the project level and passing base configuration
file(s) in the tox.ini file, those latter will take precedence over the
global one[1].

Note that tox-ansible will now raise a RuntimeError if it finds out
multiple driver name declaration when using multiple molecule base
configuration.

[1] - <PROJECT_ABSPATH>/.config/molecule/config.yml

Fixes ansible#88

Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
@greg-hellings
Copy link
Contributor

I'm going to merge this as-is.

I think it's worth noting that there's no reason a user can't configure the Driver in multiple base config files, to my knowledge. (I'd like to hear from @ssbarnea on that) So, if someone needs that ability, they can open an issue to relax that. But, as it is, this likely solves 99% of the problems people will have.

@greg-hellings greg-hellings merged commit f26012e into ansible:master May 17, 2021
@strider
Copy link
Contributor Author

strider commented May 17, 2021

@greg-hellings

It could happen and it's called a human mistake IMO. We should have only one default driver declared in base config file(s) and could possibly be overriden through the molecule.yml file of your scenarios.

Btw, I still don't understand why we are able to pass multiple base config files to molecule ... Isn't one just enough? :/

@strider
Copy link
Contributor Author

strider commented May 17, 2021

@greg-hellings Anyway, Thank you for merging this pull request 👍

@strider
Copy link
Contributor Author

strider commented May 17, 2021

@greg-hellings, @ssbarnea

Could you please guys make a new release including this PR as soon as possible ?

@greg-hellings
Copy link
Contributor

@greg-hellings

It could happen and it's called a human mistake IMO. We should have only one default driver declared in base config file(s) and could possibly be overriden through the molecule.yml file of your scenarios.

I disagree. I can totally see having a default one that I use on my development rig that has lots of things configured, including running tests with Vagrant/Libvirt and an additional file that I include during CI runs that overrides it to use Vagrant/VirtualBox or the like.

Btw, I still don't understand why we are able to pass multiple base config files to molecule ... Isn't one just enough? :/

Molecule does a deep-merging when multiple are found. It could make sense to have a base option to configure things like dependency options, ansible.cfg options, and verifier options. Then include different files based on being on a Developer machine, different CI environments, stage, etc. It's possible - I don't know that it's common, but it makes sense in some complex setups.

openstack-mirroring pushed a commit to openstack-archive/tripleo-validations that referenced this pull request May 19, 2021
[1] has been merged and released[2] in upstream tox-ansible and it is now
able to manage global molecule configuration. The workaround, which
consisted in adding the molecule driver name in each scenarios
molecule.yml files, is not necessary anymore.

This patch also removes all the relative symlink to the Dockerfile and
adds directly in the global molecule configuration file.

[1] ansible/tox-ansible#89
[2] https://github.com/ansible-community/tox-ansible/releases/tag/v1.5.0

Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
Change-Id: I259c17b7a49ff5bf3476df4da399cc4b2782403d
openstack-mirroring pushed a commit to openstack-archive/validations-common that referenced this pull request May 19, 2021
[1] has been merged and released[2] in upstream tox-ansible and it is now
able to manage global molecule configuration. The workaround, which
consisted in adding the molecule driver name in each scenarios
molecule.yml files, is not necessary anymore.

This patch also removes all the relative symlink to the Dockerfile and
adds directly in the global molecule configuration file.

[1] ansible/tox-ansible#89
[2] https://github.com/ansible-community/tox-ansible/releases/tag/v1.5.0

Change-Id: I8ac3f731c9d6af983dd902fc94e06a07c2ab9954
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
openstack-mirroring pushed a commit to openstack/openstack that referenced this pull request May 19, 2021
* Update validations-common from branch 'master'
  to ae6c7e506d890a9af4cf6d7be5d8aa56f7ee31e8
  - Merge "Remove workaround for tox-ansible and global molecule config"
  - Remove workaround for tox-ansible and global molecule config
    
    [1] has been merged and released[2] in upstream tox-ansible and it is now
    able to manage global molecule configuration. The workaround, which
    consisted in adding the molecule driver name in each scenarios
    molecule.yml files, is not necessary anymore.
    
    This patch also removes all the relative symlink to the Dockerfile and
    adds directly in the global molecule configuration file.
    
    [1] ansible/tox-ansible#89
    [2] https://github.com/ansible-community/tox-ansible/releases/tag/v1.5.0
    
    Change-Id: I8ac3f731c9d6af983dd902fc94e06a07c2ab9954
    Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
openstack-mirroring pushed a commit to openstack/openstack that referenced this pull request May 19, 2021
* Update tripleo-validations from branch 'master'
  to a9a0ab6433bdbba43894e64e08cfcd347aa13207
  - Merge "Remove workaround for tox-ansible and global molecule config"
  - Remove workaround for tox-ansible and global molecule config
    
    [1] has been merged and released[2] in upstream tox-ansible and it is now
    able to manage global molecule configuration. The workaround, which
    consisted in adding the molecule driver name in each scenarios
    molecule.yml files, is not necessary anymore.
    
    This patch also removes all the relative symlink to the Dockerfile and
    adds directly in the global molecule configuration file.
    
    [1] ansible/tox-ansible#89
    [2] https://github.com/ansible-community/tox-ansible/releases/tag/v1.5.0
    
    Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
    Change-Id: I259c17b7a49ff5bf3476df4da399cc4b2782403d
openstack-mirroring pushed a commit to openstack-archive/tripleo-validations that referenced this pull request Jun 18, 2021
[1] has been merged and released[2] in upstream tox-ansible and it is now
able to manage global molecule configuration. The workaround, which
consisted in adding the molecule driver name in each scenarios
molecule.yml files, is not necessary anymore.

This patch also removes all the relative symlink to the Dockerfile and
adds directly in the global molecule configuration file.

[1] ansible/tox-ansible#89
[2] https://github.com/ansible-community/tox-ansible/releases/tag/v1.5.0

Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
Change-Id: I259c17b7a49ff5bf3476df4da399cc4b2782403d
(cherry picked from commit c551910)
openstack-mirroring pushed a commit to openstack-archive/tripleo-validations that referenced this pull request Jun 23, 2021
[1] has been merged and released[2] in upstream tox-ansible and it is now
able to manage global molecule configuration. The workaround, which
consisted in adding the molecule driver name in each scenarios
molecule.yml files, is not necessary anymore.

This patch also removes all the relative symlink to the Dockerfile and
adds directly in the global molecule configuration file.

[1] ansible/tox-ansible#89
[2] https://github.com/ansible-community/tox-ansible/releases/tag/v1.5.0

Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
Change-Id: I259c17b7a49ff5bf3476df4da399cc4b2782403d
(cherry picked from commit c551910)
(cherry picked from commit f3cba82)
(cherry picked from commit 12dd20e3b55e96d88468531f8752b9bcea21360b)
openstack-mirroring pushed a commit to openstack-archive/tripleo-validations that referenced this pull request Jun 24, 2021
[1] has been merged and released[2] in upstream tox-ansible and it is now
able to manage global molecule configuration. The workaround, which
consisted in adding the molecule driver name in each scenarios
molecule.yml files, is not necessary anymore.

This patch also removes all the relative symlink to the Dockerfile and
adds directly in the global molecule configuration file.

[1] ansible/tox-ansible#89
[2] https://github.com/ansible-community/tox-ansible/releases/tag/v1.5.0

Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
Change-Id: I259c17b7a49ff5bf3476df4da399cc4b2782403d
(cherry picked from commit c551910)
(cherry picked from commit f3cba82)
openstack-mirroring pushed a commit to openstack-archive/tripleo-validations that referenced this pull request Jul 12, 2021
[1] has been merged and released[2] in upstream tox-ansible and it is now
able to manage global molecule configuration. The workaround, which
consisted in adding the molecule driver name in each scenarios
molecule.yml files, is not necessary anymore.

This patch also removes all the relative symlink to the Dockerfile and
adds directly in the global molecule configuration file.

[1] ansible/tox-ansible#89
[2] https://github.com/ansible-community/tox-ansible/releases/tag/v1.5.0

Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
Change-Id: I259c17b7a49ff5bf3476df4da399cc4b2782403d
(cherry picked from commit c551910)
(cherry picked from commit f3cba82)
(cherry picked from commit 12dd20e3b55e96d88468531f8752b9bcea21360b)
(cherry picked from commit 76eb983e9842e38a95940787af2fdda540e2a83b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue/PR relates to a feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tox-ansible fails in driver detection when using a shared molecule config file in the project level
4 participants