From 1ed78d5d73cc23599bcbd5febcdc285d95bd0ed0 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Wed, 22 Feb 2017 13:33:05 +0100 Subject: [PATCH] library/roles/java-keyring: Fixed some typos. As default do not use the java cacerts keystore. --- java-keyring/defaults/main.yml | 8 +++++--- java-keyring/tasks/main.yml | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/java-keyring/defaults/main.yml b/java-keyring/defaults/main.yml index c9b4fc59..4a38161d 100644 --- a/java-keyring/defaults/main.yml +++ b/java-keyring/defaults/main.yml @@ -1,13 +1,15 @@ --- -java_keyring_use_default: True +java_keyring_use_default: False java_default_keyring: '{{ jdk_java_home }}/jre/lib/security/cacerts' java_keyring_dir: "{{ pki_dir | default('/etc/pki') }}/jdk" -java_keyring_file: '{{ java_default_keyring }}' -#java_keyring_file: '{{ java_keyring_dir }}/java.jks' +#java_keyring_file: '{{ java_default_keyring }}' +java_keyring_file: '{{ java_keyring_dir }}/java.jks' java_keytool_bin: '{{ jdk_java_home }}/jre/bin/keytool' #java_keyring_certs_list: [] java_keyring_cert_alias: '{{ ansible_fqdn }}' +# This is the default java password. No need to hide it. +# Change it inside a vault file if you need something good java_keyring_pwd: changeit java_keyring_letsencrypt_trusted_ca: identrustdstx3 java_import_letsencrypt_cert: True diff --git a/java-keyring/tasks/main.yml b/java-keyring/tasks/main.yml index 06c7100b..f6a03c90 100644 --- a/java-keyring/tasks/main.yml +++ b/java-keyring/tasks/main.yml @@ -8,11 +8,11 @@ - block: - name: Import the certificates - shell: keytool -list -keystore {{ java_keyring_file }} -storepass {{ java_keyring_pwd }} -noprompt | grep {{ item.alias }} ; RETVAL=$? ; if [ $RETVAL -ne 0 ] ; then keytool -trustcacerts -keystore {{ java_keyring_file }} -storepass {{ java_keyring_pwd }} -noprompt -importcert -alias {{ item.alias }} -file {{ item.certfile | default(omit) }} ; fi + shell: RETVAL= ; {{ java_keytool_bin }} -list -keystore {{ java_keyring_file }} -storepass {{ java_keyring_pwd }} -noprompt | grep {{ item.alias }} ; RETVAL=$? ; if [ $RETVAL -ne 0 ] ; then {{ java_keytool_bin }} -trustcacerts -keystore {{ java_keyring_file }} -storepass {{ java_keyring_pwd }} -noprompt -importcert -alias {{ item.alias }} -file {{ item.certfile }} ; fi with_items: '{{ java_keyring_certs_list | default([]) }}' - name: Import the certificate key - shell: keytool -import -alias NOME -keyalg RSA -keystore {{ java_keyring_file }} -dname "CN={{ ansible_fqdn }}" -keypass {{ java_keyring_pwd }} -storepass {{ java_keyring_pwd }} -file {{ item.keyfile }} + shell: RETVAL= ; {{ java_keytool_bin }} -import -alias NOME -keyalg RSA -keystore {{ java_keyring_file }} -dname "CN={{ ansible_fqdn }}" -keypass {{ java_keyring_pwd }} -storepass {{ java_keyring_pwd }} -file {{ item.keyfile }} with_items: '{{ java_keyring_certs_list | default([]) }}' when: java_keyring_certs_list is defined @@ -20,10 +20,10 @@ - block: - name: Import the Letsencrypt intermediate CA cert - shell: keytool -list -keystore {{ java_keyring_file }} -storepass {{ java_keyring_pwd }} -noprompt | grep {{ java_keyring_letsencrypt_trusted_ca }} ; RETVAL=$? ; if [ $RETVAL -ne 0 ] ; then keytool -trustcacerts -keystore {{ java_keyring_file }} -storepass {{ java_keyring_pwd }} -noprompt -importcert -alias {{ java_keyring_letsencrypt_trusted_ca }} -dname "CN={{ ansible_fqdn }}" -file {{ letsencrypt_acme_certs_dir }}/chain ; fi + shell: RETVAL= ; {{ java_keytool_bin }} -list -keystore {{ java_keyring_file }} -storepass {{ java_keyring_pwd }} -noprompt | grep {{ java_keyring_letsencrypt_trusted_ca }} ; RETVAL=$? ; if [ $RETVAL -ne 0 ] ; then {{ java_keytool_bin }} -trustcacerts -keystore {{ java_keyring_file }} -storepass {{ java_keyring_pwd }} -noprompt -importcert -alias {{ java_keyring_letsencrypt_trusted_ca }} -dname "CN={{ ansible_fqdn }}" -file {{ letsencrypt_acme_certs_dir }}/chain ; fi - name: Import the letsencrypt certificate - shell: keytool -list -keystore {{ java_keyring_file }} -storepass {{ java_keyring_pwd }} -noprompt | grep {{ ansible_fqdn }} ; RETVAL=$? ; if [ $RETVAL -ne 0 ] ; then openssl pkcs12 -export -in {{ letsencrypt_acme_certs_dir }}/cert -inkey {{ letsencrypt_acme_certs_dir }}/privkey -CAfile {{ letsencrypt_acme_certs_dir }}/chain -name "{{ ansible_fqdn }}" -out /var/tmp/{{ ansible_fqdn }}.p12 -password pass:{{ java_keyring_pwd }} ; keytool -importkeystore -srcstorepass {{ java_keyring_pwd }} -deststorepass {{ java_keyring_pwd }} -destkeystore {{ java_keyring_file }} -srckeystore /var/tmp/{{ ansible_fqdn }}.p12 -srcstoretype PKCS12 ; rm -f /var/tmp/{{ ansible_fqdn }}.p12 ; fi + shell: RETVAL= ; {{ java_keytool_bin }} -list -keystore {{ java_keyring_file }} -storepass {{ java_keyring_pwd }} -noprompt | grep {{ ansible_fqdn }} ; RETVAL=$? ; if [ $RETVAL -ne 0 ] ; then openssl pkcs12 -export -in {{ letsencrypt_acme_certs_dir }}/cert -inkey {{ letsencrypt_acme_certs_dir }}/privkey -CAfile {{ letsencrypt_acme_certs_dir }}/chain -name "{{ ansible_fqdn }}" -out /var/tmp/{{ ansible_fqdn }}.p12 -password pass:{{ java_keyring_pwd }} ; {{ java_keytool_bin }} -importkeystore -srcstorepass {{ java_keyring_pwd }} -deststorepass {{ java_keyring_pwd }} -destkeystore {{ java_keyring_file }} -srckeystore /var/tmp/{{ ansible_fqdn }}.p12 -srcstoretype PKCS12 ; rm -f /var/tmp/{{ ansible_fqdn }}.p12 ; fi when: - java_import_letsencrypt_cert