diff --git a/.travis.yml b/.travis.yml index 28a7223..2134a16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,3 +15,6 @@ script: # Verify Ansible is available in the container. - docker exec --tty test-container env TERM=xterm ansible --version + + # Verify that Systemd is working + - docker exec --tty test-container env TERM=xterm sh -c 'systemctl status --no-pager' diff --git a/Dockerfile b/Dockerfile index f1f4767..b2c9d63 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,19 @@ RUN sed -i 's/^\($ModLoad imklog\)/#\1/' /etc/rsyslog.conf # Fix potential UTF-8 errors with ansible-test. RUN locale-gen en_US.UTF-8 +# Cleanup unwanted systemd files +# See https://hub.docker.com/_/centos/ and https://github.com/ansible/molecule/issues/1104 +RUN find /lib/systemd/system/sysinit.target.wants/* ! -name systemd-tmpfiles-setup.service -delete; \ +rm -f /lib/systemd/system/multi-user.target.wants/*; \ +rm -f /etc/systemd/system/*.wants/*; \ +rm -f /lib/systemd/system/local-fs.target.wants/*; \ +rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ +rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ +rm -f /lib/systemd/system/basic.target.wants/*; \ +rm -f /lib/systemd/system/anaconda.target.wants/*; \ +rm -f /lib/systemd/system/systemd*udev*; \ +rm -f /lib/systemd/system/getty.target + # Install Ansible via Pip. RUN pip3 install $pip_packages @@ -30,10 +43,5 @@ RUN chmod +x initctl_faker && rm -fr /sbin/initctl && ln -s /initctl_faker /sbin RUN mkdir -p /etc/ansible RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts -# Remove unnecessary getty and udev targets that result in high CPU usage when using -# multiple containers with Molecule (https://github.com/ansible/molecule/issues/1104) -RUN rm -f /lib/systemd/system/systemd*udev* \ - && rm -f /lib/systemd/system/getty.target - VOLUME ["/sys/fs/cgroup", "/tmp", "/run"] CMD ["/lib/systemd/systemd"]