-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Roles] Use non-root users for step with bootstrap and acme_cert roles (
#307) * WIP * WIP * idempotency fix * WIP * WIP
- Loading branch information
Showing
32 changed files
with
568 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
platforms: | ||
# Use the smallstep-provided CA image so that we don't have to set up the CA ourselves | ||
- name: step-ca | ||
groups: | ||
- ca | ||
image: "docker.io/smallstep/step-ca:${STEP_CA_VERSION}" | ||
# we don't actually use the container with ansible, leave it as is | ||
override_command: false | ||
pre_build_image: true | ||
env: | ||
DOCKER_STEPCA_INIT_NAME: "Molecule_Bootstrap_CA" | ||
DOCKER_STEPCA_INIT_DNS_NAMES: "step-ca,localhost" | ||
network: molecule-step-acme-cert | ||
|
||
- name: step-host-ubuntu-22 | ||
groups: | ||
- clients | ||
- ubuntu | ||
image: "docker.io/geerlingguy/docker-ubuntu2204-ansible" | ||
systemd: always | ||
override_command: false | ||
pre_build_image: true | ||
network: molecule-step-acme-cert | ||
|
||
- name: step-host-ubuntu-20 | ||
groups: | ||
- clients | ||
- ubuntu | ||
image: "docker.io/geerlingguy/docker-ubuntu2004-ansible" | ||
systemd: always | ||
override_command: false | ||
pre_build_image: true | ||
network: molecule-step-acme-cert | ||
|
||
- name: step-host-ubuntu-18 | ||
groups: | ||
- clients | ||
- ubuntu | ||
image: "docker.io/geerlingguy/docker-ubuntu1804-ansible" | ||
systemd: always | ||
override_command: false | ||
pre_build_image: true | ||
network: molecule-step-acme-cert | ||
|
||
- name: step-host-debian-11 | ||
groups: | ||
- clients | ||
- debian | ||
image: "docker.io/geerlingguy/docker-debian11-ansible" | ||
systemd: always | ||
override_command: false | ||
pre_build_image: true | ||
network: molecule-step-acme-cert | ||
|
||
- name: step-host-debian-10 | ||
groups: | ||
- clients | ||
- debian | ||
image: "docker.io/geerlingguy/docker-debian10-ansible" | ||
systemd: always | ||
override_command: false | ||
pre_build_image: true | ||
network: molecule-step-acme-cert | ||
|
||
- name: step-host-rockylinux-9 | ||
groups: | ||
- clients | ||
- rockylinux | ||
image: "docker.io/geerlingguy/docker-rockylinux9-ansible" | ||
systemd: always | ||
override_command: false | ||
pre_build_image: true | ||
network: molecule-step-acme-cert | ||
|
||
- name: step-host-rockylinux-8 | ||
groups: | ||
- clients | ||
- rockylinux | ||
image: "docker.io/geerlingguy/docker-rockylinux8-ansible" | ||
systemd: always | ||
override_command: false | ||
pre_build_image: true | ||
network: molecule-step-acme-cert | ||
|
||
- name: step-host-fedora-36 | ||
groups: | ||
- clients | ||
- fedora | ||
image: "docker.io/geerlingguy/docker-fedora36-ansible" | ||
systemd: always | ||
override_command: false | ||
pre_build_image: true | ||
network: molecule-step-acme-cert | ||
|
||
provisioner: | ||
playbooks: | ||
verify: ../verify.yml | ||
converge: ../converge.yml | ||
inventory: | ||
group_vars: | ||
ca: | ||
step_ca_user: step-ca | ||
all: | ||
step_acme_cert_user: max | ||
step_acme_cert_steppath: "/home/max/custom-steppath" | ||
step_acme_cert_ca_provisioner: ACME | ||
step_bootstrap_ca_url: https://step-ca:9000 | ||
|
||
certfile: /etc/ssl/non-root/nginx-test.cert | ||
keyfile: /etc/ssl/non-root/nginx-test.key | ||
|
||
step_acme_cert_certfile: | ||
path: /etc/ssl/non-root/nginx-test.cert | ||
mode: "644" | ||
group: "{{ webgroup[ansible_os_family] }}" | ||
step_acme_cert_keyfile: | ||
path: /etc/ssl/non-root/nginx-test.key | ||
mode: "640" | ||
group: "{{ webgroup[ansible_os_family] }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
- hosts: ubuntu:debian | ||
tasks: | ||
- name: Update apt | ||
apt: | ||
update_cache: yes | ||
|
||
- hosts: rockylinux:fedora | ||
tasks: | ||
# Required to prevent issues with ansible_default_ipv4 missing | ||
- name: Install iproute | ||
package: | ||
name: iproute | ||
|
||
- hosts: localhost | ||
tasks: | ||
# Somewhat hacky way to customize the container image, but we make do with what we have | ||
- name: Add ACME provisioner # noqa no-changed-when | ||
ansible.builtin.command: "podman exec step-ca step ca provisioner add {{ step_acme_cert_ca_provisioner }} --type=ACME" | ||
- name: Get CA PID | ||
ansible.builtin.command: podman exec step-ca pgrep -f step-ca | ||
register: _step_ca_pid | ||
changed_when: false | ||
- name: Reload step-ca # noqa no-changed-when | ||
ansible.builtin.command: "podman exec step-ca kill -1 {{ _step_ca_pid.stdout }}" | ||
|
||
- hosts: clients | ||
vars: | ||
webgroup: | ||
Debian: www-data | ||
RedHat: nginx | ||
tasks: | ||
- name: Install nginx | ||
package: | ||
name: nginx | ||
- name: Stop nginx | ||
systemd: | ||
name: nginx | ||
state: stopped | ||
enabled: no | ||
|
||
- name: Create test user | ||
ansible.builtin.user: | ||
name: max | ||
create_home: yes | ||
- name: Create certificate directory | ||
ansible.builtin.file: | ||
state: directory | ||
path: /etc/ssl/non-root | ||
owner: max | ||
group: "{{ webgroup[ansible_os_family] }}" | ||
mode: "750" | ||
|
||
- name: Get CA fingerprint | ||
ansible.builtin.command: podman exec step-ca step certificate fingerprint certs/root_ca.crt | ||
register: _ca_fingerprint | ||
changed_when: false | ||
check_mode: false | ||
run_once: true | ||
delegate_to: localhost | ||
|
||
- name: Bootstrap host | ||
include_role: | ||
name: maxhoesel.smallstep.step_bootstrap_host | ||
vars: | ||
step_bootstrap_fingerprint: "{{ _ca_fingerprint.stdout }}" | ||
step_bootstrap_users: | ||
- user: max | ||
steppath: "{{ step_acme_cert_steppath }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../tests/roles/requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.