From ef81faefdfe2ebbf67542b1733405f9ccadec81e Mon Sep 17 00:00:00 2001 From: root Date: Wed, 12 Jan 2022 09:13:53 -0600 Subject: [PATCH] Download source via url --- README.md | 10 +++++++++- roles/keycloak/README.md | 20 +++++++++++++++++++- roles/keycloak/defaults/main.yml | 4 ++-- roles/keycloak/tasks/download_from_rhn.yml | 19 ++++++++++++++++--- roles/keycloak/tasks/install.yml | 2 +- 5 files changed, 47 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7f6ff00..b6cea3d 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ This is default way, no need to define any additional variables. keycloak_zip_file_local_path: ``` -#### Install RHSSO from the Customer Portal, when the following variables are defined +#### Install RHSSO from the Customer Support Portal, when the following variables are defined ``` rhn_username: '' @@ -57,6 +57,14 @@ rhsso_rhn_id: '' where `sso_product_id` is the ID for the specific Red Hat Single Sign-On version, ie. _101971_ will install version _7.5_) +#### Install RHSSO from remote sources like Nexus etc, when the following variables are defined + +``` +rhsso_source_download_url: '' +``` + +where `sso_product_id` is the ID for the specific Red Hat Single Sign-On version, ie. _101971_ will install version _7.5_) + #### Install RHSSO from local source when the following variable is defined ``` diff --git a/roles/keycloak/README.md b/roles/keycloak/README.md index d9e98e2..ddbbc83 100644 --- a/roles/keycloak/README.md +++ b/roles/keycloak/README.md @@ -72,6 +72,11 @@ The following variables can be used to install Keycloak or Red Hat Single Sign-O |`rhsso_zip_file_local_path` | Full local path of Red Hat Single Sign-On zip file | `tmp/rhsso/rh-sso-7.5-server-dist.zip` | |`keycloak_zip_file_local_path` | Full local path of Keycloak zip file | `/tmp/keycloak/keycloak-16.1.0.zip` | +The following variable can be used to install Red Hat Single Sign-On from source via url, auth support is not added right now. +| Variable | Description | Default | +|:---------|:------------|:---------| +|`rhsso_source_download_url` | URL to download Red Hat Single Sign-On zip file from | `http://localhost:8081/nexus/rhsso/rh-sso-7.5-server-dist.zip` | + Dependencies ------------ @@ -133,6 +138,20 @@ The following is an example playbook that makes use of the role to install Red H keycloak_admin_password: "changeme" ``` +The following is an example playbook that makes use of the role to install Red Hat Single Sign-On from source url + +```yaml +--- +- hosts: keycloak + tasks: + - name: Keycloak Role + include_role: + name: keycloak + vars: + keycloak_admin_password: "changeme" + rhsso_source_download_url: "" # This should be the full of remote source rhsso zip file +``` + The following is an example playbook that makes use of the role to install Red Hat Single Sign-On from local path ```yaml @@ -147,7 +166,6 @@ The following is an example playbook that makes use of the role to install Red H rhsso_zip_file_local_path: "/tmp/rhsso/rh-sso-7.5-server-dist.zip" # This should be local path of rhsso zip file ``` - License ------- diff --git a/roles/keycloak/defaults/main.yml b/roles/keycloak/defaults/main.yml index 3a4656e..638c237 100644 --- a/roles/keycloak/defaults/main.yml +++ b/roles/keycloak/defaults/main.yml @@ -6,7 +6,7 @@ keycloak_download_url: https://downloads.jboss.org/keycloak/{{ keycloak_version keycloak_installdir: "{{ keycloak_dest }}/keycloak-{{ keycloak_version }}" ### Configuration specific to Red Hat Single Sing-On -keycloak_rhsso_enable: "{{ True if rhsso_rhn_id is defined or rhsso_zip_file_local_path is defined else False }}" +keycloak_rhsso_enable: "{{ True if rhsso_rhn_id is defined or rhsso_zip_file_local_path is defined or rhsso_source_download_url is defined else False }}" keycloak_rhsso_version: 7.5 keycloak_rhsso_archive: rh-sso-{{ keycloak_rhsso_version }}-server-dist.zip keycloak_rhsso_installdir: "{{ keycloak_dest }}/rh-sso-{{ keycloak_rhsso_version }}" @@ -15,7 +15,7 @@ keycloak_rhsso_base_url: 'https://access.redhat.com/jbossnetwork/restricted/soft ### Install location and service settings jvm_package: java-1.8.0-openjdk-devel keycloak_dest: /opt/keycloak -keycloak_jboss_home: "{{ keycloak_rhsso_installdir if rhsso_rhn_id is defined or rhsso_zip_file_local_path is defined else keycloak_installdir }}" +keycloak_jboss_home: "{{ keycloak_rhsso_installdir if rhsso_rhn_id is defined or rhsso_zip_file_local_path is defined or rhsso_source_download_url is defined else keycloak_installdir }}" keycloak_config_dir: "{{ keycloak_jboss_home }}/standalone/configuration" keycloak_config_standalone_xml: "keycloak.xml" diff --git a/roles/keycloak/tasks/download_from_rhn.yml b/roles/keycloak/tasks/download_from_rhn.yml index 3ed54e6..1fef600 100644 --- a/roles/keycloak/tasks/download_from_rhn.yml +++ b/roles/keycloak/tasks/download_from_rhn.yml @@ -2,7 +2,7 @@ - assert: that: - zipfile_dest is defined - - (rhn_username is defined and rhn_password is defined and rhn_id_file is defined) or rhsso_zip_file_local_path is defined + - (rhn_username is defined and rhn_password is defined and rhn_id_file is defined) or rhsso_zip_file_local_path is defined or rhsso_source_download_url is defined quiet: true - set_fact: @@ -13,7 +13,7 @@ path: "{{ zipfile_dest }}" register: archive_path -- name: "Install zipfile from RHN: {{ rhn_download_url }}" +- name: "Download zipfile from RHN: {{ rhn_download_url }}" redhat_csp_download: url: "{{ rhn_download_url }}" dest: "{{ zipfile_dest }}" @@ -24,7 +24,20 @@ - archive_path is defined - archive_path.stat is defined - not archive_path.stat.exists - - not rhsso_zip_file_local_path is defined + - rhsso_rhn_id is defined + +- name: "Copy zipfile from source like Nexus etc : {{ rhsso_source_download_url }}" + get_url: + url: "{{ rhsso_source_download_url }}" + dest: "{{ zipfile_dest }}" + owner: "{{ keycloak_service_user }}" + group: "{{ keycloak_service_group }}" + mode: 0750 + when: + - archive_path is defined + - archive_path.stat is defined + - not archive_path.stat.exists + - rhsso_source_download_url is defined - name: "Copy zipfile from local source: {{ rhsso_zip_file_local_path }}" ansible.builtin.copy: diff --git a/roles/keycloak/tasks/install.yml b/roles/keycloak/tasks/install.yml index 7b687af..40b87f1 100644 --- a/roles/keycloak/tasks/install.yml +++ b/roles/keycloak/tasks/install.yml @@ -105,7 +105,7 @@ - block: - assert: that: - - rhsso_rhn_id is defined or rhsso_zip_file_local_path is defined + - rhsso_rhn_id is defined or rhsso_zip_file_local_path is defined or rhsso_source_download_url is defined quiet: true fail_msg: "Can't install RHSSO without either RHN ID or RHSSO zip file local path"