1

molecule can create containers or VMs to test ansible roles.

I am using containers which run systemd to test the role in multiple environments.

To run systemd I am using the command: option but in one container i cannot do that because of the ENTRYPOINT set on the container. This is the relevant extract from molecule/default/molecule.yml:

---
driver:
  name: podman
platforms:
  - name: some_platform
    image: "docker.io/someuser/some_image:version"
    entrypoint: /lib/systemd/systemd    # does not work on molecule[podman]
  - name: some_platform
    image: "docker.io/someuser/some_image:version"
    entrypoint:
      - /lib/systemd/systemd    # does not work on molecule[podman]
  - name: some_platform
    image: "docker.io/someuser/some_image:version"
    # I thought maybe this would work because of
    # https://github.com/containers/podman/issues/4595
    entrypoint: ["/lib/systemd/systemd"]    # does not work on molecule[podman]

Is there any way to override the entrypoint from molecule.yml and podman driver?

xihh
  • 169
  • 2
  • 12
  • https://github.com/ansible-community/molecule-podman/blob/main/README.rst says _This plugin requires containers.podman collection to be present:_ [Doc](https://github.com/containers/ansible-podman-collections/blob/f1d68c0fbdba65169d8a557269049cc231a7db0a/plugins/modules/podman_container.py#L145-L148) for parsing _command_. [Doc](https://github.com/containers/ansible-podman-collections/blob/f1d68c0fbdba65169d8a557269049cc231a7db0a/plugins/modules/podman_container.py#L248-L251) for parsing _entrypoint_. It seems _entrypoint_ expects a string. Strange that it doesn't work. – Erik Sjölund Apr 24 '22 at 04:53

1 Answers1

0

I had the same issue and solved it by manually running the podman container before launching molecule converge. I'm using "docker.io/geerlingguy/docker-ubuntu2004-ansible", which works perfectly fine :D

Thus, in your case, first start a podman container named "some_platform"

sudo podman run --name some_platform -d docker.io/someuser/some_image:version

Adjust your converge.yml file as follows:

--
driver:
  name: podman
  platforms:
  - name: some_platform
    image: "docker.io/someuser/some_image:version"
    pre_build_image: true

And finally, run your molecule converge:

sudo molecule converge