在无人机CI中测试Ansible角色,SystemD服务不起作用



测试Ansible角色时,我的Systemd Services无法启动。这是我遇到的错误,

TASK [memcached : Packages Present] ********************************************
changed: [localhost] => (item=[u'memcached', u'libmemcached'])
TASK [memcached : Service Enabled] *********************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Could not find the requested service memcached: host"}

my .drone.yml


pipeline:
  build:
    image: samdoran/centos7-ansible
    privileged: true
    commands:
      - echo 'sslverify=0' >> /etc/yum.conf
      - yum install -y redhat-lsb-core python-devel openldap-devel git gcc gcc-c++ python2-pip
      - pip install -U pip tox
      - tox

我的docker-compose.yml

version: '2'
services:
  drone-server:
    image: drone/drone:0.8
    ports:
      - 8000:8000
      - 9000
    volumes:
      - /var/lib/drone:/var/lib/drone/
      - /etc/ssl/certs/ca-bundle.crt:/etc/ssl/certs/ca-certificates.crt
    restart: always
    environment:
      - DRONE_OPEN=true
      - DRONE_HOST=https://example.server
      - DRONE_ADMIN=drone
      - DRONE_VOLUME=/etc/ssl/certs/ca-bundle.crt:/etc/ssl/certs/ca-certificates.crt
      - DRONE_GOGS_GIT_USERNAME=drone
      - DRONE_GOGS_GIT_PASSWORD=XXXXXXXX
      - DRONE_GOGS=true
      - DRONE_GOGS_URL=https://example.gogs
      - DRONE_SECRET=${DRONE_SECRET}
  drone-agent:
    image: drone/agent:0.8
    command: agent
    restart: always
    depends_on:
      - drone-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_SERVER=drone-server:9000
      - DRONE_SECRET=${DRONE_SECRET}
      - DOCKER_API_VERSION=1.24

我试图手动执行一个备忘录的安装,从我的Fedora Workstation启动基本CentOS:7个Docker容器,并且服务在私人时的预期开始。无人机Dockers正在RHEL 7主机上运行。我已经将存储库设置为无人机接口中的信任。

/sys/fs/cgroup的读取权添加到您的volumes部分: - /sys/fs/cgroup:/sys/fs/cgroup:ro

这里的完整说明。

事实证明,问题与输入程序的实现有关,如果您覆盖它不像预期的那样启动的命令。因此,解决方法是启动容器,分离,然后将命令发送到运行的容器。

---
pipeline:
  system:
    image: cyberpunkspike/docker-centos7-ansible:latest
    labels:
      com.amtrustna.it.infr.serv.system: "true"
    cap_add:
      - SYS_ADMIN
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:ro
    init: /usr/lib/systemd/systemd
    detach: true
  exec:
    image: docker
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    commands:
      - CONTAINER_ID="$(docker ps -qf "label=com.amtrustna.it.infr.serv.system")"
      - test -n "$CONTAINER_ID" || { echo "Container Not Found"; exit 1 ;}
      - docker exec -t "$CONTAINER_ID" sh -c "export TERM=xterm-256color; cd $PWD && tox"

有时您可以通过用systemctl.py替换init-command来丢弃整个特权/系统。它甚至可能给您不同的错误诊断。

相关内容

  • 没有找到相关文章

最新更新