Introduce keycloak_service_restart_always alongside keycloak_service_restart_on_failure

This commit is contained in:
Helmut Wolf 2023-05-31 18:11:00 +02:00
parent 8f042d3e29
commit bc4cb5c52a
4 changed files with 20 additions and 14 deletions

View file

@ -72,10 +72,11 @@ Role Defaults
|`keycloak_config_standalone_xml`| filename for configuration | `keycloak.xml` | |`keycloak_config_standalone_xml`| filename for configuration | `keycloak.xml` |
|`keycloak_service_user`| posix account username | `keycloak` | |`keycloak_service_user`| posix account username | `keycloak` |
|`keycloak_service_group`| posix account group | `keycloak` | |`keycloak_service_group`| posix account group | `keycloak` |
|`keycloak_service_restart_on_failure`| systemd restart-on-failure behavior activation |True |`keycloak_service_restart_always`| systemd restart always behavior activation | `False`
|`keycloak_service_startlimitintervalsec`| systemd StartLimitIntervalSec | `300` if `keycloak_service_restart_on_failure` else `` | |`keycloak_service_restart_on_failure`| systemd restart on-failure behavior activation | `False`
|`keycloak_service_startlimitburst`| systemd StartLimitBurst | `5` if `keycloak_service_restart_on_failure` else `` | |`keycloak_service_startlimitintervalsec`| systemd StartLimitIntervalSec | `300` |
|`keycloak_service_restartsec`| systemd RestartSec | `10s` if `keycloak_service_restart_on_failure` else `` | |`keycloak_service_startlimitburst`| systemd StartLimitBurst | `5` |
|`keycloak_service_restartsec`| systemd RestartSec | `10s` |
|`keycloak_service_pidfile`| pid file path for service | `/run/keycloak.pid` | |`keycloak_service_pidfile`| pid file path for service | `/run/keycloak.pid` |
|`keycloak_features` | List of `name`/`status` pairs of features (also known as profiles on RH-SSO) to `enable` or `disable`, example: `[ { name: 'docker', status: 'enabled' } ]` | `[]` |`keycloak_features` | List of `name`/`status` pairs of features (also known as profiles on RH-SSO) to `enable` or `disable`, example: `[ { name: 'docker', status: 'enabled' } ]` | `[]`
|`keycloak_jvm_package`| RHEL java package runtime | `java-1.8.0-openjdk-headless` | |`keycloak_jvm_package`| RHEL java package runtime | `java-1.8.0-openjdk-headless` |

View file

@ -24,10 +24,11 @@ keycloak_service_name: keycloak
keycloak_service_desc: Keycloak keycloak_service_desc: Keycloak
keycloak_service_start_delay: 10 keycloak_service_start_delay: 10
keycloak_service_start_retries: 25 keycloak_service_start_retries: 25
keycloak_service_restart_on_failure: True keycloak_service_restart_always: False
keycloak_service_startlimitintervalsec: "{{ 300 if keycloak_service_restart_on_failure else '' }}" keycloak_service_restart_on_failure: False
keycloak_service_startlimitburst: "{{ 5 if keycloak_service_restart_on_failure else '' }}" keycloak_service_startlimitintervalsec: "300"
keycloak_service_restartsec: "{{ '10s' if keycloak_service_restart_on_failure else '' }}" keycloak_service_startlimitburst: "5"
keycloak_service_restartsec: "10s"
keycloak_configure_firewalld: False keycloak_configure_firewalld: False

View file

@ -299,9 +299,13 @@ argument_specs:
default: "25" default: "25"
description: "How many time should Ansible retry to connect to the service after it was started, before failing." description: "How many time should Ansible retry to connect to the service after it was started, before failing."
type: "int" type: "int"
keycloak_service_restart_always:
default: false
description: "systemd restart always behavior activation for keycloak"
type: "bool"
keycloak_service_restart_on_failure: keycloak_service_restart_on_failure:
default: true default: false
description: "systemd restart-on-failure behavior activation for keycloak" description: "systemd restart on-failure behavior activation for keycloak"
type: "bool" type: "bool"
keycloak_service_startlimitintervalsec: keycloak_service_startlimitintervalsec:
default: 300 default: 300

View file

@ -2,10 +2,8 @@
[Unit] [Unit]
Description={{ keycloak.service_name }} Server Description={{ keycloak.service_name }} Server
After=network.target After=network.target
{% if keycloak_service_restart_on_failure %}
StartLimitIntervalSec={{ keycloak_service_startlimitintervalsec }} StartLimitIntervalSec={{ keycloak_service_startlimitintervalsec }}
StartLimitBurst={{ keycloak_service_startlimitburst }} StartLimitBurst={{ keycloak_service_startlimitburst }}
{% endif %}
[Service] [Service]
@ -17,10 +15,12 @@ ExecStop={{ keycloak_dest }}/keycloak-service.sh stop
TimeoutStartSec=30 TimeoutStartSec=30
TimeoutStopSec=30 TimeoutStopSec=30
LimitNOFILE=102642 LimitNOFILE=102642
{% if keycloak_service_restart_on_failure %} {% if keycloak_service_restart_always %}
Restart=always
{% elif keycloak_service_restart_on_failure %}
Restart=on-failure Restart=on-failure
RestartSec={{ keycloak_service_restartsec }}
{% endif %} {% endif %}
RestartSec={{ keycloak_service_restartsec }}
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target