File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11FROM alpine:latest
22LABEL maintainer="Sebastian Gumprich"
33
4- RUN apk add --no-cache ansible
4+ RUN apk add --no-cache ansible sudo openrc linux-pam openssh-server-pam bash
55
66# Install Ansible inventory file
77RUN mkdir -p /etc/ansible \
88 && echo "[local]\n localhost ansible_connection=local" > /etc/ansible/hosts
99
10+ # https://molecule.readthedocs.io/en/latest/examples.html#docker-with-non-privileged-user
11+ # Create `ansible` user with sudo permissions and membership in `DEPLOY_GROUP`
12+ # This template gets rendered using `loop: "{{ molecule_yml.platforms }}"`, so
13+ # each `item` is an element of platforms list from the molecule.yml file for this scenario.
14+ ENV ANSIBLE_USER=ansible DEPLOY_GROUP=deployer SUDO_GROUP=wheel
15+ RUN set -xe \
16+ && adduser -D ${ANSIBLE_USER} ${DEPLOY_GROUP} \
17+ && addgroup ${ANSIBLE_USER} ${ANSIBLE_USER} \
18+ && addgroup ${ANSIBLE_USER} ${SUDO_GROUP} \
19+ && sed -i "s/^# %${SUDO_GROUP} ALL=(ALL:ALL) NOPASSWD: ALL/%${SUDO_GROUP} ALL=(ALL:ALL) NOPASSWD: ALL/" /etc/sudoers
20+
1021# delete file created by systemd that prevents login via ssh
1122RUN rm -f /{var/run,etc,run}/nologin
1223
You can’t perform that action at this time.
0 commit comments