- block:

  - name: Ensure Dashboard certificates directory permissions.
    file:
      path: "/etc/wazuh-dashboard/certs/"
      state: directory
      owner: wazuh-dashboard
      group: wazuh-dashboard
      mode: 500

  - name: Copy the certificates from local to the Wazuh dashboard instance
    copy:
      src: "{{ local_certs_path }}/wazuh-certificates/{{ item }}"
      dest: /etc/wazuh-dashboard/certs/
      owner: wazuh-dashboard
      group: wazuh-dashboard
      mode: 0400
    with_items:
      - "root-ca.pem"
      - "{{ dashboard_node_name }}-key.pem"
      - "{{ dashboard_node_name }}.pem"
  tags:
  - security
