How to override entrypoint for molecule[podman] containers

1.2k views Asked by At

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?

1

There are 1 answers

0
Lukas Käppeli On

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