Skip to content

Commit de01557

Browse files
committed
run monitoring-test container per environment and add mujina containers
1 parent e26c22d commit de01557

7 files changed

Lines changed: 123 additions & 35 deletions

File tree

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
---
2-
#health_checks:
3-
# - name: env1
4-
# port: 80
5-
# - name: env2
6-
# port: 8080
2+
health_checks:
3+
- acc
4+
- prd
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
- name: Retrieve vars from environments inventory
2+
ansible.builtin.include_vars:
3+
dir: "{{ inventory_dir }}/../{{ env }}/group_vars/"
4+
5+
- name: Retrieve secrets from environments inventory
6+
ansible.builtin.include_vars:
7+
file: "{{ inventory_dir }}/../{{ env }}/secrets/secrets.yml"
8+
9+
- name: Create mujina idp container
10+
ansible.builtin.include_role:
11+
name: mujina-idp
12+
vars:
13+
mujina_idp_container: "mujina-idp-{{ env }}"
14+
mujina_idp_dir_docker: "/opt/openconext/mujina_idp_{{ env }}"
15+
16+
- name: Create mujina sp container
17+
ansible.builtin.include_role:
18+
name: mujina-sp
19+
vars:
20+
mujina_sp_container: "mujina-sp-{{ env }}"
21+
mujina_sp_dir_docker: "/opt/openconext/mujina_sp_{{ env }}"
22+
23+
- name: Place health scripts
24+
ansible.builtin.template:
25+
src: templates/check.sh.j2
26+
dest: "/opt/openconext/health_check_{{ env }}/check.sh"
27+
mode: 0755
28+
29+
- name: Place application.yml for set environments
30+
ansible.builtin.template:
31+
src: templates/application.yml.j2
32+
dest: "/opt/openconext/health_check_{{ env }}/application.yml"
33+
mode: 0644
34+
35+
- name: Start monitoring tests docker container(s)
36+
community.docker.docker_container:
37+
name: "monitoring-{{ env }}"
38+
image: "ghcr.io/openconext/openconext-monitoring/monitoring:latest"
39+
state: started
40+
restart_policy: "always"
41+
recreate: false
42+
ports:
43+
- "{{ monitoring_tests.port }}:{{ monitoring_tests.port }}"
44+
mounts:
45+
- type: bind
46+
source: "/opt/openconext/health_check_{{ env }}/application.yml"
47+
target: /application.yml
Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,26 @@
11
---
2-
- name: Start monitoring tests docker container
3-
community.docker.docker_container:
4-
name: "monitoring"
5-
image: "ghcr.io/openconext/openconext-monitoring/monitoring:latest"
6-
state: started
7-
restart_policy: "always"
8-
recreate: false
9-
networks:
10-
- name: "loadbalancer"
11-
12-
- name: Create required directories for health check scripts
2+
- name: Create required directories for health check scripts in /opt
133
ansible.builtin.file:
144
state: directory
15-
path: "/opt/health_check_{{ item.name }}"
5+
path: "/opt/openconext/health_check_{{ item }}"
166
owner: root
177
group: root
188
mode: 0755
199
with_items: "{{ health_checks }}"
20-
when: health_checks is defined
2110

2211
- name: Make sure nrpe directory exists
2312
ansible.builtin.file:
2413
state: directory
2514
path: /etc/nrpe.d
26-
when: health_checks is defined
2715

28-
- name: Place health scripts
29-
ansible.builtin.template:
30-
src: templates/check.sh.j2
31-
dest: "/opt/health_check_{{ item.name }}/check.sh"
32-
mode: 0755
16+
- name: Place monitoring files per environment
17+
include_tasks: create_monitoring.yml
3318
with_items: "{{ health_checks }}"
34-
when: health_checks is defined
19+
loop_control:
20+
loop_var: "env"
3521

