---
- hosts: all
  vars:
    ssl_certificates_create:
      - name: foo.bar.org
      - name: bar.foo.org
    java_keystore_certificates:
      - name: foo.bar.org
        crt: /etc/ssl/certs/foo.bar.org.crt
        key: /etc/ssl/private/foo.bar.org.pem
      - name: bar.foo.org
        crt: /etc/ssl/certs/bar.foo.org.crt
        key: /etc/ssl/private/bar.foo.org.pem
    java_keystore_file: /tmp/cacerts
    java_keystore_pass: changeit
  roles:
    - { role: ansible-ssl-certificates }
    - { role: ansible-java }
  tasks:
    - name: Test with custom keystore
      tags:
        - java
        - keystore
      with_items: java_keystore_certificates
      keystore:
        state=present
        dest={{ java_keystore_file }}
        alias={{ item.name }}
        crt={{ item.crt }}
        key={{ item.key }}
        keytool=/opt/java/oracle/jdk1.8.0_31/bin/keytool
        password={{ java_keystore_pass }}
        owner=0
        group=0
        mode=0640

---
- hosts: all
  vars:
    ssl_certificates_create:
      - name: foo.bar.org
        CN: foo.bar.org
      - name: bar.foo.org
        CN: bar.foo.org
    java_keystore_certificates:
      - name: foo.bar.org
        crt: /etc/ssl/certs/foo.bar.org.crt
        key: /etc/ssl/private/foo.bar.org.pem
      - name: bar.foo.org
        crt: /etc/ssl/certs/bar.foo.org.crt
        key: /etc/ssl/private/bar.foo.org.pem
    java_keystore_file: /tmp/cacerts
    java_keystore_pass: changeit
  roles:
    - { role: ansible-ssl-certificates }
    - { role: ansible-java }
  tasks:
    - name: Test with custom keystore
      tags:
        - java
        - keystore
      with_items: java_keystore_certificates
      keystore:
        state=present
        create=true
        dest={{ java_keystore_file }}
        alias={{ item.name }}
        crt={{ item.crt }}
        key={{ item.key }}
        keytool=/opt/java/oracle/jdk1.8.0_31/bin/keytool
        password={{ java_keystore_pass }}
        owner=0
        group=0
        mode=0640

Create test SSL certificates with "usable" CN names
Create test SSL certificates with "usable" CN names
