Gitlab-runner / Docker / systemd
Hello,
First, I'm sorry for my bad english.
I am in the process of setting up a platform (ci) to test my ansible roles.
My architecture is: gitlab -> gitlab-runner -> docker.
When I push my project, I have the following error:
RUNNING HANDLER [sftp: restart_sshd] ****************************************** fatal: [localhost]: FAILED! => {"changed": false, "cmd": "/ usr / bin / systemctl", "msg": "Failed to >get D-Bus connection: Operation not permitted", "rc": 1, "stderr": "Failed to get D-Bus connection: >Operation not permitted \ n", "stderr_lines": ["Failed to get D-Bus connection: Operation not permitted"], "stdout": "", "stdout_lines": []} to retry, use: --limit @ / builds / ansible / sftp / sftp / tests / test.retry'''
I know that by default, systemd is disabled in docker containers for security, but I need it.
I made a lot of settings, but it did not succeed. My configuration is as follows:
[root@localhost ~]# vi /etc/gitlab-runner/config.toml
[[runners]]
name = "runner_two"
url = "https://gitlab.example.sn/"
token = "dfgbgr4E556890973fetgch"
executor = "docker"
[runners.docker]
tls_verify = false
image = "soume/centos7-base"
privileged = true security_opt = ["seccomp:unconfined"]
disable_cache = false
volumes = ["/cache", "/sys/fs/cgroup:/sys/fs/cgroup:ro"]
pull_policy = "if-not-present"
shm_size = 0
[runners.cache]
My Dockerfile
FROM centos:latest
MAINTAINER "soume" soume@gitlab.example.sn
ENV container=docker
RUN yum -y update; yum clean all
RUN yum -y install epel-release
RUN yum -y install ansible
RUN yum -y install git
RUN yum -y install openssh openssh-server openssh-clients openssl-libs
RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''
RUN yum -y install systemd; yum clean all; \
(cd /lib/systemd/system/sysinit.target.wants/; for i in ; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
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/*;
RUN systemctl enable sshd.service
VOLUME [ “/sys/fs/cgroup” ]
CMD [“/usr/sbin/init”]
Would someone have a solution?
soume,