Rewrite initd/systemd scripts interaction

main
Guido Grazioli 2021-12-14 16:01:41 +01:00
parent 26fe41595d
commit e14220a01b
3 changed files with 17 additions and 33 deletions

View File

@ -38,7 +38,7 @@ jobs:
working-directory: ./ansible_collections/middleware_automation/keycloak working-directory: ./ansible_collections/middleware_automation/keycloak
- name: Run molecule test - name: Run molecule test
run: molecule test --all -- -vvvvv run: molecule test --all
working-directory: ./ansible_collections/middleware_automation/keycloak working-directory: ./ansible_collections/middleware_automation/keycloak
env: env:
PY_COLORS: '1' PY_COLORS: '1'

View File

@ -38,30 +38,12 @@
daemon_reload: yes daemon_reload: yes
when: systemdunit.changed when: systemdunit.changed
- block: - name: start keycloak
- name: start keycloak
systemd: systemd:
name: keycloak name: keycloak
enabled: yes enabled: yes
state: started state: started
become: yes 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 }} - {{ ansible_facts['virtualization_type'] }}"
changed_when: False
ignore_errors: True
- command: "cat /opt/keycloak/keycloak-service.sh"
changed_when: False
ignore_errors: True
- command: "systemctl status keycloak" - command: "systemctl status keycloak"
register: keycloak_service_status register: keycloak_service_status

View File

@ -75,14 +75,16 @@ startKeycloak() {
if [ "$(isKeyCloakRunning)" -eq 1 ]; then if [ "$(isKeyCloakRunning)" -eq 1 ]; then
statusKeycloak statusKeycloak
else else
JLAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PIDFILE=${KEYCLOAK_PIDFILE} ${KEYCLOAK_HOME}/bin/standalone.sh \ LAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PIDFILE=${KEYCLOAK_PIDFILE} ${KEYCLOAK_HOME}/bin/standalone.sh \
-Djboss.bind.address=${KEYCLOAK_BIND_ADDRESS} \ -Djboss.bind.address=${KEYCLOAK_BIND_ADDRESS} \
-Djboss.http.port=${KEYCLOAK_HTTP_PORT} \ -Djboss.http.port=${KEYCLOAK_HTTP_PORT} \
-Djboss.https.port=${KEYCLOAK_HTTPS_PORT} \ -Djboss.https.port=${KEYCLOAK_HTTPS_PORT} \
-Djboss.management.http.port=${KEYCLOAK_MANAGEMENT_HTTP_PORT} \ -Djboss.management.http.port=${KEYCLOAK_MANAGEMENT_HTTP_PORT} \
-Djboss.management.https.port=${KEYCLOAK_MANAGEMENT_HTTPS_PORT} \ -Djboss.management.https.port=${KEYCLOAK_MANAGEMENT_HTTPS_PORT} \
-Djboss.node.name={{ inventory_hostname }} {% if ansible_facts.virtualization_type in ['docker','containerd'] %}-Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true {% endif %}\ -Djboss.node.name={{ inventory_hostname }} \
{% if ansible_facts.virtualization_type in ['docker','oci','containerd'] %}-Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true {% endif %}\
2>&1 >> "${KEYCLOAK_LOGFILE}" & 2>&1 >> "${KEYCLOAK_LOGFILE}" &
while [ ! -f ${KEYCLOAK_PIDFILE} ]; do sleep 1; done
fi fi
} }