mirror of
https://github.com/ansible-middleware/keycloak.git
synced 2026-07-31 03:44:48 +00:00
Fixing linting issues
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
---
|
||||
- name: "Check if packages are already installed" # noqa command-instead-of-module this runs faster
|
||||
ansible.builtin.command: "rpm -q {{ packages_list | join(' ') }}"
|
||||
register: rpm_info
|
||||
register: keycloak_rpm_info
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when: ansible_facts.os_family == "RedHat"
|
||||
|
||||
- name: "Add missing packages to the yum install list"
|
||||
ansible.builtin.set_fact:
|
||||
packages_to_install: "{{ packages_to_install | default([]) + rpm_info.stdout_lines | \
|
||||
keycloak_packages_to_install: "{{ keycloak_packages_to_install | default([]) + keycloak_rpm_info.stdout_lines | \
|
||||
map('regex_findall', 'package (.+) is not installed$') | default([]) | flatten }}"
|
||||
when: ansible_facts.os_family == "RedHat"
|
||||
|
||||
- name: "Install packages: {{ packages_to_install }}"
|
||||
- name: "Install packages: {{ keycloak_packages_to_install }}"
|
||||
become: "{{ keycloak_fastpackages_require_privilege_escalation | default(true) }}"
|
||||
ansible.builtin.dnf:
|
||||
name: "{{ packages_to_install }}"
|
||||
name: "{{ keycloak_packages_to_install }}"
|
||||
state: present
|
||||
when:
|
||||
- packages_to_install | default([]) | length > 0
|
||||
- keycloak_packages_to_install | default([]) | length > 0
|
||||
- ansible_facts.os_family == "RedHat"
|
||||
|
||||
- name: "Install packages: {{ packages_list }}"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
enabled: true
|
||||
state: started
|
||||
|
||||
- name: "Configure firewall ports for {{ keycloak.service_name }}"
|
||||
- name: "Configure firewall ports for {{ keycloak_config.service_name }}"
|
||||
become: "{{ keycloak_firewalld_require_privilege_escalation | default(true) }}"
|
||||
ansible.posix.firewalld:
|
||||
port: "{{ item }}"
|
||||
|
||||
@@ -14,18 +14,18 @@
|
||||
become: "{{ keycloak_install_require_privilege_escalation | default(true) }}"
|
||||
ansible.builtin.stat:
|
||||
path: "{{ keycloak_jboss_home }}"
|
||||
register: existing_deploy
|
||||
register: keycloak_existing_deploy
|
||||
|
||||
- name: Stop and restart if existing deployment exists and install forced
|
||||
when: existing_deploy.stat.exists and keycloak_force_install | bool
|
||||
when: keycloak_existing_deploy.stat.exists and keycloak_force_install | bool
|
||||
block:
|
||||
- name: "Stop the old {{ keycloak.service_name }} service"
|
||||
- name: "Stop the old service: {{ keycloak_config.service_name }}"
|
||||
become: "{{ keycloak_install_require_privilege_escalation | default(true) }}"
|
||||
failed_when: false
|
||||
ansible.builtin.systemd:
|
||||
name: keycloak
|
||||
state: stopped
|
||||
- name: "Remove the old {{ keycloak.service_name }} deployment"
|
||||
- name: "Remove the old deployment: {{ keycloak_config.service_name }}"
|
||||
become: "{{ keycloak_install_require_privilege_escalation | default(true) }}"
|
||||
ansible.builtin.file:
|
||||
path: "{{ keycloak_jboss_home }}"
|
||||
@@ -36,7 +36,7 @@
|
||||
ansible.builtin.stat:
|
||||
path: "{{ keycloak_jboss_home }}"
|
||||
|
||||
- name: "Create service user/group for {{ keycloak.service_name }}"
|
||||
- name: "Create service user/group for {{ keycloak_config.service_name }}"
|
||||
become: "{{ keycloak_install_require_privilege_escalation | default(true) }}"
|
||||
ansible.builtin.user:
|
||||
name: "{{ keycloak_service_user }}"
|
||||
@@ -44,7 +44,7 @@
|
||||
system: true
|
||||
create_home: false
|
||||
|
||||
- name: "Create install location for {{ keycloak.service_name }}"
|
||||
- name: "Create install location for {{ keycloak_config.service_name }}"
|
||||
become: "{{ keycloak_install_require_privilege_escalation | default(true) }}"
|
||||
ansible.builtin.file:
|
||||
dest: "{{ keycloak_dest }}"
|
||||
@@ -65,34 +65,35 @@
|
||||
## check remote archive
|
||||
- name: Set download archive path
|
||||
ansible.builtin.set_fact:
|
||||
archive: "{{ keycloak_dest }}/{{ keycloak.bundle }}"
|
||||
keycloak_archive_full_path: "{{ keycloak_dest }}/{{ keycloak_archive }}"
|
||||
|
||||
- name: Check download archive path
|
||||
become: "{{ keycloak_install_require_privilege_escalation | default(true) }}"
|
||||
ansible.builtin.stat:
|
||||
path: "{{ archive }}"
|
||||
register: archive_path
|
||||
path: "{{ keycloak_archive_full_path }}"
|
||||
register: keycloak_archive_path
|
||||
|
||||
## download to controller
|
||||
- name: Check local download archive path
|
||||
ansible.builtin.stat:
|
||||
path: "{{ lookup('env', 'PWD') }}"
|
||||
register: local_path
|
||||
register: keycloak_local_path
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Download keycloak archive
|
||||
ansible.builtin.get_url: # noqa risky-file-permissions delegated, uses controller host user
|
||||
url: "{{ keycloak_download_url }}"
|
||||
dest: "{{ local_path.stat.path }}/{{ keycloak.bundle }}"
|
||||
dest: "{{ keycloak_local_path.stat.path }}/{{ keycloak_archive }}"
|
||||
mode: '0644'
|
||||
url_username: "{{ keycloak_binary_download_user | default(omit) }}"
|
||||
url_password: "{{ keycloak_binary_download_pass | default(omit) }}"
|
||||
validate_certs: false
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
when:
|
||||
- archive_path is defined
|
||||
- archive_path.stat is defined
|
||||
- not archive_path.stat.exists
|
||||
- keycloak_archive_path is defined
|
||||
- keycloak_archive_path.stat is defined
|
||||
- not keycloak_archive_path.stat.exists
|
||||
- not sso_enable is defined or not sso_enable
|
||||
- not keycloak_offline_install
|
||||
|
||||
@@ -100,9 +101,9 @@
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
when:
|
||||
- archive_path is defined
|
||||
- archive_path.stat is defined
|
||||
- not archive_path.stat.exists
|
||||
- keycloak_archive_path is defined
|
||||
- keycloak_archive_path.stat is defined
|
||||
- not keycloak_archive_path.stat.exists
|
||||
- sso_enable is defined and sso_enable
|
||||
- not keycloak_offline_install
|
||||
block:
|
||||
@@ -113,14 +114,18 @@
|
||||
product_type: DISTRIBUTION
|
||||
product_version: "{{ sso_version.split('.')[:2] | join('.') }}"
|
||||
product_category: "{{ sso_product_category }}"
|
||||
register: rhn_products
|
||||
register: keycloak_rhn_products
|
||||
no_log: "{{ omit_rhn_output | default(true) }}"
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
|
||||
- name: Determine install zipfile from search results
|
||||
ansible.builtin.set_fact:
|
||||
rhn_filtered_products: "{{ rhn_products.results | selectattr('file_name', 'match', '.*rh-sso-' + sso_version.split('.')[:2] | join('.') + '.*-server-dist\\.zip$') | rejectattr('file_name', 'search', 'maven|src|license|provenance|adapter') | list }}"
|
||||
keycloak_rhn_filtered_products: >-
|
||||
{{ keycloak_rhn_products.results
|
||||
| selectattr('file_name', 'match', '.*rh-sso-' + sso_version.split('.')[:2] | join('.') + '.*-server-dist\\.zip$')
|
||||
| rejectattr('file_name', 'search', 'maven|src|license|provenance|adapter')
|
||||
| list }}
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
|
||||
@@ -128,8 +133,8 @@
|
||||
middleware_automation.common.product_download: # noqa risky-file-permissions delegated, uses controller host user
|
||||
client_id: "{{ rhn_username }}"
|
||||
client_secret: "{{ rhn_password }}"
|
||||
product_id: "{{ (rhn_filtered_products | first).id }}"
|
||||
dest: "{{ local_path.stat.path }}/{{ keycloak.bundle }}"
|
||||
product_id: "{{ (keycloak_rhn_filtered_products | first).id }}"
|
||||
dest: "{{ keycloak_local_path.stat.path }}/{{ keycloak_archive }}"
|
||||
no_log: "{{ omit_rhn_output | default(true) }}"
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
@@ -137,68 +142,69 @@
|
||||
- name: Download rhsso archive from alternate location
|
||||
ansible.builtin.get_url: # noqa risky-file-permissions delegated, uses controller host user
|
||||
url: "{{ keycloak_rhsso_download_url }}"
|
||||
dest: "{{ local_path.stat.path }}/{{ keycloak.bundle }}"
|
||||
dest: "{{ keycloak_local_path.stat.path }}/{{ keycloak_archive }}"
|
||||
mode: '0644'
|
||||
validate_certs: false
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
when:
|
||||
- archive_path is defined
|
||||
- archive_path.stat is defined
|
||||
- not archive_path.stat.exists
|
||||
- keycloak_archive_path is defined
|
||||
- keycloak_archive_path.stat is defined
|
||||
- not keycloak_archive_path.stat.exists
|
||||
- sso_enable is defined and sso_enable
|
||||
- not keycloak_offline_install
|
||||
- keycloak_rhsso_download_url is defined
|
||||
|
||||
- name: Check downloaded archive
|
||||
ansible.builtin.stat:
|
||||
path: "{{ local_path.stat.path }}/{{ keycloak.bundle }}"
|
||||
register: local_archive_path
|
||||
path: "{{ keycloak_local_path.stat.path }}/{{ keycloak_archive }}"
|
||||
register: keycloak_local_archive_path
|
||||
delegate_to: localhost
|
||||
|
||||
## copy and unpack
|
||||
- name: Copy archive to target nodes
|
||||
ansible.builtin.copy:
|
||||
src: "{{ local_path.stat.path }}/{{ keycloak.bundle }}"
|
||||
dest: "{{ archive }}"
|
||||
src: "{{ keycloak_local_path.stat.path }}/{{ keycloak_archive }}"
|
||||
dest: "{{ keycloak_archive_full_path }}"
|
||||
owner: "{{ keycloak_service_user }}"
|
||||
group: "{{ keycloak_service_group }}"
|
||||
mode: '0640'
|
||||
register: new_version_downloaded
|
||||
register: keycloak_new_version_downloaded
|
||||
when:
|
||||
- not archive_path.stat.exists
|
||||
- local_archive_path.stat is defined
|
||||
- local_archive_path.stat.exists
|
||||
- not keycloak_archive_path.stat.exists
|
||||
- keycloak_local_archive_path.stat is defined
|
||||
- keycloak_local_archive_path.stat.exists
|
||||
become: "{{ keycloak_install_require_privilege_escalation | default(true) }}"
|
||||
|
||||
- name: "Check target directory: {{ keycloak.home }}"
|
||||
- name: "Check target directory: {{ keycloak_config.home }}"
|
||||
ansible.builtin.stat:
|
||||
path: "{{ keycloak.home }}"
|
||||
register: path_to_workdir
|
||||
path: "{{ keycloak_config.home }}"
|
||||
register: keycloak_path_to_workdir
|
||||
become: "{{ keycloak_install_require_privilege_escalation | default(true) }}"
|
||||
|
||||
- name: "Extract {{ keycloak_service_desc }} archive on target"
|
||||
- name: "Extract archive on target: {{ keycloak_service_desc }}"
|
||||
ansible.builtin.unarchive:
|
||||
remote_src: true
|
||||
src: "{{ archive }}"
|
||||
src: "{{ keycloak_archive_full_path }}"
|
||||
dest: "{{ keycloak_dest }}"
|
||||
creates: "{{ keycloak.home }}"
|
||||
creates: "{{ keycloak_config.home }}"
|
||||
owner: "{{ keycloak_service_user }}"
|
||||
group: "{{ keycloak_service_group }}"
|
||||
become: "{{ keycloak_install_require_privilege_escalation | default(true) }}"
|
||||
when:
|
||||
- new_version_downloaded.changed or not path_to_workdir.stat.exists
|
||||
- keycloak_new_version_downloaded.changed or not keycloak_path_to_workdir.stat.exists
|
||||
notify:
|
||||
- restart keycloak
|
||||
|
||||
- name: Inform decompression was not executed
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ keycloak.home }} already exists and version unchanged, skipping decompression"
|
||||
msg: "{{ keycloak_config.home }} already exists and version unchanged, skipping decompression"
|
||||
when:
|
||||
- not new_version_downloaded.changed and path_to_workdir.stat.exists
|
||||
- not keycloak_new_version_downloaded.changed and keycloak_path_to_workdir.stat.exists
|
||||
|
||||
- name: "Reown installation directory to {{ keycloak_service_user }}"
|
||||
ansible.builtin.file:
|
||||
path: "{{ keycloak.home }}"
|
||||
path: "{{ keycloak_config.home }}"
|
||||
owner: "{{ keycloak_service_user }}"
|
||||
group: "{{ keycloak_service_group }}"
|
||||
recurse: true
|
||||
@@ -206,17 +212,17 @@
|
||||
changed_when: false
|
||||
|
||||
- name: Ensure permissions are correct on existing deploy
|
||||
ansible.builtin.command: chown -R "{{ keycloak_service_user }}:{{ keycloak_service_group }}" "{{ keycloak.home }}"
|
||||
ansible.builtin.command: chown -R "{{ keycloak_service_user }}:{{ keycloak_service_group }}" "{{ keycloak_config.home }}"
|
||||
when: keycloak_service_runas
|
||||
become: "{{ keycloak_install_require_privilege_escalation | default(true) }}"
|
||||
changed_when: false
|
||||
|
||||
# driver and configuration
|
||||
- name: "Install {{ keycloak_jdbc_engine }} driver"
|
||||
- name: "Install database driver: {{ keycloak_jdbc_engine }}"
|
||||
ansible.builtin.include_tasks: jdbc_driver.yml
|
||||
when: keycloak_jdbc[keycloak_jdbc_engine].enabled
|
||||
|
||||
- name: "Deploy custom {{ keycloak.service_name }} config to {{ keycloak_config_path_to_standalone_xml }} from {{ keycloak_config_override_template }}"
|
||||
- name: "Deploy custom config: {{ keycloak_config.service_name }}"
|
||||
become: "{{ keycloak_install_require_privilege_escalation | default(true) }}"
|
||||
ansible.builtin.template:
|
||||
src: "templates/{{ keycloak_config_override_template }}"
|
||||
@@ -228,7 +234,7 @@
|
||||
- restart keycloak
|
||||
when: (keycloak_config_override_template | default('', true)) | length > 0
|
||||
|
||||
- name: "Deploy standalone {{ keycloak.service_name }} config to {{ keycloak_config_path_to_standalone_xml }}"
|
||||
- name: "Deploy standalone config: {{ keycloak_config.service_name }}"
|
||||
become: "{{ keycloak_install_require_privilege_escalation | default(true) }}"
|
||||
ansible.builtin.template:
|
||||
src: templates/standalone.xml.j2
|
||||
@@ -256,7 +262,7 @@
|
||||
loop: "{{ ansible_play_batch }}"
|
||||
when: keycloak_ha_enabled and keycloak_ha_discovery == 'TCPPING'
|
||||
|
||||
- name: "Deploy HA {{ keycloak.service_name }} config to {{ keycloak_config_path_to_standalone_xml }}"
|
||||
- name: "Deploy HA config: {{ keycloak_config.service_name }}"
|
||||
become: "{{ keycloak_install_require_privilege_escalation | default(true) }}"
|
||||
ansible.builtin.template:
|
||||
src: templates/standalone-ha.xml.j2
|
||||
@@ -271,7 +277,7 @@
|
||||
- not keycloak_remote_cache_enabled
|
||||
- (keycloak_config_override_template | default('', true)) | length == 0
|
||||
|
||||
- name: "Deploy HA {{ keycloak.service_name }} config with infinispan remote cache store to {{ keycloak_config_path_to_standalone_xml }}"
|
||||
- name: "Deploy HA config with infinispan: {{ keycloak_config.service_name }}"
|
||||
become: "{{ keycloak_install_require_privilege_escalation | default(true) }}"
|
||||
ansible.builtin.template:
|
||||
src: templates/standalone-infinispan.xml.j2
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
packages_list:
|
||||
- iptables
|
||||
|
||||
- name: "Configure firewall ports for {{ keycloak.service_name }}"
|
||||
- name: "Configure firewall ports for {{ keycloak_config.service_name }}"
|
||||
become: "{{ keycloak_iptables_require_privilege_escalation | default(true) }}"
|
||||
ansible.builtin.iptables:
|
||||
destination_port: "{{ item }}"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
- name: "Check module directory: {{ keycloak_jdbc[keycloak_jdbc_engine].driver_module_dir }}"
|
||||
ansible.builtin.stat:
|
||||
path: "{{ keycloak_jdbc[keycloak_jdbc_engine].driver_module_dir }}"
|
||||
register: dest_path
|
||||
register: keycloak_dest_path
|
||||
become: "{{ keycloak_jdbc_driver_require_privilege_escalation | default(true) }}"
|
||||
|
||||
- name: "Set up module dir for JDBC Driver {{ keycloak_jdbc[keycloak_jdbc_engine].driver_module_name }}"
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
retries: 2
|
||||
delay: 2
|
||||
rescue:
|
||||
- name: "Create {{ keycloak.service_name }} admin user"
|
||||
- name: "Create admin user: {{ keycloak_config.service_name }}"
|
||||
ansible.builtin.command:
|
||||
args:
|
||||
argv:
|
||||
@@ -76,11 +76,11 @@
|
||||
- "-p{{ keycloak_admin_password }}"
|
||||
changed_when: true
|
||||
become: "{{ keycloak_require_privilege_escalation | default(true) }}"
|
||||
- name: "Restart {{ keycloak.service_name }}"
|
||||
- name: "Restart service: {{ keycloak_config.service_name }}"
|
||||
ansible.builtin.include_tasks: tasks/restart_keycloak.yml
|
||||
- name: "Wait until {{ keycloak.service_name }} becomes active {{ keycloak.health_url }}"
|
||||
- name: "Wait until service becomes active: {{ keycloak_config.service_name }}"
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak.health_url }}"
|
||||
url: "{{ keycloak_config.health_url }}"
|
||||
register: keycloak_status
|
||||
until: keycloak_status.status == 200
|
||||
retries: 25
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
- name: "Restart and enable {{ keycloak.service_name }} service"
|
||||
- name: "Restart and enable service: {{ keycloak_config.service_name }}"
|
||||
ansible.builtin.systemd:
|
||||
name: keycloak
|
||||
enabled: true
|
||||
@@ -9,9 +9,9 @@
|
||||
delegate_to: "{{ ansible_play_hosts | first }}"
|
||||
run_once: true
|
||||
|
||||
- name: "Wait until {{ keycloak.service_name }} becomes active {{ keycloak.health_url }}"
|
||||
- name: "Wait until service becomes active: {{ keycloak_config.service_name }}"
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak.health_url }}"
|
||||
url: "{{ keycloak_config.health_url }}"
|
||||
register: keycloak_status
|
||||
until: keycloak_status.status == 200
|
||||
delegate_to: "{{ ansible_play_hosts | first }}"
|
||||
@@ -19,7 +19,7 @@
|
||||
retries: "{{ keycloak_service_start_retries }}"
|
||||
delay: "{{ keycloak_service_start_delay }}"
|
||||
|
||||
- name: "Restart and enable {{ keycloak.service_name }} service"
|
||||
- name: "Restart and enable service (remaining nodes): {{ keycloak_config.service_name }}"
|
||||
ansible.builtin.systemd:
|
||||
name: keycloak
|
||||
enabled: true
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
|
||||
- name: "Execute CLI query: {{ cli_query }}"
|
||||
ansible.builtin.command: >
|
||||
{{ keycloak.cli_path }} --connect --command='{{ cli_query }}' --controller={{ keycloak_host }}:{{ keycloak_management_http_port }}
|
||||
{{ keycloak_config.cli_path }} --connect --command='{{ cli_query }}' --controller={{ keycloak_host }}:{{ keycloak_management_http_port }}
|
||||
changed_when: false
|
||||
register: cli_result
|
||||
register: keycloak_cli_result
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
## check remote patch archive
|
||||
- name: Set download patch archive path
|
||||
ansible.builtin.set_fact:
|
||||
patch_archive: "{{ keycloak_dest }}/{{ sso_patch_bundle }}"
|
||||
patch_bundle: "{{ sso_patch_bundle }}"
|
||||
patch_version: "{{ sso_patch_version }}"
|
||||
keycloak_patch_archive: "{{ keycloak_dest }}/{{ sso_patch_bundle }}"
|
||||
keycloak_patch_bundle: "{{ sso_patch_bundle }}"
|
||||
keycloak_patch_version: "{{ sso_patch_version }}"
|
||||
when: sso_patch_version is defined
|
||||
|
||||
- name: Check download patch archive path
|
||||
ansible.builtin.stat:
|
||||
path: "{{ patch_archive }}"
|
||||
register: patch_archive_path
|
||||
path: "{{ keycloak_patch_archive }}"
|
||||
register: keycloak_patch_archive_path
|
||||
when: sso_patch_version is defined
|
||||
become: "{{ keycloak_rhsso_patch_require_privilege_escalation | default(true) }}"
|
||||
|
||||
@@ -29,14 +29,14 @@
|
||||
product_type: BUGFIX
|
||||
product_version: "{{ sso_version.split('.')[:2] | join('.') }}"
|
||||
product_category: "{{ sso_product_category }}"
|
||||
register: rhn_products
|
||||
register: keycloak_rhn_products
|
||||
no_log: "{{ omit_rhn_output | default(true) }}"
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
|
||||
- name: Determine patch versions list
|
||||
ansible.builtin.set_fact:
|
||||
filtered_versions: "{{ rhn_products.results | map(attribute='file_name') | \
|
||||
keycloak_filtered_versions: "{{ keycloak_rhn_products.results | map(attribute='file_name') | \
|
||||
select('match', '^[^/]*/rh-sso-.*[0-9]*[.][0-9]*[.][0-9]*.*$') | \
|
||||
map('regex_replace', '[^/]*/rh-sso-([0-9]*[.][0-9]*[.][0-9]*(-[0-9])?)-.*', '\\1') | list | unique }}"
|
||||
when: (sso_patch_version | default('', true)) | length == 0
|
||||
@@ -45,25 +45,25 @@
|
||||
|
||||
- name: Determine latest version
|
||||
ansible.builtin.set_fact:
|
||||
sso_latest_version: "{{ filtered_versions | middleware_automation.common.version_sort | last }}"
|
||||
keycloak_sso_latest_version: "{{ keycloak_filtered_versions | middleware_automation.common.version_sort | last }}"
|
||||
when: (sso_patch_version | default('', true)) | length == 0
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
|
||||
- name: Determine install zipfile from search results
|
||||
ansible.builtin.set_fact:
|
||||
rhn_filtered_products: "{{ rhn_products.results | selectattr('file_name', 'match', '[^/]*/rh-sso-' + sso_latest_version + '-patch.zip$') }}"
|
||||
patch_bundle: "rh-sso-{{ sso_latest_version }}-patch.zip"
|
||||
patch_version: "{{ sso_latest_version }}"
|
||||
keycloak_keycloak_rhn_filtered_products: "{{ keycloak_rhn_products.results | selectattr('file_name', 'match', '[^/]*/rh-sso-' + keycloak_sso_latest_version + '-patch.zip$') }}"
|
||||
keycloak_patch_bundle: "rh-sso-{{ keycloak_sso_latest_version }}-patch.zip"
|
||||
keycloak_patch_version: "{{ keycloak_sso_latest_version }}"
|
||||
when: (sso_patch_version | default('', true)) | length == 0
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
|
||||
- name: "Determine selected patch from supplied version: {{ sso_patch_version }}"
|
||||
ansible.builtin.set_fact:
|
||||
rhn_filtered_products: "{{ rhn_products.results | selectattr('file_name', 'match', '[^/]*/' + sso_patch_bundle + '$') }}"
|
||||
patch_bundle: "{{ sso_patch_bundle }}"
|
||||
patch_version: "{{ sso_patch_version }}"
|
||||
keycloak_keycloak_rhn_filtered_products: "{{ keycloak_rhn_products.results | selectattr('file_name', 'match', '[^/]*/' + sso_patch_bundle + '$') }}"
|
||||
keycloak_patch_bundle: "{{ sso_patch_bundle }}"
|
||||
keycloak_patch_version: "{{ sso_patch_version }}"
|
||||
when: sso_patch_version is defined
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
@@ -72,35 +72,35 @@
|
||||
middleware_automation.common.product_download: # noqa risky-file-permissions delegated, uses controller host user
|
||||
client_id: "{{ rhn_username }}"
|
||||
client_secret: "{{ rhn_password }}"
|
||||
product_id: "{{ (rhn_filtered_products | sort | last).id }}"
|
||||
dest: "{{ local_path.stat.path }}/{{ patch_bundle }}"
|
||||
product_id: "{{ (keycloak_rhn_filtered_products | sort | last).id }}"
|
||||
dest: "{{ keycloak_local_path.stat.path }}/{{ keycloak_patch_bundle }}"
|
||||
no_log: "{{ omit_rhn_output | default(true) }}"
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
|
||||
- name: Set download patch archive path
|
||||
ansible.builtin.set_fact:
|
||||
patch_archive: "{{ keycloak_dest }}/{{ patch_bundle }}"
|
||||
keycloak_patch_archive: "{{ keycloak_dest }}/{{ keycloak_patch_bundle }}"
|
||||
|
||||
- name: Check download patch archive path
|
||||
ansible.builtin.stat:
|
||||
path: "{{ patch_archive }}"
|
||||
register: patch_archive_path
|
||||
path: "{{ keycloak_patch_archive }}"
|
||||
register: keycloak_patch_archive_path
|
||||
become: "{{ keycloak_rhsso_patch_require_privilege_escalation | default(true) }}"
|
||||
|
||||
## copy and unpack
|
||||
- name: Copy patch archive to target nodes
|
||||
ansible.builtin.copy:
|
||||
src: "{{ local_path.stat.path }}/{{ patch_bundle }}"
|
||||
dest: "{{ patch_archive }}"
|
||||
src: "{{ keycloak_local_path.stat.path }}/{{ keycloak_patch_bundle }}"
|
||||
dest: "{{ keycloak_patch_archive }}"
|
||||
owner: "{{ keycloak_service_user }}"
|
||||
group: "{{ keycloak_service_group }}"
|
||||
mode: '0640'
|
||||
register: new_version_downloaded
|
||||
register: keycloak_new_version_downloaded
|
||||
when:
|
||||
- not patch_archive_path.stat.exists
|
||||
- local_archive_path.stat is defined
|
||||
- local_archive_path.stat.exists
|
||||
- not keycloak_patch_archive_path.stat.exists
|
||||
- keycloak_local_archive_path.stat is defined
|
||||
- keycloak_local_archive_path.stat.exists
|
||||
become: "{{ keycloak_rhsso_patch_require_privilege_escalation | default(true) }}"
|
||||
|
||||
- name: "Check installed patches"
|
||||
@@ -114,14 +114,14 @@
|
||||
|
||||
- name: "Perform patching"
|
||||
when:
|
||||
- cli_result is defined
|
||||
- cli_result.stdout is defined
|
||||
- patch_version | regex_replace('-[0-9]$', '') not in cli_result.stdout
|
||||
- keycloak_cli_result is defined
|
||||
- keycloak_cli_result.stdout is defined
|
||||
- keycloak_patch_version | regex_replace('-[0-9]$', '') not in keycloak_cli_result.stdout
|
||||
block:
|
||||
- name: "Apply patch {{ patch_version }} to server"
|
||||
- name: "Apply patch to server: {{ keycloak_patch_version }}"
|
||||
ansible.builtin.include_tasks: rhsso_cli.yml
|
||||
vars:
|
||||
cli_query: "patch apply {{ patch_archive }}"
|
||||
cli_query: "patch apply {{ keycloak_patch_archive }}"
|
||||
args:
|
||||
apply:
|
||||
become: "{{ keycloak_rhsso_patch_require_privilege_escalation | default(true) }}"
|
||||
@@ -132,15 +132,15 @@
|
||||
vars:
|
||||
cli_query: "shutdown --restart"
|
||||
when:
|
||||
- cli_result.rc == 0
|
||||
- keycloak_cli_result.rc == 0
|
||||
args:
|
||||
apply:
|
||||
become: "{{ keycloak_rhsso_patch_require_privilege_escalation | default(true) }}"
|
||||
become_user: "{{ keycloak_service_user }}"
|
||||
|
||||
- name: "Wait until {{ keycloak.service_name }} becomes active {{ keycloak.health_url }}"
|
||||
- name: "Wait until service becomes active: {{ keycloak_config.service_name }}"
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak.health_url }}"
|
||||
url: "{{ keycloak_config.health_url }}"
|
||||
register: keycloak_status
|
||||
until: keycloak_status.status == 200
|
||||
retries: 25
|
||||
@@ -158,14 +158,14 @@
|
||||
- name: "Verify installed patch version"
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- patch_version not in cli_result.stdout
|
||||
- keycloak_patch_version not in keycloak_cli_result.stdout
|
||||
fail_msg: "Patch installation failed"
|
||||
success_msg: "Patch installation successful"
|
||||
|
||||
- name: "Skipping patch"
|
||||
ansible.builtin.debug:
|
||||
msg: "Cumulative patch {{ patch_version }} already installed, skipping patch installation."
|
||||
msg: "Cumulative patch {{ keycloak_patch_version }} already installed, skipping patch installation."
|
||||
when:
|
||||
- cli_result is defined
|
||||
- cli_result.stdout is defined
|
||||
- patch_version in cli_result.stdout
|
||||
- keycloak_cli_result is defined
|
||||
- keycloak_cli_result.stdout is defined
|
||||
- keycloak_patch_version in keycloak_cli_result.stdout
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
- name: "Start {{ keycloak.service_name }} service"
|
||||
- name: "Start service: {{ keycloak_config.service_name }}"
|
||||
ansible.builtin.systemd:
|
||||
name: keycloak
|
||||
enabled: true
|
||||
@@ -7,9 +7,9 @@
|
||||
daemon_reload: true
|
||||
become: "{{ keycloak_start_require_privilege_escalation | default(true) }}"
|
||||
|
||||
- name: "Wait until {{ keycloak.service_name }} becomes active {{ keycloak.health_url }}"
|
||||
- name: "Wait until service becomes active: {{ keycloak_config.service_name }}"
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak.health_url }}"
|
||||
url: "{{ keycloak_config.health_url }}"
|
||||
register: keycloak_status
|
||||
until: keycloak_status.status == 200
|
||||
retries: "{{ keycloak_service_start_retries }}"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
- name: "Stop {{ keycloak.service_name }}"
|
||||
- name: "Stop {{ keycloak_config.service_name }}"
|
||||
ansible.builtin.systemd:
|
||||
name: keycloak
|
||||
enabled: true
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
- name: "Configure {{ keycloak.service_name }} service script wrapper"
|
||||
- name: "Configure service script wrapper: {{ keycloak_config.service_name }}"
|
||||
become: "{{ keycloak_systemd_require_privilege_escalation | default(true) }}"
|
||||
ansible.builtin.template:
|
||||
src: keycloak-service.sh.j2
|
||||
@@ -10,7 +10,7 @@
|
||||
notify:
|
||||
- restart keycloak
|
||||
|
||||
- name: "Configure sysconfig file for {{ keycloak.service_name }} service"
|
||||
- name: "Configure sysconfig file for service: {{ keycloak_config.service_name }}"
|
||||
become: "{{ keycloak_systemd_require_privilege_escalation | default(true) }}"
|
||||
ansible.builtin.template:
|
||||
src: keycloak-sysconfig.j2
|
||||
@@ -21,7 +21,7 @@
|
||||
notify:
|
||||
- restart keycloak
|
||||
|
||||
- name: "Configure systemd unit file for {{ keycloak.service_name }} service"
|
||||
- name: "Configure systemd unit file for service: {{ keycloak_config.service_name }}"
|
||||
ansible.builtin.template:
|
||||
src: keycloak.service.j2
|
||||
dest: /etc/systemd/system/keycloak.service
|
||||
@@ -29,16 +29,16 @@
|
||||
group: root
|
||||
mode: '0644'
|
||||
become: "{{ keycloak_systemd_require_privilege_escalation | default(true) }}"
|
||||
register: systemdunit
|
||||
register: keycloak_systemdunit
|
||||
notify:
|
||||
- restart keycloak
|
||||
|
||||
- name: "Start and wait for {{ keycloak.service_name }} service (first node db)"
|
||||
- name: "Start and wait for service (first node db): {{ keycloak_config.service_name }}"
|
||||
ansible.builtin.include_tasks: start_keycloak.yml
|
||||
run_once: true
|
||||
when: keycloak_db_enabled
|
||||
|
||||
- name: "Start and wait for {{ keycloak.service_name }} service (remaining nodes)"
|
||||
- name: "Start and wait for service (remaining nodes): {{ keycloak_config.service_name }}"
|
||||
ansible.builtin.include_tasks: start_keycloak.yml
|
||||
|
||||
- name: Check service status
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{% for feature in keycloak.features %}
|
||||
{% for feature in keycloak_config.features %}
|
||||
feature.{{ feature.name }}={{ feature.status | default('enabled') }}
|
||||
{% endfor %}
|
||||
@@ -17,7 +17,7 @@ checkEnvVar() {
|
||||
# for testing outside systemd
|
||||
. /etc/sysconfig/keycloak
|
||||
|
||||
readonly KEYCLOAK_HOME={{ keycloak.home }}
|
||||
readonly KEYCLOAK_HOME={{ keycloak_config.home }}
|
||||
readonly KEYCLOAK_BIND_ADDRESS=${KEYCLOAK_BIND_ADDRESS}
|
||||
readonly KEYCLOAK_HTTP_PORT=${KEYCLOAK_HTTP_PORT}
|
||||
readonly KEYCLOAK_HTTPS_PORT=${KEYCLOAK_HTTPS_PORT}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{{ ansible_managed | comment }}
|
||||
JAVA_OPTS='{{ keycloak_java_opts }}'
|
||||
JAVA_HOME={{ keycloak_java_home | default(keycloak_pkg_java_home, true) }}
|
||||
JBOSS_HOME={{ keycloak.home }}
|
||||
JBOSS_HOME={{ keycloak_config.home }}
|
||||
KEYCLOAK_BIND_ADDRESS={{ keycloak_bind_address }}
|
||||
KEYCLOAK_HTTP_PORT={{ keycloak_http_port }}
|
||||
KEYCLOAK_HTTPS_PORT={{ keycloak_https_port }}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{{ ansible_managed | comment }}
|
||||
[Unit]
|
||||
Description={{ keycloak.service_name }} Server
|
||||
Description={{ keycloak_config.service_name }} Server
|
||||
After=network.target
|
||||
StartLimitIntervalSec={{ keycloak_service_startlimitintervalsec }}
|
||||
StartLimitBurst={{ keycloak_service_startlimitburst }}
|
||||
@@ -13,8 +13,8 @@ Group={{ keycloak_service_group }}
|
||||
{% endif -%}
|
||||
EnvironmentFile=-{{ keycloak_sysconf_file }}
|
||||
PIDFile={{ keycloak_service_pidfile }}
|
||||
ExecStart={{ keycloak.home }}/bin/standalone.sh $WILDFLY_OPTS
|
||||
WorkingDirectory={{ keycloak.home }}
|
||||
ExecStart={{ keycloak_config.home }}/bin/standalone.sh $WILDFLY_OPTS
|
||||
WorkingDirectory={{ keycloak_config.home }}
|
||||
TimeoutStartSec=30
|
||||
TimeoutStopSec=30
|
||||
LimitNOFILE=102642
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
---
|
||||
# internal variables below
|
||||
|
||||
|
||||
|
||||
keycloak:
|
||||
keycloak_config:
|
||||
home: "{{ keycloak_jboss_home }}"
|
||||
config_dir: "{{ keycloak_config_dir }}"
|
||||
bundle: "{{ keycloak_archive }}"
|
||||
|
||||
Reference in New Issue
Block a user