aboutsummaryrefslogblamecommitdiffstats
path: root/roles/acme/tasks/main.yml
blob: c068ab5f6e011bb68eebef66f4f43b5424c67746 (plain) (tree)
1
2
3
4
5
6
7
8
9

   
                                          
                           



                                         
                
 
                                
                          

                                                          

                                  
 
                                  
                                                    
                                                   
                                  

                                              

                                       
                        

                                                                     

                                                 
                       



                                                                         
                                                   
---

- name: generate acme-client configuration
  ansible.builtin.template:
    src: acme-client.conf.j2
    dest: "{{ acme_configuration_file }}"
    owner: 0
    group: 0
    mode: "0644"

- name: retrieve enabled domains
  ansible.builtin.shell: |
    set -o pipefail
    grep "^domain" /etc/acme-client.conf | cut -d " " -f 2
  register: acme_result_subdomains
  changed_when: false

- name: generate acme certificates
  ansible.builtin.command: acme-client -v {{ item }}
  loop: "{{ acme_result_subdomains.stdout_lines }}"
  register: acme_result_generation
  failed_when: acme_result_generation.rc == 1
  changed_when: acme_result_generation.rc != 2

- name: display registered certificates
  ansible.builtin.debug:
    msg: "{{ acme_result_generation.results | map(attribute='stderr')
      | join('\n') }}"

- name: enable automatic acme certificates update
  ansible.builtin.cron:
    name: "automatic acme certificates update for subdomain : {{ item }}"
    minute: 0
    hour: 6,18
    job: "acme-client -v {{ item }} && rcctl reload relayd"
  loop: "{{ acme_result_subdomains.stdout_lines }}"
remember that computers suck.