--- # systemd's sandboxing directives (ProtectSystem, PrivateTmp, PrivateDevices and # the Protect* family) need a mount namespace, which needs CAP_SYS_ADMIN. The # test container is unprivileged on purpose, so without this drop-in the unit # fails with status 226/NAMESPACE. The drop-in resets only those directives; # the user, capabilities, environment file and ExecStart under test are the # role's own. The sandbox itself is therefore not covered by this scenario. # # User is reset too. The switch to User=traefik fails in the unprivileged container # (exit 217/USER, "Failed to keep CAP_SYS_ADMIN"), so the unit runs as root here. # The traefik user, the file ownership checks and the other unit settings are # still asserted. - name: Prepare hosts: all gather_facts: false tasks: - name: Create the unit drop-in directory ansible.builtin.file: path: /etc/systemd/system/traefik.service.d state: directory mode: "0755" - name: Disable the namespace-based sandboxing for the unprivileged container ansible.builtin.copy: dest: /etc/systemd/system/traefik.service.d/molecule.conf mode: "0644" content: | [Service] ProtectSystem=no ProtectHome=no PrivateTmp=no PrivateDevices=no ProtectKernelModules=no ProtectKernelTunables=no ReadWritePaths= User=