Compare commits

..

5 Commits

Author SHA1 Message Date
Guillaume Dott 91b37a910e Replace yum with apt for Debian support 2022-10-05 14:55:42 +02:00
Guido Grazioli 65da436d74
restart handler: orchestrate 2022-09-28 16:48:40 +02:00
Guido Grazioli be582171ce
restart handler: orchestrate 2022-09-28 16:30:26 +02:00
Guido Grazioli a7fbce2990
New variable for binding of management ports 2022-09-28 15:33:30 +02:00
Guido Grazioli dfc1912a99
jdbc_driver: switch from uri to get_url 2022-09-27 15:36:14 +02:00
9 changed files with 41 additions and 14 deletions

View File

@ -26,6 +26,7 @@ warn_list:
- jinja[spacing] - jinja[spacing]
- jinja[invalid] - jinja[invalid]
- meta-no-tags - meta-no-tags
- name[template]
skip_list: skip_list:
- vars_should_not_be_used - vars_should_not_be_used

View File

@ -52,6 +52,7 @@ Role Defaults
|`keycloak_db_enabled`| Enable auto configuration for database backend | `True` if `keycloak_ha_enabled` is True, else `False` | |`keycloak_db_enabled`| Enable auto configuration for database backend | `True` if `keycloak_ha_enabled` is True, else `False` |
|`keycloak_admin_user`| Administration console user account | `admin` | |`keycloak_admin_user`| Administration console user account | `admin` |
|`keycloak_bind_address`| Address for binding service ports | `0.0.0.0` | |`keycloak_bind_address`| Address for binding service ports | `0.0.0.0` |
|`keycloak_management_port_bind_address`| Address for binding management ports | `127.0.0.1` |
|`keycloak_host`| hostname | `localhost` | |`keycloak_host`| hostname | `localhost` |
|`keycloak_http_port`| HTTP port | `8080` | |`keycloak_http_port`| HTTP port | `8080` |
|`keycloak_https_port`| TLS HTTP port | `8443` | |`keycloak_https_port`| TLS HTTP port | `8443` |

View File

@ -8,7 +8,7 @@ keycloak_installdir: "{{ keycloak_dest }}/keycloak-{{ keycloak_version }}"
keycloak_offline_install: False keycloak_offline_install: False
### Install location and service settings ### Install location and service settings
keycloak_jvm_package: java-1.8.0-openjdk-headless keycloak_jvm_package: openjdk-17-jdk-headless
keycloak_java_home: keycloak_java_home:
keycloak_dest: /opt/keycloak keycloak_dest: /opt/keycloak
keycloak_jboss_home: "{{ keycloak_installdir }}" keycloak_jboss_home: "{{ keycloak_installdir }}"
@ -34,6 +34,7 @@ keycloak_http_port: 8080
keycloak_https_port: 8443 keycloak_https_port: 8443
keycloak_ajp_port: 8009 keycloak_ajp_port: 8009
keycloak_jgroups_port: 7600 keycloak_jgroups_port: 7600
keycloak_management_port_bind_address: 127.0.0.1
keycloak_management_http_port: 9990 keycloak_management_http_port: 9990
keycloak_management_https_port: 9993 keycloak_management_https_port: 9993
keycloak_java_opts: "-Xms1024m -Xmx2048m" keycloak_java_opts: "-Xms1024m -Xmx2048m"

View File

@ -94,6 +94,10 @@ argument_specs:
default: "0.0.0.0" default: "0.0.0.0"
description: "Address for binding service ports" description: "Address for binding service ports"
type: "str" type: "str"
keycloak_management_port_bind_address:
default: "127.0.0.1"
description: "Address for binding the managemnt ports"
type: "str"
keycloak_host: keycloak_host:
# line 35 of keycloak/defaults/main.yml # line 35 of keycloak/defaults/main.yml
default: "localhost" default: "localhost"

View File

