-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathDockerfile
54 lines (46 loc) · 2 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
FROM archlinux:latest
LABEL maintainer="Sebastian Gumprich"
# Update, install sudo and systemd, cleanup and remove unneeded unit files.
RUN pacman -S -y \
&& pacman -S --noconfirm \
sudo \
systemd \
&& \
for i in /lib/systemd/system/sysinit.target.wants/*; do [ $i == systemd-tmpfiles-setup.service ] || rm -vf $i; done; \
rm -vf /lib/systemd/system/multi-user.target.wants/*; \
rm -vf /etc/systemd/system/*.wants/*; \
rm -vf /lib/systemd/system/local-fs.target.wants/*; \
rm -vf /lib/systemd/system/sockets.target.wants/*udev*; \
rm -vf /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -vf /lib/systemd/system/basic.target.wants/*;
# Update archlinux-keyring.
RUN pacman -S -y \
&& pacman -S --noconfirm \
archlinux-keyring
# Install glibc, python and Ansible and clear caches.
RUN pacman -S -y \
&& pacman -S --noconfirm \
glibc \
python \
ansible \
&& pacman -Scc --noconfirm || true
# Install Ansible inventory file.
RUN mkdir /etc/ansible \
&& echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
# Switch default target from graphical to multi-user.
RUN systemctl set-default multi-user.target
# https://molecule.readthedocs.io/en/latest/examples.html#docker-with-non-privileged-user
# Create `ansible` user with sudo permissions and membership in `DEPLOY_GROUP`
# This template gets rendered using `loop: "{{ molecule_yml.platforms }}"`, so
# each `item` is an element of platforms list from the molecule.yml file for this scenario.
ENV ANSIBLE_USER=ansible DEPLOY_GROUP=deployer SUDO_GROUP=wheel
RUN set -xe \
&& groupadd -r ${ANSIBLE_USER} \
&& groupadd -r ${DEPLOY_GROUP} \
&& useradd -m -g ${ANSIBLE_USER} ${ANSIBLE_USER} \
&& usermod -aG ${SUDO_GROUP} ${ANSIBLE_USER} \
&& usermod -aG ${DEPLOY_GROUP} ${ANSIBLE_USER} \
&& sed -i "s/^# \(%${SUDO_GROUP} ALL=(ALL:ALL) NOPASSWD: ALL\)/\\1/g" /etc/sudoers
# delete file created by systemd that prevents login via ssh
RUN rm -f /{var/run,etc,run}/nologin
CMD [ "ansible-playbook", "--version" ]