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

Adding molecule template based on driver.name #4126

Merged
merged 3 commits into from Feb 8, 2024

Conversation

mrbrandao
Copy link
Contributor

@mrbrandao mrbrandao commented Jan 31, 2024

In past when using cookicuter some molecule templates where straight forward to use delegated container drivers, such as podman and docker. Since it was gone, every time a new scenario is created it's needed to configure the templates again, by adding the image and the driver, also cleaning the files that will not be used by default such as create.yml and destroy.yml

If we can just init the scenario with a basic template that just works as we had in version 5 would be great.

Here I'm bringing back some of this functionality, e.g:

ansible-galaxy collection init foo.example
cd foo/example/roles
ansible-galaxy role init bar
cd bar
molecule init scenario -d podman podman

This will create a molecule.yml as the following:

---
driver:
  name: podman
platforms:
  - name: instance
    image: quay.io/centos/centos:stream8
    pre_build_image: true

it will also create the molecule scenario with just the molecule.yml and the converge.yml. e.g:

tree ./molecule/podman/
./molecule/podman/
├── converge.yml
└── molecule.yml

If the scenario was any driver different than podman, docker or containers it will create the scenario with all the default templates from the current data structure, e.g:

molecule init scenario
tree ./molecule/
./molecule/
├── default
│   ├── converge.yml
│   ├── create.yml
│   ├── destroy.yml
│   └── molecule.yml

The final scenario tree, after the commands molecule init scenario -d podman podman and molecule init scenario will look like:

tree ./molecule/
./molecule/
├── default
│   ├── converge.yml
│   ├── create.yml
│   ├── destroy.yml
│   └── molecule.yml
└── podman
    ├── converge.yml
    └── molecule.yml

Fixes: #4128

In past when using cookicuter was possible to have templates based on a
set of variables.
This commit adds a default image entry when using 'containers',
'podman' or 'docker' drivers.
The `init-scenario.yml` also will by default only copy the create.yml
and destroy.yml if not using one of those container drivers.
@mrbrandao mrbrandao changed the title Adding molecule template based on driver.name Adding molecule template based on driver.name - issue #4128 Feb 1, 2024
@mrbrandao mrbrandao changed the title Adding molecule template based on driver.name - issue #4128 Adding molecule template based on driver.name Feb 1, 2024
@ssbarnea ssbarnea added the bug label Feb 5, 2024
@ssbarnea ssbarnea self-requested a review February 5, 2024 11:42
@ssbarnea ssbarnea added minor and removed bug labels Feb 5, 2024
@ssbarnea ssbarnea changed the title Adding molecule template based on driver.name Adding molecule template based on driver.name Feb 8, 2024
@ssbarnea ssbarnea merged commit 203f06d into ansible:main Feb 8, 2024
13 checks passed
@mrbrandao mrbrandao deleted the create-from-driver branch February 8, 2024 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Container drivers are not working
2 participants