36-
- name: Place nrpe config file
22+
- name: Place nagios config file
3723
ansible.builtin.lineinfile:
38-
line: "command[check_health_prd]=/opt/health_check_{{ item.name }}/check.sh"
24+
line: "command[check_health_prd]=/opt/openconext/health_check_{{ item }}/check.sh"
3925
dest: "/etc/nrpe.d/check_components.cfg"
4026
with_items: "{{ health_checks }}"
41-
when: health_checks is defined
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
logging:
2+
config: classpath:logback.xml
3+
4+
server:
5+
# The port to where this Spring Boot application listens to.
6+
port: {{ monitoring_tests.port }}
7+
8+
eb:
9+
metadata_sp_url: {{ monitoring_tests.metadata_sp_url }}
10+
metadata_idp_url: {{ monitoring_tests.metadata_idp_url }}
11+
mujina_sp_base_url: http://localhost:{{ monitoring_tests.mujina_sp_port }}
12+
mujina_idp_entity_id: {{ mujina_idp.entity_id }}
13+
mujina_username: monitor-user
14+
15+
pdp:
16+
user: {{ pdp.username }}
17+
password: {{ pdp.password }}
18+
idp_entity_id: https://engine.{{ base_domain }}/authentication/idp/metadata
19+
sp_entity_id: https://engine.{{ base_domain }}/authentication/sp/metadata
20+
base_url: https://pdp.{{ base_domain }}
21+
22+
voot:
23+
oidc:
24+
authorization_url: https://connect.{{ base_domain }}/oidc/token
25+
voot_base_url: https://voot.{{ base_domain }}
26+
client_id: monitoring.{{ base_domain }}
27+
secret: {{ monitoring_tests_oidcng_client_secret }}
28+
person_id: {{ monitoring_tests.person_id }}
29+
30+
oidcng:
31+
base_url: https://connect.{{ base_domain }}/oidc
32+
client_id: {{ monitoring_tests.oidcng_client_id }}
33+
secret: {{ monitoring_tests_oidcng_client_secret }}
34+
resource_server_id: {{ monitoring_tests.oidcng_resource_server_id }}
35+
resource_server_secret: {{ monitoring_tests_oidcng_resource_server_secret }}
36+
37+
# We disable all endpoints except health for the load-balancer and info for git information.
38+
management:
39+
endpoints:
40+
web:
41+
exposure:
42+
include: "health,info"
43+
endpoint:
44+
info:
45+
enabled: true
46+
health:
47+
show-details: always
48+
mappings:
49+
enabled: true
50+
info:
51+
git:
52+
mode: full
53+
54+
# used by the git plugin
55+
info:
56+
build:
57+
artifact: "@project.artifactId@"
58+
version: "@project.version@"

roles/monitoring-tests-docker/templates/check.sh.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
JSON=`curl -s 'http://localhost:{{ item.port }}/actuator/health'`
3+
JSON=`curl -s 'http://localhost:{{ monitoring_tests.port }}/actuator/health'`
44
ss=`echo $JSON | python3 -c "import sys, json; print(json.load(sys.stdin)['status'])"`
55
mms=`echo $JSON | python3 -c "import sys, json; print(json.load(sys.stdin)['components']['metadataMonitor']['status'])"`
66
sps=`echo $JSON | python3 -c "import sys, json; print(json.load(sys.stdin)['components']['samlProxyMonitor']['status'])"`

roles/mujina-idp/tasks/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
- name: Create and start the server container
2727
community.docker.docker_container:
28-
name: mujina-idp
28+
name: "{{ mujina_idp_container | default ('mujina-idp') }}"
2929
image: ghcr.io/openconext/mujina/mujina-idp:{{ mujina_version }}
3030
pull: true
3131
restart_policy: "always"
@@ -45,7 +45,7 @@
4545
labels:
4646
traefik.http.routers.mujina-idp.rule: "Host(`mujina-idp.{{ base_domain }}`)"
4747
traefik.http.routers.mujina-idp.tls: "true"
48-
traefik.http.services.mujina-idp.loadbalancer.server.port: "8080"
48+
traefik.http.services.mujina-idp.loadbalancer.server.port: "{{ mujina_idp_port | default('8080') }}"
4949
traefik.enable: "true"
5050
healthcheck:
5151
test:
@@ -55,7 +55,7 @@
5555
"-no-verbose",
5656
"--tries=1",
5757
"--spider",
58-
"http://localhost:8080/internal/health",
58+
"http://localhost:{{ mujina_idp_port | default('8080') }}/internal/health",
5959
]
6060
interval: 10s
6161
timeout: 10s

roles/mujina-sp/tasks/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
- name: Create and start the server container
2727
community.docker.docker_container:
28-
name: mujina-sp
28+
name: "{{ mujina_sp_container | default ('mujina-sp') }}"
2929
image: ghcr.io/openconext/mujina/mujina-sp:{{ mujina_version }}
3030
pull: true
3131
restart_policy: "always"
@@ -45,7 +45,7 @@
4545
labels:
4646
traefik.http.routers.mujina-sp.rule: "Host(`mujina-sp.{{ base_domain }}`)"
4747
traefik.http.routers.mujina-sp.tls: "true"
48-
traefik.http.services.mujina-sp.loadbalancer.server.port: "9090"
48+
traefik.http.services.mujina-sp.loadbalancer.server.port: "{{ mujina_sp_port | default('9090') }}"
4949
traefik.enable: "true"
5050
healthcheck:
5151
test:
@@ -55,7 +55,7 @@
5555
"-no-verbose",
5656
"--tries=1",
5757
"--spider",
58-
"http://localhost:9090/internal/health",
58+
"http://localhost:{{ mujina_sp_port | default('9090') }}/internal/health",
5959
]
6060
interval: 10s
6161
timeout: 10s

0 commit comments

Comments
 (0)