- name: Download and untar lego unarchive: src: https://github.com/go-acme/lego/releases/download/v{{ lego_version }}/lego_v{{ lego_version }}_linux_amd64.tar.gz dest: /usr/local/bin remote_src: yes - name: Check if certs exist stat: path: /root/.lego/certificates/{{ inventory_hostname | default(cert_domain) }}.crt register: cert_check - name: Generate an initial cert if not present include_tasks: file: initial_cert.yaml when: not cert_check.stat.exists - name: Copy certificates include_tasks: file: copy_certs.yaml