---
- name: Issue many self-signed certificates
  hosts: all
  vars:
    certificate_requests:
      - name: mycert_many_self_signed
        dns: www.example.com
        ca: self-sign
      - name: other-cert
        dns: www.example.org
        ca: self-sign
      - name: another-cert
        dns: www.example.net
        ca: self-sign
  roles:
    - redhat.rhel_system_roles.certificate

- name: Verify certificate
  hosts: all
  vars:
    certificates:
      - path: /etc/pki/tls/certs/mycert_many_self_signed.crt
        key_path: /etc/pki/tls/private/mycert_many_self_signed.key
        subject:
          - name: commonName
            oid: 2.5.4.3
            value: www.example.com
        subject_alt_name:
          - name: DNS
            value: www.example.com
      - path: /etc/pki/tls/certs/other-cert.crt
        key_path: /etc/pki/tls/private/other-cert.key
        subject:
          - name: commonName
            oid: 2.5.4.3
            value: www.example.org
        subject_alt_name:
          - name: DNS
            value: www.example.org
      - path: /etc/pki/tls/certs/another-cert.crt
        key_path: /etc/pki/tls/private/another-cert.key
        subject:
          - name: commonName
            oid: 2.5.4.3
            value: www.example.net
        subject_alt_name:
          - name: DNS
            value: www.example.net
  tasks:
    - name: Verify each certificate
      include_tasks: tasks/assert_certificate_parameters.yml
      loop: "{{ certificates }}"
      loop_control:
        loop_var: cert