@ -2,21 +2,21 @@
- name: Check packages to be installed - name: Check packages to be installed
block: block:
- name: "Check if packages are already installed" - name: "Check if packages are already installed"
ansible.builtin.command: "rpm -q {{ packages_list | join(' ') }}" ansible.builtin.command: "dpkg -s {{ packages_list | join(' ') }}"
args: args:
warn: no warn: no
register: rpm_info register: dpkg_info
changed_when: rpm_info.failed changed_when: dpkg_info.failed
rescue: rescue:
- name: "Add missing packages to the yum install list" - name: "Add missing packages to the apt install list"
ansible.builtin.set_fact: ansible.builtin.set_fact:
packages_to_install: "{{ packages_to_install | default([]) + rpm_info.stdout_lines | map('regex_findall', 'package (.+) is not installed$') | flatten }}" packages_to_install: "{{ packages_to_install | default([]) + dpkg_info.stdout_lines | map('regex_findall', 'package (.+) is not installed and no information is available$') | flatten }}"
when: rpm_info.failed when: rpm_info.failed
- name: "Install packages: {{ packages_to_install }}" - name: Install packages
become: yes become: yes
ansible.builtin.yum: ansible.builtin.apt:
name: "{{ packages_to_install }}" name: "{{ packages_to_install }}"
state: present state: present
when: packages_to_install | default([]) | length > 0 when: packages_to_install | default([]) | length > 0

View File

@ -18,7 +18,7 @@
- not dest_path.stat.exists - not dest_path.stat.exists
- name: "Retrieve JDBC Driver from {{ keycloak_jdbc[keycloak_jdbc_engine].driver_jar_url }}" - name: "Retrieve JDBC Driver from {{ keycloak_jdbc[keycloak_jdbc_engine].driver_jar_url }}"
ansible.builtin.uri: ansible.builtin.get_url:
url: "{{ keycloak_jdbc[keycloak_jdbc_engine].driver_jar_url }}" url: "{{ keycloak_jdbc[keycloak_jdbc_engine].driver_jar_url }}"
dest: "{{ keycloak_jdbc[keycloak_jdbc_engine].driver_module_dir }}/{{ keycloak_jdbc[keycloak_jdbc_engine].driver_jar_filename }}" dest: "{{ keycloak_jdbc[keycloak_jdbc_engine].driver_module_dir }}/{{ keycloak_jdbc[keycloak_jdbc_engine].driver_jar_filename }}"
group: "{{ keycloak_service_group }}" group: "{{ keycloak_service_group }}"

View File

@ -5,3 +5,23 @@
enabled: yes enabled: yes
state: restarted state: restarted
become: yes become: yes
delegate_to: "{{ ansible_play_hosts | first }}"
run_once: True
- name: "Wait until {{ keycloak.service_name }} becomes active {{ keycloak.health_url }}"
ansible.builtin.uri:
url: "{{ keycloak.health_url }}"
register: keycloak_status
until: keycloak_status.status == 200
delegate_to: "{{ ansible_play_hosts | first }}"
run_once: True
retries: 25
delay: 10
- name: "Restart and enable {{ keycloak.service_name }} service"
ansible.builtin.systemd:
name: keycloak
enabled: yes
state: restarted
become: yes
when: inventory_hostname != ansible_play_hosts | first

View File

@ -724,7 +724,7 @@
</profile> </profile>
<interfaces> <interfaces>
<interface name="management"> <interface name="management">
<inet-address value="${jboss.bind.address.management:127.0.0.1}"/> <inet-address value="{{ keycloak_management_port_bind_address }}"/>
</interface> </interface>
<interface name="jgroups"> <interface name="jgroups">
{% if ansible_default_ipv4 is defined %} {% if ansible_default_ipv4 is defined %}
@ -734,7 +734,7 @@
{% endif %} {% endif %}
</interface> </interface>
<interface name="public"> <interface name="public">
<inet-address value="${jboss.bind.address:127.0.0.1}"/> <inet-address value="{{ keycloak_bind_address }}"/>
</interface> </interface>
</interfaces> </interfaces>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}"> <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">

View File

@ -632,10 +632,10 @@
</profile> </profile>
<interfaces> <interfaces>
<interface name="management"> <interface name="management">
<inet-address value="${jboss.bind.address.management:127.0.0.1}"/> <inet-address value="{{ keycloak_management_port_bind_address }}"/>
</interface> </interface>
<interface name="public"> <interface name="public">
<inet-address value="${jboss.bind.address:127.0.0.1}"/> <inet-address value="{{ keycloak_bind_address }}"/>
</interface> </interface>
</interfaces> </interfaces>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}"> <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">