Docker cgroups2 and cgroupns support in Molecule

538 views
Skip to first unread message

Sudheer Satyanarayana

unread,
Sep 20, 2022, 6:08:03 AM9/20/22
to ansible...@googlegroups.com
Hello,

I have encountered an issue with using systemd in docker. I have a role
with a task like this:

- name: Start and enable apache2
  systemd:
    name: apache2
    state: started
    enabled: true

And it fails like this:

TASK [acme.molecule_reference_role : Start and enable apache2]
*****************
fatal: [ubuntu]: FAILED! => {"changed": false, "msg": "Service is in
unknown state", "status": {}}

I realize on the command like, this can be worked around with:

docker run -it --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:rw
--cgroupns=host geerlingguy/docker-ubuntu2204-ansible:latest

basically mounting /sys/fs/cgroup with rw option and adding the
parameter cgroupns with value host.

But I am unable to pass the parameter cgroupns in molecule. I tried like
this:

platforms:
  - name: ubuntu
    image: geerlingguy/docker-ubuntu2204-ansible
    privileged: true
    cgroupns: host
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:rw

But it does not work.

I also see the open issue in the Molecule project
https://github.com/ansible-community/molecule/discussions/3349 from Dec
2021.

Is there a plan to support the flag cgroupns in Molecule? Is a new PR
expected?

-

Sudheer

Reply all
Reply to author
Forward
0 new messages