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

  vars:
    certificate_requests:
      - name: mycert_subject
        dns: www.example.com
        common_name: Some other common name
        country: US
        state: NC
        locality: Raleigh
        organization: Red Hat
        organizational_unit: Linux
        ca: self-sign
  roles:
    - linux-system-roles.certificate

- name: Verify certificate
  hosts: all
  vars:
    certificates:
      - path: /etc/pki/tls/certs/mycert_subject.crt
        key_path: /etc/pki/tls/private/mycert_subject.key
        subject:
          - name: countryName
            oid: 2.5.4.6
            value: US
          - name: stateOrProvinceName
            oid: 2.5.4.8
            value: NC
          - name: localityName
            oid: 2.5.4.7
            value: Raleigh
          - name: organizationName
            oid: 2.5.4.10
            value: Red Hat
          - name: organizationalUnitName
            oid: 2.5.4.11
            value: Linux
          - name: commonName
            oid: 2.5.4.3
            value: Some other common name
        subject_alt_name:
          - name: DNS
            value: www.example.com
  tasks:
    - name: Verify each certificate
      include_tasks: tasks/assert_certificate_parameters.yml
      loop: "{{ certificates }}"
      loop_control:
        loop_var: cert
