---
- name: define signed certificate path
  ansible.builtin.set_fact:
    nextcloud_tls_cert_file: "{{ nextcloud_tls_cert | default(\"/etc/ssl/\" + nextcloud_instance_name + \".crt\") }}"
- name: define signed certificate's key path
  ansible.builtin.set_fact:
    nextcloud_tls_cert_key_file: "{{ nextcloud_tls_cert_key | default(\"/etc/ssl/\" + nextcloud_instance_name + \".key\") }}"

- name: "[SIGNED TLS] - Certificate is on the host"
  ansible.builtin.copy:
    dest: "{{ nextcloud_tls_cert_file }}"
    src: "{{ nextcloud_tls_src_cert }}"
    mode: 0640

- name: "[SIGNED TLS] - Key is on the host"
  ansible.builtin.copy:
    dest: "{{ nextcloud_tls_cert_key_file }}"
    src: "{{ nextcloud_tls_src_cert_key }}"
    mode: 0640

- name: "[SIGNED TLS] - check TLS certificate permissions"
  ansible.builtin.file:
    path: "{{ nextcloud_tls_cert_file }}"
    mode: 0644
    group: "{{ nextcloud_websrv_group }}"

- name: "[SIGNED TLS] - check TLS key permissions"
  ansible.builtin.file:
    path: "{{ nextcloud_tls_cert_key_file }}"
    mode: 0640
    group: "{{ nextcloud_websrv_group }}"
