aboutsummaryrefslogtreecommitdiff
path: root/roles/signed_certificate/tasks/main.yml
blob: 4fb424d48bbe4ffd9eff982977b111e8133f3065 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
- name: Unset cert_changed Flag
  set_fact:
    cert_changed: False

- name: Install crypt libs
  apt:
    name:
      - python3-cryptography
  become: yes

- name: Check for OpenSSL Private Key
  community.crypto.openssl_privatekey_info:
    path: '{{ key_path }}/{{ cert_name }}.key'
  ignore_errors: yes
  become: yes
  register: key_check

- name: Create OpenSSL Private Key
  community.crypto.openssl_privatekey:
    path: '{{ key_path }}/{{ cert_name }}.key'
    owner: '{{ owner }}'
    group: '{{ group }}'
    mode: '640'
  become: yes
  when: key_check.failed

- name: Check File Permissions for Key
  file:
    path: '{{ key_path }}/{{ cert_name }}.key'
    state: file
    owner: '{{ owner }}'
    group: '{{ group }}'
    mode: '640'
  become: yes
  when: not key_check.failed

- name: Trigger Cert Generation
  include_tasks: selfsigned.yml
  when: use_acme == false

- name: Trigger Cert Generation
  include_tasks: letsencrypt.yml
  when: use_acme == true