Skip to content

Commit

Permalink
Fix the (re)start logic for the services
Browse files Browse the repository at this point in the history
We need to start the services in a specific order, e.g.
1. verifier -> 2. registrar -> 3. agent, and in some
extra configuration/files are created, such as CA and/or
certificates, so a service may take some time before it is
ready.

Let's now check whether the verifier is accesible -- via its
port --, before starting the registrar.

Signed-off-by: Sergio Correia <scorreia@redhat.com>
  • Loading branch information
sergio-correia committed Jul 24, 2023
1 parent dac5984 commit b9845bf
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
5 changes: 1 addition & 4 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# SPDX-License-Identifier: MIT
---
- name: Restart services
service:
name: "{{ item }}"
state: restarted
loop: "{{ __keylime_server_services }}"
include_tasks: tasks/restart_services.yml
16 changes: 13 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,19 @@
include_tasks: keylime-config.yml
when: not __keylime_server_legacy_config

- name: Ensure required services are enabled and started
- name: Ensure the verifier is enabled and started
service:
name: "{{ item }}"
name: "{{ __keylime_server_verifier_service }}"
state: started
enabled: true

- name: Make sure the verifier is up and running
ansible.builtin.wait_for:
host: "{{ keylime_server_verifier_ip }}"
port: "{{ keylime_server_verifier_port }}"

- name: Ensure the registrat is enabled and started
service:
name: "{{ __keylime_server_registrar_service }}"
state: started
enabled: true
loop: "{{ __keylime_server_services }}"
17 changes: 17 additions & 0 deletions tasks/restart_services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-License-Identifier: MIT
---

- name: Restart the verifier
service:
name: "{{ __keylime_server_verifier_service }}"
state: restarted

- name: Make sure the verifier is up and running
ansible.builtin.wait_for:
host: "{{ keylime_server_verifier_ip }}"
port: "{{ keylime_server_verifier_port }}"

- name: Restart the registrar
service:
name: "{{ __keylime_server_registrar_service }}"
state: restarted
5 changes: 2 additions & 3 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ __keylime_server_packages:
- keylime-verifier
- keylime-registrar

__keylime_server_services:
- keylime_verifier
- keylime_registrar
__keylime_server_verifier_service: keylime_verifier
__keylime_server_registrar_service: keylime_registrar

__keylime_server_user: keylime
__keylime_server_group: keylime
Expand Down

0 comments on commit b9845bf

Please sign in to comment.