Add certbot installation with root cert renew
This commit is contained in:
parent
a08eb939b6
commit
c7a20e14a1
9 changed files with 101 additions and 14 deletions
5
roles/reverse-proxy/handlers/main.yml
Normal file
5
roles/reverse-proxy/handlers/main.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: Confirm Certbot plugin containment level
|
||||
become: true
|
||||
ansible.builtin.command:
|
||||
cmd: snap set certbot trust-plugin-with-root=ok
|
||||
|
|
@ -19,6 +19,53 @@
|
|||
ansible.builtin.apt:
|
||||
name: nginx # Creates the "nginx" user as well
|
||||
state: present
|
||||
# TODO: Remove the default configuration here, we'll keep it for now as an example...
|
||||
# TODO: Setup Certbot as it's part of the installation...
|
||||
# ---------- CERTBOT INSTALLATION ---------- #
|
||||
# See the installation instructions here: https://certbot.eff.org/instructions?ws=nginx&os=debianbuster&tab=wildcard
|
||||
- name: Install Certbot
|
||||
become: true
|
||||
community.general.snap:
|
||||
name: certbot
|
||||
classic: true
|
||||
state: present
|
||||
notify: Confirm Certbot plugin containment level
|
||||
- name: Flush handlers # Makes sure that the handler runs
|
||||
ansible.builtin.meta: flush_handlers
|
||||
- name: Install Certbot DNS Cloudflare plugin
|
||||
become: true
|
||||
community.general.snap:
|
||||
name: certbot-dns-cloudflare
|
||||
classic: true
|
||||
state: present
|
||||
- name: Set cloudflare variable
|
||||
ansible.builtin.set_fact:
|
||||
cloudflare_credential_dir_path: "/root/.secrets/certbot"
|
||||
cloudflare_credential_filename: cloudflare.ini
|
||||
- name: Create Certbot credential directory
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{ cloudflare_credential_dir_path }}"
|
||||
state: directory
|
||||
mode: '0700'
|
||||
- name: Place cloudflare credential in certbot user's file
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: cloudflare.ini.j2
|
||||
dest: "{{ cloudflare_credential_dir_path }}/{{ cloudflare_credential_filename }}"
|
||||
mode: '0400'
|
||||
- name: Install the certificate script
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: register_certbot_domain.sh.j2
|
||||
dest: /usr/local/bin/register_certbot_domain.sh
|
||||
mode: '0500'
|
||||
- name: Create the root certificate for my domain
|
||||
become: true
|
||||
ansible.builtin.command:
|
||||
cmd: register_certbot_domain.sh kleinendorst.info
|
||||
creates: /etc/letsencrypt/live/kleinendorst.info # The certificate directory
|
||||
# END ------ CERTBOT INSTALLATION ------ END #
|
||||
- name: Start Nginx
|
||||
become: true
|
||||
ansible.builtin.systemd:
|
||||
|
|
|
|||
2
roles/reverse-proxy/templates/cloudflare.ini.j2
Normal file
2
roles/reverse-proxy/templates/cloudflare.ini.j2
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# Cloudflare API token used by Certbot
|
||||
dns_cloudflare_api_token = {{ dns_cloudflare_api_token }}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
/snap/bin/certbot certonly \
|
||||
--dns-cloudflare \
|
||||
--dns-cloudflare-credentials '{{ cloudflare_credential_dir_path }}/{{ cloudflare_credential_filename }}' \
|
||||
--agree-tos --test-cert -m {{ administration_email }} \
|
||||
-d $1
|
||||
|
|
@ -1,2 +1,3 @@
|
|||
---
|
||||
nginx_user: nginx # Created automatically by the apt installation
|
||||
certbot_user: certbot
|
||||
|
|
|
|||
9
roles/reverse-proxy/vars/main/vault.yml
Normal file
9
roles/reverse-proxy/vars/main/vault.yml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
$ANSIBLE_VAULT;1.1;AES256
|
||||
35613135623165306639373939396435656431326134336466636666393637333532623036303831
|
||||
6534646334633731313838323138303261663536376330640a376538653563353365336634346338
|
||||
34663031643265623838396239383164303865346332366361313839386533363530336361373930
|
||||
6438313861353563630a343738383365656531313137613361323636653635393232343738633433
|
||||
63356634323264623134313565386362663131313963373433306636383661373930323262353663
|
||||
64393433393639346166666433396363313465373032343239633939343830303465633564353130
|
||||
37333437643064346233633863346632393266633435396433396563653737386233346231303061
|
||||
37623138386233303764
|
||||
11
roles/snapcraft/tasks/main.yml
Normal file
11
roles/snapcraft/tasks/main.yml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
- name: Install Snapcraft
|
||||
become: true
|
||||
ansible.builtin.apt:
|
||||
name: snapd
|
||||
state: present
|
||||
- name: Install Snap Core
|
||||
become: true
|
||||
community.general.snap:
|
||||
name: core
|
||||
state: present
|
||||
|
|
@ -63,12 +63,16 @@
|
|||
regexp: '^plugins=\((.*)(?<!zsh-autosuggestions)\)$'
|
||||
line: 'plugins=(\1 zsh-autosuggestions)'
|
||||
backrefs: true
|
||||
- name: Add Starship eval in ~/.zshrc
|
||||
# For some reason snap isn't properly configured and its bin directory isn't added to the $PATH variable.
|
||||
# This probably has something to do with the hardening rules, instead we'll fix it here.
|
||||
- name: Add Starship config and Snapcraft to ~/.zshrc
|
||||
become: true
|
||||
become_user: "{{ target_user }}"
|
||||
ansible.builtin.blockinfile:
|
||||
path: ~/.zshrc
|
||||
block: |-
|
||||
# Add Snapcraft to $PATH
|
||||
export PATH=$PATH:/snap/bin
|
||||
|
||||
# Starship
|
||||
eval "$(starship init zsh)"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue