diff --git a/defaults/main.yml b/defaults/main.yml index 571aeaf..53f8d2e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -3,4 +3,6 @@ keycloak_home: "/opt/keycloak/keycloak-10.0.2" keycloak_modules: "{{ keycloak_home }}/modules" keycloak_themes: "{{ keycloak_home }}/themes" keycloak_deployments: "{{ keycloak_home }}/standalone/deployments" -update: false +updatethemes: true +updatemodule: false +updateear: false diff --git a/tasks/main.yml b/tasks/main.yml index 6f54b51..1eb7d30 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -8,10 +8,16 @@ state: stopped become: true - - name: "Git checkout of d4sceicne themes" + - name: "Check if the themes are already installed" + stat: + path: "{{ keycloak_themes }}/d4science" + register: d4sciencethemes + + - name: "Git checkout of d4science themes" git: repo: 'https://code-repo.d4science.org/gCubeSystem/d4science-keycloak-themes.git' dest: "/tmp/checkout/d4science-keycloak-themes" + when: not d4sciencethemes.stat.exists or updatethemes - name: "Copy themes in the proper folder" copy: @@ -22,17 +28,18 @@ directory_mode: "yes" mode: "u=rwx,g=rwx,o=" remote_src: "yes" + when: not d4sciencethemes.stat.exists or updatethemes - name: "Check if the avatar-storage module is already installed" stat: path: "{{ keycloak_modules }}/org/gcube/keycloak/avatar-storage/main" register: storagemodule - - name "Remove old avatar-storage module" - ansible.builtin.file: + - name: "Remove old avatar-storage module" + file: path: "{{ keycloak_modules }}/org/gcube/keycloak/avatar-storage" state: absent - when: storagemodule.stat.exists and update + when: storagemodule.stat.exists and updatemodule - name: "Download avatar-storage JAR from Maven repo" maven_artifact: @@ -42,13 +49,13 @@ repository_url: 'https://maven.research-infrastructures.eu/nexus/content/repositories/gcube-staging-jenkins' dest: "/tmp/avatar-storage.jar" verify_checksum: "always" - when: not storagemodule.stat.exists or update + when: not storagemodule.stat.exists or updatemodule - name: "Install avatar-storage Keycloak module" shell: cmd: './bin/jboss-cli.sh --command="module add --name=org.gcube.keycloak.avatar-storage --resources=/tmp/avatar-storage.jar --dependencies=org.keycloak.keycloak-core,org.keycloak.keycloak-services,org.keycloak.keycloak-server-spi,org.keycloak.keycloak-server-spi-private,org.jboss.logging"' chdir: "{{ keycloak_home }}" - when: not storagemodule.stat.exists or update + when: not storagemodule.stat.exists or updatemodule - name: "Switch ON Keycloak server instance" service: @@ -58,7 +65,7 @@ - name: "Waiting for server start" pause: - seconds: 15 + seconds: 20 - name: "Enable avatar-storage module in Keycloak conf" shell: @@ -71,11 +78,18 @@ name: keycloak state: stopped become: true + when: not storagemodule.stat.exists - service: name: keycloak state: started become: true + when: not storagemodule.stat.exists + + - name: "Waiting for server start" + pause: + seconds: 20 + when: not storagemodule.stat.exists - name: "Download keycloak-d4science-bundle EAR from Maven repo" maven_artifact: @@ -85,6 +99,7 @@ repository_url: 'https://maven.research-infrastructures.eu/nexus/content/repositories/gcube-staging-jenkins' dest: "/tmp/keycloak-d4science-bundle.ear" verify_checksum: "always" + when: updateear - name: "Deploy keycloak-d4science-bundle EAR on Keycloak" copy: @@ -95,4 +110,5 @@ directory_mode: "yes" mode: "u=rw,g=rw,o=" remote_src: "yes" + when: updateear