mirror of
https://github.com/ansible-middleware/keycloak.git
synced 2025-07-29 08:01:33 -07:00
fix: use FQCN
This commit is contained in:
parent
73bbca9fc1
commit
b90684a44a
21 changed files with 84 additions and 79 deletions
|
@ -1,3 +1,3 @@
|
|||
---
|
||||
- name: restart keycloak
|
||||
include_tasks: restart_keycloak.yml
|
||||
ansible.builtin.include_tasks: restart_keycloak.yml
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
- block:
|
||||
- name: "Check if package {{ package_name }} is already installed"
|
||||
command: rpm -q {{ package_name }}
|
||||
ansible.builtin.command: rpm -q {{ package_name }}
|
||||
args:
|
||||
warn: no
|
||||
register: rpm_info
|
||||
|
@ -9,6 +9,6 @@
|
|||
|
||||
rescue:
|
||||
- name: "Add {{ package_name }} to the yum install list if missing"
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
packages_to_install: "{{ packages_to_install + [ package_name ] }}"
|
||||
when: rpm_info.failed
|
|
@ -1,18 +1,18 @@
|
|||
---
|
||||
- name: Set facts
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
update_cache: true
|
||||
packages_to_install: []
|
||||
|
||||
- name: "Check packages to be installed"
|
||||
include_tasks: check.yml
|
||||
ansible.builtin.include_tasks: check.yml
|
||||
loop: "{{ packages_list | flatten }}"
|
||||
loop_control:
|
||||
loop_var: package_name
|
||||
|
||||
- name: "Install packages: {{ packages_to_install }}"
|
||||
become: yes
|
||||
yum:
|
||||
ansible.builtin.yum:
|
||||
name: "{{ packages_to_install }}"
|
||||
state: present
|
||||
when: packages_to_install | length > 0
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
- name: Enable and start the firewalld service
|
||||
become: yes
|
||||
systemd:
|
||||
ansible.builtin.systemd:
|
||||
name: firewalld
|
||||
enabled: yes
|
||||
state: started
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
- name: Validate parameters
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- keycloak_jboss_home is defined
|
||||
- keycloak_service_user is defined
|
||||
|
@ -12,7 +12,7 @@
|
|||
|
||||
- name: Check for an existing deployment
|
||||
become: yes
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ keycloak_jboss_home }}"
|
||||
register: existing_deploy
|
||||
|
||||
|
@ -20,24 +20,24 @@
|
|||
- name: Stop the old keycloak service
|
||||
become: yes
|
||||
ignore_errors: yes
|
||||
systemd:
|
||||
ansible.builtin.systemd:
|
||||
name: keycloak
|
||||
state: stopped
|
||||
- name: Remove the old Keycloak deployment
|
||||
become: yes
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ keycloak_jboss_home }}"
|
||||
state: absent
|
||||
when: existing_deploy.stat.exists and keycloak_force_install|bool
|
||||
|
||||
- name: check for an existing deployment after possible forced removal
|
||||
become: yes
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ keycloak_jboss_home }}"
|
||||
|
||||
- name: create Keycloak service user/group
|
||||
become: yes
|
||||
user:
|
||||
ansible.builtin.user:
|
||||
name: "{{ keycloak_service_user }}"
|
||||
home: /opt/keycloak
|
||||
system: yes
|
||||
|
@ -45,7 +45,7 @@
|
|||
|
||||
- name: create Keycloak install location
|
||||
become: yes
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
dest: "{{ keycloak_dest }}"
|
||||
state: directory
|
||||
owner: "{{ keycloak_service_user }}"
|
||||
|
@ -54,23 +54,23 @@
|
|||
|
||||
## check remote archive
|
||||
- name: Set download archive path
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
archive: "{{ keycloak_dest }}/{{ keycloak.bundle }}"
|
||||
|
||||
- name: Check download archive path
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ archive }}"
|
||||
register: archive_path
|
||||
|
||||
## download to controller
|
||||
- name: Check local download archive path
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ lookup('env', 'PWD') }}"
|
||||
register: local_path
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Download keycloak archive
|
||||
get_url:
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ keycloak_download_url }}"
|
||||
dest: "{{ local_path.stat.path }}/{{ keycloak.bundle }}"
|
||||
delegate_to: localhost
|
||||
|
@ -82,7 +82,7 @@
|
|||
- not keycloak_offline_install
|
||||
|
||||
- name: Perform download from RHN
|
||||
redhat_csp_download:
|
||||
middleware_automation.redhat_csp_download.redhat_csp_download:
|
||||
url: "{{ keycloak_rhsso_download_url }}"
|
||||
dest: "{{ local_path.stat.path }}/{{ keycloak.bundle }}"
|
||||
username: "{{ rhn_username }}"
|
||||
|
@ -98,7 +98,7 @@
|
|||
- keycloak_rhn_url in keycloak_rhsso_download_url
|
||||
|
||||
- name: Download rhsso archive from alternate location
|
||||
get_url:
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ keycloak_rhsso_download_url }}"
|
||||
dest: "{{ local_path.stat.path }}/{{ keycloak.bundle }}"
|
||||
delegate_to: localhost
|
||||
|
@ -111,14 +111,14 @@
|
|||
- not keycloak_rhn_url in keycloak_rhsso_download_url
|
||||
|
||||
- name: Check downloaded archive
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ local_path.stat.path }}/{{ keycloak.bundle }}"
|
||||
register: local_archive_path
|
||||
delegate_to: localhost
|
||||
|
||||
## copy and unpack
|
||||
- name: Copy archive to target nodes
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
src: "{{ local_path.stat.path }}/{{ keycloak.bundle }}"
|
||||
dest: "{{ archive }}"
|
||||
owner: "{{ keycloak_service_user }}"
|
||||
|
@ -132,13 +132,13 @@
|
|||
become: yes
|
||||
|
||||
- name: "Check target directory: {{ keycloak.home }}"
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ keycloak.home }}"
|
||||
register: path_to_workdir
|
||||
become: yes
|
||||
|
||||
- name: "Extract {{ 'Red Hat Single Sign-On' if keycloak_rhsso_enable else 'Keycloak' }} archive on target"
|
||||
unarchive:
|
||||
ansible.builtin.unarchive:
|
||||
remote_src: yes
|
||||
src: "{{ archive }}"
|
||||
dest: "{{ keycloak_dest }}"
|
||||
|
@ -152,13 +152,13 @@
|
|||
- restart keycloak
|
||||
|
||||
- name: Inform decompression was not executed
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ keycloak.home }} already exists and version unchanged, skipping decompression"
|
||||
when:
|
||||
- not new_version_downloaded.changed and path_to_workdir.stat.exists
|
||||
|
||||
- name: "Reown installation directory to {{ keycloak_service_user }}"
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ keycloak.home }}"
|
||||
owner: "{{ keycloak_service_user }}"
|
||||
group: "{{ keycloak_service_group }}"
|
||||
|
@ -168,8 +168,8 @@
|
|||
|
||||
# driver and configuration
|
||||
- name: "Install {{ keycloak_jdbc_engine }} driver"
|
||||
include_role:
|
||||
name: wildfly_driver
|
||||
ansible.builtin.include_role:
|
||||
name: middleware_automation.wildfly.wildfly_driver
|
||||
vars:
|
||||
wildfly_user: "{{ keycloak_service_user }}"
|
||||
jdbc_driver_module_dir: "{{ keycloak_jdbc[keycloak_jdbc_engine].driver_module_dir }}"
|
||||
|
@ -182,7 +182,7 @@
|
|||
|
||||
- name: "Deploy {{ keycloak.service_name }} config to {{ keycloak_config_path_to_standalone_xml }}"
|
||||
become: yes
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: templates/standalone.xml.j2
|
||||
dest: "{{ keycloak_config_path_to_standalone_xml }}"
|
||||
owner: "{{ keycloak_service_user }}"
|
||||
|
@ -194,7 +194,7 @@
|
|||
|
||||
- name: "Deploy {{ keycloak.service_name }} config with remote cache store to {{ keycloak_config_path_to_standalone_xml }}"
|
||||
become: yes
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: templates/standalone-infinispan.xml.j2
|
||||
dest: "{{ keycloak_config_path_to_standalone_xml }}"
|
||||
owner: "{{ keycloak_service_user }}"
|
||||
|
|
|
@ -2,25 +2,25 @@
|
|||
# tasks file for keycloak
|
||||
|
||||
- name: Check prerequisites
|
||||
include_tasks: prereqs.yml
|
||||
ansible.builtin.include_tasks: prereqs.yml
|
||||
tags:
|
||||
- prereqs
|
||||
|
||||
- name: Include install tasks
|
||||
include_tasks: tasks/install.yml
|
||||
ansible.builtin.include_tasks: tasks/install.yml
|
||||
|
||||
- name: Include systemd tasks
|
||||
include_tasks: tasks/systemd.yml
|
||||
ansible.builtin.include_tasks: tasks/systemd.yml
|
||||
|
||||
- name: Link default logs directory
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
state: link
|
||||
src: "{{ keycloak_jboss_home }}/standalone/log"
|
||||
dest: /var/log/keycloak
|
||||
|
||||
- block:
|
||||
- name: Check admin credentials by generating a token
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak_url }}/auth/realms/master/protocol/openid-connect/token"
|
||||
method: POST
|
||||
body: "client_id={{ keycloak_auth_client }}&username={{ keycloak_admin_user }}&password={{ keycloak_admin_password }}&grant_type=password"
|
||||
|
@ -31,7 +31,7 @@
|
|||
delay: 2
|
||||
rescue:
|
||||
- name: "Create {{ keycloak.service_name }} admin user"
|
||||
command:
|
||||
ansible.builtin.command:
|
||||
args:
|
||||
argv:
|
||||
- "{{ keycloak_jboss_home }}/bin/add-user-keycloak.sh"
|
||||
|
@ -41,9 +41,9 @@
|
|||
changed_when: yes
|
||||
become: yes
|
||||
- name: "Restart {{ keycloak.service_name }}"
|
||||
include_tasks: tasks/restart_keycloak.yml
|
||||
ansible.builtin.include_tasks: tasks/restart_keycloak.yml
|
||||
- name: "Wait until {{ keycloak.service_name }} becomes active {{ keycloak.health_url }}"
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak.health_url }}"
|
||||
register: keycloak_status
|
||||
until: keycloak_status.status == 200
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
- name: Validate configuration
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- (keycloak_ha_enabled and keycloak_db_enabled) or (not keycloak_ha_enabled and keycloak_db_enabled) or (not keycloak_ha_enabled and not keycloak_db_enabled)
|
||||
quiet: True
|
||||
|
@ -8,7 +8,7 @@
|
|||
success_msg: "{{ 'Configuring HA' if keycloak_ha_enabled else 'Configuring standalone' }}"
|
||||
|
||||
- name: Validate credentials
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- (rhn_username is defined and keycloak_rhsso_enable) or not keycloak_rhsso_enable or keycloak_offline_install
|
||||
- (rhn_password is defined and keycloak_rhsso_enable) or not keycloak_rhsso_enable or keycloak_offline_install
|
||||
|
@ -17,7 +17,7 @@
|
|||
success_msg: "{{ 'Installing Red Hat Single Sign-On' if keycloak_rhsso_enable else 'Installing keycloak.org' }}"
|
||||
|
||||
- name: Set required packages facts
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
required_packages:
|
||||
- "{{ jvm_package }}"
|
||||
- unzip
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
- name: "Restart and enable keycloack service"
|
||||
systemd:
|
||||
ansible.builtin.systemd:
|
||||
name: keycloak
|
||||
enabled: yes
|
||||
state: restarted
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
- name: "Stop SSO service"
|
||||
systemd:
|
||||
ansible.builtin.systemd:
|
||||
name: keycloak
|
||||
enabled: yes
|
||||
state: stopped
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
- name: configure keycloak service script wrapper
|
||||
become: yes
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: keycloak-service.sh.j2
|
||||
dest: "{{ keycloak_dest }}/keycloak-service.sh"
|
||||
owner: root
|
||||
|
@ -11,7 +11,7 @@
|
|||
|
||||
- name: configure sysconfig file for keycloak service
|
||||
become: yes
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: keycloak-sysconfig.j2
|
||||
dest: /etc/sysconfig/keycloak
|
||||
owner: root
|
||||
|
@ -21,7 +21,7 @@
|
|||
- restart keycloak
|
||||
|
||||
- name: configure systemd unit file for keycloak service
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: keycloak.service.j2
|
||||
dest: /etc/systemd/system/keycloak.service
|
||||
owner: root
|
||||
|
@ -34,33 +34,33 @@
|
|||
|
||||
- name: reload systemd
|
||||
become: yes
|
||||
systemd:
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: yes
|
||||
when: systemdunit.changed
|
||||
|
||||
- name: start keycloak
|
||||
systemd:
|
||||
ansible.builtin.systemd:
|
||||
name: keycloak
|
||||
enabled: yes
|
||||
state: started
|
||||
become: yes
|
||||
|
||||
- name: Check service status
|
||||
command: "systemctl status keycloak"
|
||||
ansible.builtin.command: "systemctl status keycloak"
|
||||
register: keycloak_service_status
|
||||
changed_when: False
|
||||
|
||||
- name: Verify service status
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- keycloak_service_status is defined
|
||||
- keycloak_service_status.stdout is defined
|
||||
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
ansible.builtin.meta: flush_handlers
|
||||
|
||||
- name: "Wait until Keycloak becomes active {{ keycloak.health_url }}"
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak.health_url }}"
|
||||
register: keycloak_status
|
||||
until: keycloak_status.status == 200
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue