【发布时间】: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 上遇到过类似的问题,但问题似乎在几个月后神奇地消失了。
非常感谢任何建议 - 即使是关于检查内容的想法也会有所帮助。
【问题讨论】: