Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(alpine): add ansible-user and sudo-support #57

Merged
merged 2 commits into from
Oct 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion alpine-ansible-latest/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
FROM alpine:latest
LABEL maintainer="Sebastian Gumprich"

RUN apk add --no-cache ansible
RUN apk add --no-cache ansible sudo openrc linux-pam openssh-server-pam bash

# Install Ansible inventory file
RUN mkdir -p /etc/ansible \
&& echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts

# 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 \
&& adduser -D ${ANSIBLE_USER} ${DEPLOY_GROUP} \
&& addgroup ${ANSIBLE_USER} ${ANSIBLE_USER} \
&& addgroup ${ANSIBLE_USER} ${SUDO_GROUP} \
&& sed -i "s/^# %${SUDO_GROUP} ALL=(ALL:ALL) NOPASSWD: ALL/%${SUDO_GROUP} ALL=(ALL:ALL) NOPASSWD: ALL/" /etc/sudoers

# delete file created by systemd that prevents login via ssh
RUN rm -f /{var/run,etc,run}/nologin

Expand Down
Loading