---
- name: Create Receptor cert directories
  ansible.builtin.file:
    dest: "{{ item }}"
    state: directory
    mode: '0750'
    owner: "{{ receptor_user }}"
    group: "{{ receptor_group }}"
    recurse: true
  with_items:
    - "{{ receptor_tls_dir }}"
    - "{{ receptor_tls_ca_dir }}"

- name: Process provided TLS files
  include_tasks: tls_local.yml
  when: custom_tls_certfile is defined or custom_tls_keyfile is defined

- name: Set TLS file permissions
  ansible.builtin.file:
    dest: "{{ item }}"
    owner: "{{ receptor_user }}"
    group: "{{ receptor_group }}"
    mode: '0640'
  with_items:
    - "{{ receptor_tls_certfile }}"
    - "{{ receptor_tls_keyfile }}"
    - "{{ receptor_ca_certfile }}"
