molecule
molecule copied to clipboard
Expose --base-config as an environment variable
Issue Type
- Feature request
Molecule and Ansible details
ansible --version && molecule --version
ansible 2.7.5
config file = None
configured module search path = ['/Users/stiilikainen/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /Users/stiilikainen/.local/share/virtualenvs/a9y-iac-GOXhPMtO/lib/python3.7/site-packages/ansible
executable location = /Users/stiilikainen/.local/share/virtualenvs/a9y-iac-GOXhPMtO/bin/ansible
python version = 3.7.2 (default, Dec 27 2018, 07:35:06) [Clang 10.0.0 (clang-1000.11.45.5)]
molecule, version 2.19.0
Molecule installation method (one of):
- pip
Ansible installation method (one of):
- pip
Desired Behavior
I would like the --base-config option to be exposed as an environment variable. The use case would be that I could put this variable in .env.yml
in my project root and thus have a project-specific base config that I wouldn't have to specify on the command line.
MOLECULE_BASE_CONFIG=./base.yml
Directory structure this would support:
project/
- .env.yml
- base.yml
- molecule/
- scenario1/
- molecule.yml
- scenario2/
- molecule.yml
Hi @tiilikainen, thanks for raising. Right now, you can do this by treating your molecule/default/molecule.yml
as the base configuration and then passing relative paths to shared configurations across all scenarios. Is this not solving your need? Can you explain further why you might need this central configuration file?
Ah, sorry, I misunderstood that we already had this --base-config
! My question above still stands but is unrelated for this issue ;) Yes, in this case, it looks like we should expose this as an env var. I've just seen a bug related to the configuration via https://github.com/ansible/molecule/issues/1661.
@tiilikainen, in your usage of this option, are you seeing anything like what is being reported in #1661?
Hi,
-
I have a few interrelated roles from which I’d like to abstract a common base config.
-
Yes, I’ve been able to replicate that bug.
Would be also possible to have this option in configuration?
When I have monorepo with multiple roles with one common molecule.yml
file, I would like to run for example only molecule converge
instead of molecule --base-config ../../molecule-common/molecule.yml converge
.
I can also see sourcing
some env
file as solution, but this is kinda same as having a configuration file. But with configuration file I don't need to do this one source
manual step.
Fancy submitting a PR @Lirt? Both requests seem reasonable to me ...
Anyone know if this have been implemented since May? We would also like this, since we have a mono-repo..
One way how to do that is alias moleculeb="molecule --base-config .config/molecule/config.yml"
Basically just by creating custom alias. It can be temporary in current terminal or permanently in your .profile
, .zprofile
or what have you.
Then just use it like moleculeb converge -s dev -- --limit workstations --tags nvim
But for sure, exposed MOLECULE_BASE_CONFIG
would be much much nicer and idiomatic solution.