Skip to content

Commit

Permalink
Allow testing this role with non-root user
Browse files Browse the repository at this point in the history
  • Loading branch information
baztian committed Feb 8, 2021
1 parent 8740a85 commit d9f7b43
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
10 changes: 10 additions & 0 deletions molecule/default/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM geerlingguy/{{ item.image }}
# Create `ansible` user with sudo permissions and membership in `DEPLOY_GROUP`
ENV ANSIBLE_USER=ansible SUDO_GROUP=sudo DEPLOY_GROUP=deployer
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 "/^%${SUDO_GROUP}/s/ALL\$/NOPASSWD:ALL/g" /etc/sudoers
1 change: 1 addition & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
- name: Converge
hosts: all
become: yes

tasks:
- name: Include this role
Expand Down
7 changes: 5 additions & 2 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ driver:
ansible_connection: local
platforms:
- name: instance
image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest"
pre_build_image: true
image: "docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest"
provisioner:
name: ansible
log: True
inventory:
host_vars:
instance:
ansible_user: ansible
verifier:
name: ansible
6 changes: 6 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
recurse: no
register: settings_sync_ext_find
become: no
- name: Install additional packages in order to be able to run the extension installation below
# Might be obsolete with the official settings sync function
apt:
pkg:
- libx11-xcb1
- libasound2
- name: Install code-settings-sync extension
command: code --install-extension shan.code-settings-sync
become: no
Expand Down

0 comments on commit d9f7b43

Please sign in to comment.