nginx: separate self-signed certs
This commit is contained in:
parent
d0d33b47b9
commit
c158a21dfc
|
@ -1,4 +1,5 @@
|
||||||
base_domain: "dev.local"
|
base_domain: "dev.local"
|
||||||
|
self_signed: false
|
||||||
admin_email: "lukas@kucharczyk.xyz"
|
admin_email: "lukas@kucharczyk.xyz"
|
||||||
server_ip: "192.168.0.107"
|
server_ip: "192.168.0.107"
|
||||||
data_folder: "{{ playbook_dir }}/docker-data"
|
data_folder: "{{ playbook_dir }}/docker-data"
|
||||||
|
|
|
@ -5,59 +5,9 @@
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
loop:
|
loop:
|
||||||
- "{{ nginx_confd_folder }}"
|
- "{{ nginx_confd_folder }}"
|
||||||
- name: generate root ca
|
- name: generate and install self-signed certs
|
||||||
command: openssl req \
|
import_tasks: self-signed.yml
|
||||||
-x509 \
|
when: self_signed
|
||||||
-new \
|
|
||||||
-nodes \
|
|
||||||
-newkey rsa:2048 \
|
|
||||||
-keyout "{{ data_folder }}/nginx/rootca.key" \
|
|
||||||
-out "{{ data_folder }}/nginx/rootca.pem" \
|
|
||||||
-sha256 \
|
|
||||||
-days 3650 \
|
|
||||||
-subj "/C=CZ/L=Prague/CN=Homelab/emailAddress={{ admin_email }}"
|
|
||||||
args:
|
|
||||||
creates: rootca.*
|
|
||||||
- name: generate wildcard csr
|
|
||||||
command: openssl req \
|
|
||||||
-new \
|
|
||||||
-nodes \
|
|
||||||
-newkey rsa:2048 \
|
|
||||||
-keyout "{{ data_folder }}/nginx/{{ base_domain }}.key" \
|
|
||||||
-out "{{ data_folder }}/nginx/{{ base_domain }}.csr" \
|
|
||||||
-subj "/C=CZ/L=Prague/CN=*.{{ base_domain }}/emailAddress={{ admin_email }}"
|
|
||||||
args:
|
|
||||||
creates: "{{ data_folder }}/nginx/{{ base_domain }}.*"
|
|
||||||
- name: sign wildcard csr with root ca
|
|
||||||
command: openssl x509 \
|
|
||||||
-req \
|
|
||||||
-in "{{ data_folder }}/nginx/{{ base_domain }}.csr" \
|
|
||||||
-CA "{{ data_folder }}/nginx/rootca.pem" \
|
|
||||||
-CAkey "{{ data_folder }}/nginx/rootca.key" \
|
|
||||||
-CAcreateserial \
|
|
||||||
-out "{{ data_folder }}/nginx/{{ base_domain }}.crt" \
|
|
||||||
-days 3650 \
|
|
||||||
-sha256
|
|
||||||
args:
|
|
||||||
creates: "{{ data_folder }}/nginx/{{ base_domain }}.crt"
|
|
||||||
- name: install root ca
|
|
||||||
command: trust anchor "{{ data_folder }}/nginx/rootca.pem"
|
|
||||||
args:
|
|
||||||
creates: /etc/ca-certificates/extracted/cadir/Homelab*
|
|
||||||
become: yes
|
|
||||||
- name: copy certificates
|
|
||||||
copy:
|
|
||||||
src: "{{ item }}"
|
|
||||||
dest: "{{ data_folder }}/nginx"
|
|
||||||
mode: '0755'
|
|
||||||
loop:
|
|
||||||
- "{{ data_folder }}/nginx/{{ base_domain }}.key"
|
|
||||||
- "{{ data_folder }}/nginx/{{ base_domain }}.crt"
|
|
||||||
- name: copy .conf file
|
|
||||||
template:
|
|
||||||
src: nginx.conf.j2
|
|
||||||
dest: "{{ data_folder }}/nginx/nginx.conf"
|
|
||||||
mode: '0755'
|
|
||||||
- name: create nginx bridge network
|
- name: create nginx bridge network
|
||||||
docker_network:
|
docker_network:
|
||||||
name: nginx-internal
|
name: nginx-internal
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
- name: generate root ca
|
||||||
|
command: openssl req \
|
||||||
|
-x509 \
|
||||||
|
-new \
|
||||||
|
-nodes \
|
||||||
|
-newkey rsa:2048 \
|
||||||
|
-keyout "{{ data_folder }}/nginx/rootca.key" \
|
||||||
|
-out "{{ data_folder }}/nginx/rootca.pem" \
|
||||||
|
-sha256 \
|
||||||
|
-days 3650 \
|
||||||
|
-subj "/C=CZ/L=Prague/CN=Homelab/emailAddress={{ admin_email }}"
|
||||||
|
- name: generate wildcard csr
|
||||||
|
command: openssl req \
|
||||||
|
-new \
|
||||||
|
-nodes \
|
||||||
|
-newkey rsa:2048 \
|
||||||
|
-keyout "{{ data_folder }}/nginx/{{ base_domain }}.key" \
|
||||||
|
-out "{{ data_folder }}/nginx/{{ base_domain }}.csr" \
|
||||||
|
-subj "/C=CZ/L=Prague/CN=*.{{ base_domain }}/emailAddress={{ admin_email }}"
|
||||||
|
- name: sign wildcard csr with root ca
|
||||||
|
command: openssl x509 \
|
||||||
|
-req \
|
||||||
|
-in "{{ data_folder }}/nginx/{{ base_domain }}.csr" \
|
||||||
|
-CA "{{ data_folder }}/nginx/rootca.pem" \
|
||||||
|
-CAkey "{{ data_folder }}/nginx/rootca.key" \
|
||||||
|
-CAcreateserial \
|
||||||
|
-out "{{ data_folder }}/nginx/{{ base_domain }}.crt" \
|
||||||
|
-days 3650 \
|
||||||
|
-sha256
|
||||||
|
- name: install root ca
|
||||||
|
command: trust anchor "{{ data_folder }}/nginx/rootca.pem"
|
||||||
|
become: yes
|
||||||
|
- name: copy .conf file
|
||||||
|
template:
|
||||||
|
src: nginx.conf.j2
|
||||||
|
dest: "{{ data_folder }}/nginx/nginx.conf"
|
||||||
|
mode: '0755'
|
Loading…
Reference in New Issue