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

Add multiple services support for certificate deployment #11

Merged
merged 4 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ vault username:
# Setup a virtualenv and install dependencies
[group('tooling')]
venv:
#!/usr/bin/env bash
[[ -d .venv ]] || (python -m venv .venv --prompt rezoleo-ansible-playbooks && {{venv_bin}}/pip install -r requirements.txt)

# Run ansible-lint
Expand Down
14 changes: 14 additions & 0 deletions roles/vault_agent/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Location of approle files
vault_agent_working_directory: /root/vault_agent_certificates

# Version of vault agent
vault_agent_vault_version: 1.18.2

# Location where the certificate will be stored
vault_agent_certificate_directory: "/var/lib/vault_agent_certificates"

# Name of the group that is allowed to read certificate
vault_agent_group_name: "vault-certs"

# Command to execute after certificate update
# vault_agent_service_reload_command:
# - systemctl
# - restart
# - mon_super_service
6 changes: 5 additions & 1 deletion roles/vault_agent/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,17 @@
owner: root
group: root

- name: Create read-acces group
ansible.builtin.group:
name: "{{ vault_agent_group_name }}"

- name: Create directory for certificates
ansible.builtin.file:
state: directory
dest: "{{ vault_agent_certificate_directory }}"
mode: '0755'
owner: root
group: root
group: "{{ vault_agent_group_name }}"

- name: Start vault-agent-certificates service
ansible.builtin.systemd:
Expand Down
8 changes: 4 additions & 4 deletions roles/vault_agent/templates/retrieving_cert.tmpl.j2
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{with secret "secret/certificat-web"}}
{{ index .Data.data "privkey.pem" | writeToFile "<<vault_agent_certificate_directory>>/privkey.pem" "" "" "0400" }}
{{ index .Data.data "chain.pem" | writeToFile "<<vault_agent_certificate_directory>>/chain.pem" "" "" "0400" }}
{{ index .Data.data "cert.pem" | writeToFile "<<vault_agent_certificate_directory>>/cert.pem" "" "" "0400" }}
{{ index .Data.data "fullchain.pem" | writeToFile "<<vault_agent_certificate_directory>>/fullchain.pem" "" "" "0400" }}
{{ index .Data.data "privkey.pem" | writeToFile "<<vault_agent_certificate_directory>>/privkey.pem" "" "<<vault_agent_group_name>>" "0440" }}
{{ index .Data.data "chain.pem" | writeToFile "<<vault_agent_certificate_directory>>/chain.pem" "" "<<vault_agent_group_name>>" "0440" }}
{{ index .Data.data "cert.pem" | writeToFile "<<vault_agent_certificate_directory>>/cert.pem" "" "<<vault_agent_group_name>>" "0440" }}
{{ index .Data.data "fullchain.pem" | writeToFile "<<vault_agent_certificate_directory>>/fullchain.pem" "" "<<vault_agent_group_name>>" "0440" }}
{{ index .Data.data "privkey.pem" }}
{{ index .Data.data "chain.pem" }}
{{ index .Data.data "cert.pem" }}
Expand Down
Loading