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

Container drivers are not working #4128

Closed
7 tasks done
mrbrandao opened this issue Feb 1, 2024 · 0 comments · Fixed by #4126
Closed
7 tasks done

Container drivers are not working #4128

mrbrandao opened this issue Feb 1, 2024 · 0 comments · Fixed by #4126

Comments

@mrbrandao
Copy link
Contributor

mrbrandao commented Feb 1, 2024

Prerequisites

  • This was not already reported in the past (duplicate check)
  • It does reproduce it with code from main branch (latest unreleased version)
  • I include a minimal example for reproducing the bug
  • The bug is not trivial, as for those a direct pull-request is preferred
  • Running pip check does not report any conflicts
  • I was able to reproduce the issue on a different machine
  • The issue is not specific to any driver other than 'default' one

Environment

molecule 6.0.3 using python 3.11 
    ansible:2.16.3
    default:6.0.3 from molecule
    podman:2.0.3 from molecule_podman requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0

What happened

  1. When using molecule init scenario -d podman the driver is not declared in the molecule.yml
  2. When running the molecule create it will create using the default driver instead, of the one specified in init command.
  3. After manually adding the driver in molecule.yml, the create and destroy plays, will still not use the declared driver, skipping all tasks. when removing the default create.yml and destroy.yml, then it will behavior as intended.

What I expect to happen?

  1. The command molecule init scenario -d podman to create the proper molecule.yml with the driver declared
  2. The command molecule create to create the container using the specified driver
  3. The command molecule destroy to destroy the running container created.

Reproducing example

python3.11 -m venv .venv
source .venv/bin/activate
pip install ansible-core molecule molecule-podman
ansible-galaxy collection init foo.example
cd foo/example/roles
ansible-galaxy role init bar
cd bar
molecule init scenario -d podman
molecule create
molecule destroy
@mrbrandao mrbrandao added the new label Feb 1, 2024
@audgirka audgirka removed the new label Feb 7, 2024
ssbarnea added a commit that referenced this issue Feb 8, 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:

```bash
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:
```yaml
---
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:

```bash
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:

```bash
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:

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

Fixes: #4128

Co-authored-by: Sorin Sbarnea <ssbarnea@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants