Interview Prep/Ansible/Cloud, AWX, Windows and Molecule

Molecule converge fails on service tasks with `System has not been booted with systemd as init system (PID 1). Can't operate.`

AdvancedTroubleshootingCloud, AWX, Windows and Molecule
Answer

Likely causes → The test container runs a shell or sleep as PID 1, not systemd. On cgroup v2 hosts (Ubuntu 22.04+ runners, recent Docker Desktop), systemd containers also need the right cgroup setup.

Fix →

platforms:
  - name: rocky9
    image: geerlingguy/docker-rockylinux9-ansible:latest
    command: /usr/sbin/init
    privileged: true
    cgroupns_mode: host
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:rw
    pre_build_image: true

Prevent → Use images built for systemd testing, and keep a known-good molecule.yml template that every role copies.

All Ansible questions Roadmap: Ansible

More on Cloud, AWX, Windows and Molecule