File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 1
1
FROM alpine:latest
2
2
LABEL maintainer="Sebastian Gumprich"
3
3
4
- RUN apk add --no-cache ansible
4
+ RUN apk add --no-cache ansible sudo
5
5
6
6
# Install Ansible inventory file
7
7
RUN mkdir -p /etc/ansible \
8
8
&& echo "[local]\n localhost ansible_connection=local" > /etc/ansible/hosts
9
9
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
+
10
21
# delete file created by systemd that prevents login via ssh
11
22
RUN rm -f /{var/run,etc,run}/nologin
12
23
You can’t perform that action at this time.
0 commit comments