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

  vars:
    certificate_requests:
      - name: mycert_no_auto_renew
        dns: www.example.com
        ca: self-sign
        auto_renew: false
      - name: defaultcert
        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_no_auto_renew.crt
        key_path: /etc/pki/tls/private/mycert_no_auto_renew.key
        subject:
          - name: commonName
            oid: 2.5.4.3
            value: www.example.com
        subject_alt_name:
          - name: DNS
            value: www.example.com
        auto_renew: false
      - path: /etc/pki/tls/certs/defaultcert.crt
        key_path: /etc/pki/tls/private/defaultcert.key
        subject:
          - name: commonName
            oid: 2.5.4.3
            value: www.example.com
        subject_alt_name:
          - name: DNS
            value: www.example.com
        auto_renew: true
  tasks:
    - name: Verify each certificate
      include_tasks: tasks/assert_certificate_parameters.yml
      loop: "{{ certificates }}"
      loop_control:
        loop_var: cert
