【问题标题】:Error When Testing Archlinux with Ansible Molecule使用 Ansible Molecule 测试 Archlinux 时出错
【发布时间】:2021-05-01 22:16:36
【问题描述】:

我正在尝试为我的各种 Ansible 角色添加对 Archlinux 的支持。我正在尝试使用 Ansible Molecule 测试角色。所有其他发行版在 Molecule 上都可以正常工作,但是在测试 Archlinux 时,我在 Molecule 上运行了这个错误。以下是技术细节:

molecule.yml

---
dependency:
  name: galaxy
  options:
    role-file: requirements.yml
    requirements-file: requirements.yml
driver:
  name: docker
platforms:
  - name: Archlinux-Latest
    image: megabytelabs/ansible-molecule-archlinux:latest
    command: /sbin/init
    tmpfs:
      - /run
      - /tmp
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:ro
    priviledged: true
    pre_build_image: true
provisioner:
  name: ansible
  connection_options:
    ansible_connection: docker
    ansible_password: ansible
    ansible_ssh_user: ansible
  inventory:
    group_vars:
      all:
        docker_molecule_test: true
  options:
    vvv: true
  playbooks:
    converge: converge.yml
verifier:
  name: ansible

Dockerfile

FROM archlinux:latest
LABEL maintainer="help@megabyte.space"

ENV container docker

# Source: https://github.com/CarloDePieri/docker-archlinux-systemd/blob/master/Dockerfile
# Source: https://github.com/CarloDePieri/docker-archlinux-ansible/blob/master/Dockerfile

RUN set -ex \
  && pacman -Syu --noconfirm \
      python \
      sudo \
  && pacman -Scc --noconfirm \
  && (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/*; \
  mkdir -p /etc/ansible \
  && echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts \
  && groupadd -r ansible \
  && useradd -m -g ansible ansible \
  && usermod -aG wheel ansible \
  && sed -i "/^%wheel/s/ALL\$/NOPASSWD:ALL/g" /etc/sudoers

VOLUME ["/sys/fs/cgroup", "/tmp", "/run"]

CMD ["/usr/lib/systemd/systemd"]

这是我收到的错误:

错误输出

fatal: [Archlinux-Latest]: UNREACHABLE! => {"changed": false, "msg": "Failed to create temporary directory.In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p \"` echo ~/.ansible/tmp `\"&& mkdir \"` echo ~/.ansible/tmp/ansible-tmp-1618893314.958555-25046-129222695615155 `\" && echo ansible-tmp-1618893314.958555-25046-129222695615155=\"` echo ~/.ansible/tmp/ansible-tmp-1618893314.958555-25046-129222695615155 `\" ), exited with result 1", "unreachable": true}

注意:我在 Fedora 33 上遇到过类似的问题,但问题似乎在几个月后神奇地消失了。

非常感谢任何建议 - 即使是关于检查内容的想法也会有所帮助。

【问题讨论】:

    标签: docker ansible archlinux


    【解决方案1】:

    不要在平台volumes条目中挂载cgroup,或者以读写方式挂载它们。

    调查

    我的分子测试过去使用 Docker 通过。我开始看到同样的错误。问题开始出现在archlinux:base-devel-20210404.0.18927

    • archlinux:base-devel-20210328.0.18194 测试通过
    • archlinux:base-devel-20210404.0.18927 测试失败

    在运行分子之前在archlinux:base-devel-20210328.0.18194上运行系统升级,测试失败。

    FROM archlinux:base-devel-20210328.0.18194
    
    RUN pacman -Syu --noconfirm python
    

    因此,它来自 2021-03-28 和 2021-04-04 之间的系统更改。

    区分两个映像之间的包,忽略不太可能导致此问题的包,我看到 systemdsystemd-libssystemd-sysvcompat 已从 247.4-2 升级到 248-2。

    宾果!建筑:

    FROM archlinux:base-devel-20210328.0.18194
    
    RUN pacman -Syu --noconfirm python --ignore systemd,systemd-libs,systemd-sysvcompat
    

    测试通过。

    我不是systemd 专家,我愿意花更多的时间来解决这个问题。以下更改日志引起了我的注意,可能是更改的来源。 https://github.com/systemd/systemd/blob/v248/NEWS#L432-L435。如果其他人有解释,我会很好奇。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-18
      • 1970-01-01
      • 1970-01-01
      • 2017-12-18
      • 2013-03-28
      相关资源
      最近更新 更多