---

- name: "Import Let's Encrypt certificate"
  hosts: localhost
  gather_facts: no
  tasks:
    - name: "Copy isrgrootx1.pem in /tmp"
      copy:
        src: "isrgrootx1.pem"
        dest: "/tmp/isrgrootx1.pem"
    - name: "Import isrgrootx1.pem"
      java_cert:
        keystore_path: "/tmp/test.jks"
        keystore_create: yes
        keystore_pass: "ansible"
        cert_path: "/tmp/isrgrootx1.pem"
        cert_alias: "letsencrypt"
        state: present
    - name: "Remove isrgrootx1.pem from /tmp"
      file:
        path: "/tmp/isrgrootx1.pem"
        state: absent
