From c7940e4f588aac30556c9b17f933d789393de80b Mon Sep 17 00:00:00 2001 From: Guido Grazioli Date: Tue, 14 Dec 2021 16:20:26 +0100 Subject: [PATCH] Run as root or systemd wont accept the pidfile --- roles/keycloak/defaults/main.yml | 2 +- roles/keycloak/tasks/systemd.yml | 30 ++++---------------- roles/keycloak/templates/keycloak.service.j2 | 5 +--- 3 files changed, 8 insertions(+), 29 deletions(-) diff --git a/roles/keycloak/defaults/main.yml b/roles/keycloak/defaults/main.yml index af9ccdc..b0d574d 100644 --- a/roles/keycloak/defaults/main.yml +++ b/roles/keycloak/defaults/main.yml @@ -20,7 +20,7 @@ keycloak_jboss_home: "{{ keycloak_rhsso_installdir if rhsso_rhn_id is defined el keycloak_config_dir: "{{ keycloak_jboss_home }}/standalone/configuration" keycloak_service_user: keycloak keycloak_service_group: keycloak -keycloak_service_pidfile: "{{ keycloak_dest }}/keycloak.pid" +keycloak_service_pidfile: "/run/keycloak.pid" keycloak_service_logfile: "{{ keycloak_dest }}/keycloak.log" ### Keycloak configuration settings diff --git a/roles/keycloak/tasks/systemd.yml b/roles/keycloak/tasks/systemd.yml index 8584c2e..67fd2e1 100644 --- a/roles/keycloak/tasks/systemd.yml +++ b/roles/keycloak/tasks/systemd.yml @@ -38,30 +38,12 @@ daemon_reload: yes when: systemdunit.changed -- block: - - name: start keycloak - systemd: - name: keycloak - enabled: yes - state: started - become: yes - rescue: - - command: "systemctl status keycloak" - changed_when: False - ignore_errors: True - - command: "journalctl -xe -ukeycloak" - changed_when: False - ignore_errors: True - - command: "tail -n 100 /opt/keycloak/keycloak.log" - changed_when: False - ignore_errors: True - - debug: - msg: "Virt type: {{ ansible_facts.virtualization_type }}" - changed_when: False - ignore_errors: True - - command: "cat /opt/keycloak/keycloak-service.sh" - changed_when: False - ignore_errors: True +- name: start keycloak + systemd: + name: keycloak + enabled: yes + state: started + become: yes - command: "systemctl status keycloak" register: keycloak_service_status diff --git a/roles/keycloak/templates/keycloak.service.j2 b/roles/keycloak/templates/keycloak.service.j2 index 4c55da6..5816af0 100644 --- a/roles/keycloak/templates/keycloak.service.j2 +++ b/roles/keycloak/templates/keycloak.service.j2 @@ -5,13 +5,10 @@ After=network.target [Service] Type=forking EnvironmentFile=-/etc/sysconfig/keycloak - -User={{ keycloak_service_user }} -Group={{ keycloak_service_group }} PIDFile={{ keycloak_service_pidfile }} ExecStart={{ keycloak_dest }}/keycloak-service.sh start ExecStop={{ keycloak_dest }}/keycloak-service.sh stop -TimeoutStartSec=45 +TimeoutStartSec=30 TimeoutStopSec=30 LimitNOFILE=102642