---

- name: shared/mount | Test if PKI mount exists
  uri:
    url: "{{ vault_leader_url }}/v1/sys/mounts/{{ mount_name }}/tune"
    headers: "{{ vault_headers }}"
  ignore_errors: true
  register: vault_pki_mount_check

- name: shared/mount | Mount PKI mount if needed
  uri:
    url: "{{ vault_leader_url }}/v1/sys/mounts/{{ mount_name }}"
    headers: "{{ vault_headers }}"
    method: POST
    body_format: json
    body: "{{ mount_options|d() }}"
    status_code: 204
  when: vault_pki_mount_check|failed
