---
- name: Issue simple self-signed certificate
  hosts: all

  vars:
    certificate_wait: false
    certificate_requests:
      - name: mycert_not_wait_for_cert
        dns: www.example.com
        ca: self-sign
  roles:
    - linux-system-roles.certificate

- name: Verify certificate
  hosts: all
  vars:
    certificates:
      - path: /etc/pki/tls/certs/mycert_not_wait_for_cert.crt
        key_path: /etc/pki/tls/private/mycert_not_wait_for_cert.key
        subject:
          - name: commonName
            oid: 2.5.4.3
            value: www.example.com
        subject_alt_name:
          - name: DNS
            value: www.example.com
  tasks:
    - name: Wait for certificate
      wait_for:
        path: "{{ item.path }}"
        timeout: 5
      loop: "{{ certificates }}"
      # cert isn't actually generated during buildah build
      when: ansible_connection != "buildah"

    - name: Verify each certificate
      include_tasks: tasks/assert_certificate_parameters.yml
      loop: "{{ certificates }}"
      loop_control:
        loop_var: cert
