-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Systemd not starting - Failed to connect to bus: No such file or directory #18
Comments
Fyi, this is an issue between Docker and newer systemd versions (248 and up): systemd/systemd#19245. One possible workaround is to boot with the kernel parameter |
Thank you for pointing this out, I wouldn't have thought the problem was systemd. |
I'm experiencing this problem as well in Ubuntu 21.10 where systemd is version 248... |
I had a similar issue on MacOS with Docker Desktop (which recently moved to cgroup v2). The only solution I found was to install a beta build mentioned in a github issue and revert back to cgroup v1. |
If you are using docker for mac workaround can be to go back on cgroup v1 # Stop running Docker
test -z "$(docker ps -q 2>/dev/null)" && osascript -e 'quit app "Docker"'
# Install jq and moreutils so we can merge into the existing json file
brew install jq moreutils
# Add the needed cgroup config to docker settings.json
echo '{"deprecatedCgroupv1": true}' | \
jq -s '.[0] * .[1]' ~/Library/Group\ Containers/group.com.docker/settings.json - | \
sponge ~/Library/Group\ Containers/group.com.docker/settings.json
# Restart docker desktop
open --background -a Docker ^ copy pasted from: docker/for-mac#6073 (comment) |
I'm having a similar issue running on Pop!_OS 21.04. Trying to see if we can migrate our existing molecule testing pipelines from vagrant/virtualbox setups to a docker based methodology. Using this image I was unable to test a role because it wants to enable a My setup
I'm able to create an instance just fine, but when trying to login (with the same
I can manually exec into the container.
|
By booting with that kernel parameter you mean to boot the main OS, right? |
I am using Docker for Mac and I am getting the same error. Using this version
|
Hi @gomex, This is a molecule problem, the temporary solution is to just copy that command manually and running it separately. |
Hi @gomex, the resolution above is technically true you just need to install the previous version to get this running molecule==3.5.2 works fine. Just uninstall the module then reinstall it with that version number and you're fine. |
I've started getting this too, on latest molecule with latest Docker Desktop for Mac :( |
Looks like we need to move everything to some kvm like virtualbox or vmware where we have full kvm. |
There are two combined issues, molecule issue is mentioned here and this will be seen throughout providers i believe. Docker issue is related to systemd not starting as mentioned here I believe a resolution to molecule is pinning the version within the docker build process for now whilst it gets resolved and for the docker issue put a note on the README about a required desktop docker version for MacOS. |
@kozicpetar I've been a fan of using virtualbox provider for molecule testing. Been using it with my compnay for over a year now. Just hard because I don't think something that would work for github actions unless I'm wrong. Github actions seems to be based on containers from what I understand. |
@NiftyMist yes, you are in the right. My primary problem is running tests on GHA because support containers. @geerlingguy Jeff, do you have some idea how we can sort this problem ? |
You saved my life :-) |
I sort problem on my Mac with Docker desktop version I built new container for Ubuntu and Debian without This is Dockerfile for Ubuntu 20.04:
I do same for Debian 11 and Ubuntu 18.04 My molecule file, you can see there is commented
After this, all my roles with systemd works as expected. |
@kozicpetar I can confirm that using your Dockerfile I am also able to run systemd specific tasks on Ansible using Molecule on my Mac Mini M1. |
Starting from the fact that I have no problem when running molecule tests in GitHub Actions (in ubuntu virtual machines), the solution of @kozicpetar still does not work for me: neither in Ubuntu nor in Fedora. What works for me is the following one (which I was also suggesting in #18 (comment)): FROM ubuntu:22.04
LABEL maintainer="Lorenzo Bettini"
ENV container docker
ENV LC_ALL C
ENV DEBIAN_FRONTEND noninteractive
# software-properties-common is required for codename in ppa to work automatically
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
software-properties-common \
python3 sudo bash ca-certificates iproute2 python3-apt \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man
ADD https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl3.py /usr/bin/systemctl
RUN chmod +x /usr/bin/systemctl
CMD ["/usr/bin/systemctl"] With this one, my playbooks and tasks that enable or disable services (even at the user level) work in molecule. |
This problem has been occurred for me too. After two days of troubleshooting, I finally resolve my own issue. I'm using debian 11 operating system and as docker documentation said, ( this link ) from debian 11 to latest , cgroup v2 is using. So I guessed that the problem should be from changing in version of cgroup . Because my co-worker that uses ubuntu 20.04 didn't face such problem. BTW, after so many tries I decided to mount Hope it will be helpfull for others. |
I tried the various solutions listed on this thread and unfortunately none of them worked for me on Arch Linux. However after a lot of digging, I found that setting the
Molecule platform configuration: platforms:
- name: instance
image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
|
* Remove composer update hook to also run composer update in control site. * put back bin-tools so they are available in bin/ and fix path lookup, aligning with composer's new bin trick. * Put back Ansible playbook run in docker build command so we can save images. * Fix up docker-systemd-prepare file. * Adding run-quiet script to main scripts. * Run both devshop-install-prerequisites (to install ansible) AND docker-systemd-prepare to ensure fully functioning container. * Default to ubuntu1804 when using docker/docker-compose.yml * fix entry points, missing env vars in docker compose, build args, etc. * Fix robo up and build. * output more debugging info in GitHub actions. * Get systems working right in GitHub actions and locally, by REMOVING the systems volume! ¯\_(ツ)_/¯ * thanks geerlingguy/docker-ubuntu2004-ansible#18 (comment)
* Remove composer update hook to also run composer update in control site. * put back bin-tools so they are available in bin/ and fix path lookup, aligning with composer's new bin trick. * Put back Ansible playbook run in docker build command so we can save images. * Fix up docker-systemd-prepare file. * Adding run-quiet script to main scripts. * Run both devshop-install-prerequisites (to install ansible) AND docker-systemd-prepare to ensure fully functioning container. * Default to ubuntu1804 when using docker/docker-compose.yml * fix entry points, missing env vars in docker compose, build args, etc. * Fix robo up and build. * output more debugging info in GitHub actions. * Get systems working right in GitHub actions and locally, by REMOVING the systems volume! ¯\_(ツ)_/¯ * thanks geerlingguy/docker-ubuntu2004-ansible#18 (comment)
* Remove composer update hook to also run composer update in control site. * put back bin-tools so they are available in bin/ and fix path lookup, aligning with composer's new bin trick. * Put back Ansible playbook run in docker build command so we can save images. * Fix up docker-systemd-prepare file. * Adding run-quiet script to main scripts. * Run both devshop-install-prerequisites (to install ansible) AND docker-systemd-prepare to ensure fully functioning container. * Default to ubuntu1804 when using docker/docker-compose.yml * fix entry points, missing env vars in docker compose, build args, etc. * Fix robo up and build. * output more debugging info in GitHub actions. * Get systems working right in GitHub actions and locally, by REMOVING the systems volume! ¯\_(ツ)_/¯ * thanks geerlingguy/docker-ubuntu2004-ansible#18 (comment)
* Remove composer update hook to also run composer update in control site. * put back bin-tools so they are available in bin/ and fix path lookup, aligning with composer's new bin trick. * Put back Ansible playbook run in docker build command so we can save images. * Fix up docker-systemd-prepare file. * Adding run-quiet script to main scripts. * Run both devshop-install-prerequisites (to install ansible) AND docker-systemd-prepare to ensure fully functioning container. * Default to ubuntu1804 when using docker/docker-compose.yml * fix entry points, missing env vars in docker compose, build args, etc. * Fix robo up and build. * output more debugging info in GitHub actions. * Get systems working right in GitHub actions and locally, by REMOVING the systems volume! ¯\_(ツ)_/¯ * thanks geerlingguy/docker-ubuntu2004-ansible#18 (comment)
This role is extremely simple, and these are a royal pain to get running because of systemd incompatibility issues with cgroups v2. See: geerlingguy/docker-ubuntu2004-ansible#18
After upgrading AKS to 1.25 (which also upgraded Ubuntu image on K8s nodes from 18.04 to 22.04, hence upgraded cgroups to v2) we encountered the above issue as well and neither solution from this thread worked. After some extensive googling and thanks to this answer I came up with this: FROM ubuntu:20.04
ARG DEBIAN_FRONTEND=noninteractive
ENV pip_packages "ansible"
# Install dependencies.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
build-essential \
locales \
libffi-dev \
libssl-dev \
libyaml-dev \
python3-dev \
python3-setuptools \
python3-pip \
python3-yaml \
software-properties-common \
rsyslog systemd systemd-cron sudo iproute2 \
&& apt-get clean \
&& rm -Rf /var/lib/apt/lists/* \
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man
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
# Install Ansible via Pip.
RUN pip3 install $pip_packages
# Install Ansible inventory file.
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/multi-user.target.wants/* \
/etc/systemd/system/*.wants/* \
/lib/systemd/system/local-fs.target.wants/* \
/lib/systemd/system/sockets.target.wants/*udev* \
/lib/systemd/system/sockets.target.wants/*initctl* \
/lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup* \
/lib/systemd/system/systemd-update-utmp* \
/lib/systemd/system/getty.target
CMD [ "/lib/systemd/systemd", "log-level=info", "unit=sysinit.target" ] And after building the image, run it like this: Note: it requires host OS to support cgroups v2 (you can check it by running And after f**king hours of debugging molecule and browsing its source code, we finally managed to get it working. platforms:
- name: instance
image: <image name>
pre_build_image: true
privileged: true
cgroup_parent: docker.slice
cgroupns_mode: private
override_command: false
capabilities:
- SYS_ADMIN
security_opts:
- seccomp=unconfined
tmpfs:
- /run
- /tmp
- /run/lock This crap: |
I solved the problem changing the volume configuration from /sys/fs/cgroup:/sys/fs/cgroup:ro to /sys/fs/cgroup:/sys/fs/cgroup:rw. Molecule platform configuration: platforms:
- name: instance
image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
privileged: true
pre_build_image: true |
|
Use: docker build -t molecule-debian-bookworm . molecule test It works to use the Ubuntu base image in the Dockerfile, too. geerlingguy/docker-ubuntu2004-ansible#18 (comment) That's where I got the config from. Signed-off-by: meows <[email protected]>
Hi everyone, I'm trying to test a role that installs postgresql using the docker driver for molecule but it seems that systemd is not starting.
Symptoms
(this container has been created using
molecule create && molecule login
)Molecule configuration
My setup
ansible
: 2.11.3molecule
: 3.4.0molecule-docker
: 0.2.4python
: 3.9docker
: 20.10.8OS
: ArchlinuxThe text was updated successfully, but these errors were encountered: