From 3e037eec5a8c77e7d857cf7925279bb989ffa19a Mon Sep 17 00:00:00 2001 From: Bart Geesink Date: Wed, 15 Nov 2023 13:24:20 +0100 Subject: [PATCH] Invite: Use handlers to restart the container --- roles/invite/defaults/main.yml | 1 + roles/invite/handlers/main.yml | 11 +++++++ roles/invite/tasks/main.yml | 52 ++++------------------------------ 3 files changed, 18 insertions(+), 46 deletions(-) create mode 100644 roles/invite/handlers/main.yml diff --git a/roles/invite/defaults/main.yml b/roles/invite/defaults/main.yml index 5b9500f20..edaa436d7 100644 --- a/roles/invite/defaults/main.yml +++ b/roles/invite/defaults/main.yml @@ -12,3 +12,4 @@ invite_manage_provision_oauth_rs_description_en: "{{ instance_name }} invite Re invite_manage_provision_oauth_rs_client_id: "{{ invite.resource_server_id }}" invite_manage_provision_oauth_rs_rp_secret: "{{ invite.resource_server_secret }}" invite_manage_provision_oauth_rs_scopes: "openid" +invite_mock_install: false diff --git a/roles/invite/handlers/main.yml b/roles/invite/handlers/main.yml new file mode 100644 index 000000000..82cb26046 --- /dev/null +++ b/roles/invite/handlers/main.yml @@ -0,0 +1,11 @@ +- name: restart inviteserver + community.docker.docker_container: + name: inviteserver + state: started + restart: true + +- name: restart inviteprovisioningmock + community.docker.docker_container: + name: inviteprovisioningmock + state: started + restart: true diff --git a/roles/invite/tasks/main.yml b/roles/invite/tasks/main.yml index 1836345cc..5ea1ea57c 100644 --- a/roles/invite/tasks/main.yml +++ b/roles/invite/tasks/main.yml @@ -16,7 +16,7 @@ mode: "0644" with_items: - serverapplication.yml - register: serverconfigfiles + notify: restart inviteserver - name: Place the mockapplication configfiles ansible.builtin.template: @@ -27,7 +27,8 @@ mode: "0644" with_items: - mockapplication.yml - register: mockconfigfiles + when: invite_mock_install + notify: restart inviteprovisioningmock - name: Create and start the server container community.docker.docker_container: @@ -52,27 +53,7 @@ timeout: 10s retries: 3 start_period: 10s - when: not serverconfigfiles.changed - -- name: Create and (re)start the server container - community.docker.docker_container: - name: inviteserver - image: ghcr.io/openconext/openconext-invite/inviteserver:{{ invite_server_version }} - pull: true - restart_policy: "always" - state: started - restart: true - networks: - - name: "loadbalancer" - mounts: - - source: /opt/openconext/invite/serverapplication.yml - target: /application.yml - type: bind - command: '--spring.config.location=./' - log_driver: local - etc_hosts: - host.docker.internal: host-gateway - when: serverconfigfiles.changed + notify: restart inviteserver - name: Create the client container community.docker.docker_container: @@ -143,29 +124,8 @@ timeout: 10s retries: 3 start_period: 10s - when: not mockconfigfiles.changed - -- name: Create and (re)start the mock provisioning container - community.docker.docker_container: - name: inviteprovisioningmock - image: ghcr.io/openconext/openconext-invite/inviteprovisioningmock:{{ invite_mock_version }} - pull: true - restart_policy: "always" - restart: true - state: started - command: '--spring.config.location=./' - mounts: - - source: /opt/openconext/invite/mockapplication.yml - target: /application.yml - type: bind - networks: - - name: "loadbalancer" - labels: - traefik.http.routers.invitemock.rule: "Host(`mock.{{ base_domain }}`)" - traefik.http.routers.invitemock.tls: "true" - traefik.http.services.invitemock.loadbalancer.server.port: "8081" - traefik.enable: "true" - when: mockconfigfiles.changed + when: invite_mock_install + notify: restart inviteprovisioningmock - name: Include the role manage_provision_entities to provision invite client to Manage ansible.builtin.include_role: