Skip to content

Commit

Permalink
Invite: Use handlers to restart the container
Browse files Browse the repository at this point in the history
  • Loading branch information
quartje committed Nov 15, 2023
1 parent d2b9db5 commit 3e037ee
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 46 deletions.
1 change: 1 addition & 0 deletions roles/invite/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions roles/invite/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -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
52 changes: 6 additions & 46 deletions roles/invite/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
mode: "0644"
with_items:
- serverapplication.yml
register: serverconfigfiles
notify: restart inviteserver

- name: Place the mockapplication configfiles
ansible.builtin.template:
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 3e037ee

Please sign in to comment.