molecule icon indicating copy to clipboard operation
molecule copied to clipboard

Support for cgroupns parameter

Open bngsudheer opened this issue 2 years ago • 7 comments

So that values like --cgroupns=host can be used to spin up container with systemd support.

bngsudheer avatar Sep 20 '22 10:09 bngsudheer

iirc, schemas fixes should be opened here : https://github.com/ansible/schemas.

apatard avatar Sep 20 '22 10:09 apatard

iirc, schemas fixes should be opened here : https://github.com/ansible/schemas.

Could you point me to the correct schema for Molecule drivers?

bngsudheer avatar Sep 20 '22 10:09 bngsudheer

iirc, schemas fixes should be opened here : https://github.com/ansible/schemas.

Could you point me to the correct schema for Molecule drivers?

I have submitted a PR here

bngsudheer avatar Sep 20 '22 10:09 bngsudheer

@apatard

iirc, schemas fixes should be opened here : https://github.com/ansible/schemas.

Per ssbarnea in this PR, https://github.com/ansible-community/molecule/pull/3638#issuecomment-1220521423

I do totally agree that we should move some of the schemas inside the projects themselves. In fact I was planning to do the same for ansible-lint and ansible-navigator, as these are quite simple. There is no more authoritative source for managing a schema than the project using it.

@bngsudheer Could you help create some examples of container using cgroupv2 in molecule repo?

https://github.com/ansible-community/molecule/blob/main/docs/examples.rst#systemd-container? Related to https://github.com/ansible-community/molecule-docker/pull/166#issuecomment-1235689840

zhan9san avatar Sep 22 '22 02:09 zhan9san

@apatard

iirc, schemas fixes should be opened here : https://github.com/ansible/schemas.

Per ssbarnea in this PR, #3638 (comment)

I do totally agree that we should move some of the schemas inside the projects themselves. In fact I was planning to do the same for ansible-lint and ansible-navigator, as these are quite simple. There is no more authoritative source for managing a schema than the project using it.

@bngsudheer Could you help create some examples of container using cgroupv2 in molecule repo?

https://github.com/ansible-community/molecule/blob/main/docs/examples.rst#systemd-container? Related to ansible-community/molecule-docker#166 (comment)

I am still testing the issue and some potential resolutions. So far, I have managed to get it to work with some Ubuntu versions. Once, I am through the tests, I will send some PRs for the documentation. Please bear with me till then.

bngsudheer avatar Sep 22 '22 06:09 bngsudheer

@bngsudheer

Are you sure it is cgroupns instead of cgroupns_mode?

Reference: https://github.com/ansible-collections/community.docker/blob/1e93feed2b9f34f3af4885d878c5dde1f51d206c/plugins/modules/docker_container.py#L51-L59

Here is what I test in https://github.com/ansible-community/molecule-docker/pull/166#issuecomment-1235689840

❯ cat molecule/default/molecule.yml
---
dependency:
  name: galaxy
driver:
  name: docker
platforms:
  - name: instance
    image: geerlingguy/docker-debian11-ansible:latest
    command: ${MOLECULE_DOCKER_COMMAND:-""}
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:rw
    pre_build_image: true
    privileged: true
    cgroupns_mode: host
provisioner:
  name: ansible
verifier:
  name: ansible

zhan9san avatar Sep 22 '22 12:09 zhan9san

@bngsudheer

Are you sure it is cgroupns instead of cgroupns_mode?

Reference: https://github.com/ansible-collections/community.docker/blob/1e93feed2b9f34f3af4885d878c5dde1f51d206c/plugins/modules/docker_container.py#L51-L59

Here is what I test in ansible-community/molecule-docker#166 (comment)

❯ cat molecule/default/molecule.yml
---
dependency:
  name: galaxy
driver:
  name: docker
platforms:
  - name: instance
    image: geerlingguy/docker-debian11-ansible:latest
    command: ${MOLECULE_DOCKER_COMMAND:-""}
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:rw
    pre_build_image: true
    privileged: true
    cgroupns_mode: host
provisioner:
  name: ansible
verifier:
  name: ansible

I have realized after the PR merge that it should be cgroupns_mode instead of cgroupns. Apparently, cgroupns is the docker CLI argument. Even with cgroupns_mode, I see it failing on fresh install of Ubuntu 22.04. Surprisingly, on a laptop with Ubuntu 22.04 which was upgraded from an older version, it is working. I am still testing things out.

bngsudheer avatar Sep 22 '22 13:09 bngsudheer

Is this this needed? If so please fix conflicts so we can merge it.

ssbarnea avatar Oct 24 '22 18:10 ssbarnea

Closing due to lack of updates

ssbarnea avatar Oct 25 '22 08:10 ssbarnea