Skip to content

Commit b9b0c79

Browse files
committed
add initial KC test
1 parent 262358e commit b9b0c79

5 files changed

Lines changed: 71 additions & 0 deletions

File tree

ansible/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
tags: "intro_website"
7777
- role: "committeeclash"
7878
tags: "committeeclash"
79+
- role: "keycloak"
80+
tags: "keycloak"
7981
- role: "rottenspringbok"
8082
tags: "rottenspringbok"
8183
- role: "studytrip"
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
- name: "create user"
3+
ansible.builtin.user:
4+
name: "keycloak"
5+
home: "{{ keycloak_project_source }}"
6+
shell: "/usr/sbin/nologin"
7+
state: "present"
8+
system: true
9+
10+
- name: "set up keycloak"
11+
become_user: "keycloak"
12+
become: true
13+
block:
14+
- name: "clone repository"
15+
ansible.builtin.git:
16+
repo: "https://github.com/svsticky/improved-adventure.git"
17+
dest: "{{ keycloak_project_source }}"
18+
depth: 1
19+
version: main #"{% if 'production' in group_names %}main{% else %}development{% endif %}" # Pull main when deploying to prod
20+
diff: false
21+
22+
- name: "Copy .env file"
23+
ansible.builtin.template:
24+
src: ".env.j2"
25+
dest: "{{ keycloak_project_source }}/.env"
26+
diff: false
27+
28+
- name: "Docker compose"
29+
ansible.builtin.include_tasks: "../docker/tasks/compose-up.yml"
30+
vars:
31+
project_source: "{{ keycloak_project_source }}"
32+
remove_images: all
33+
34+
- name: "Copy nginx configuration"
35+
ansible.builtin.template:
36+
src: "keycloak.conf.j2"
37+
dest: "/etc/nginx/sites-available/keycloak.{{ canonical_hostname }}.conf"
38+
notify: "reload nginx"
39+
40+
- name: "Enable nginx configuration for keycloak"
41+
ansible.builtin.file:
42+
src: "/etc/nginx/sites-available/keycloak.{{ canonical_hostname }}.conf"
43+
path: "/etc/nginx/sites-enabled/keycloak.{{ canonical_hostname }}.conf"
44+
state: link
45+
notify: "reload nginx"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# TODO: add input here
2+
DB_PASSWORD=foobar
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
server {
2+
listen 443 ssl http2;
3+
listen [::]:443 ssl http2;
4+
server_name keycloak.{{ canonical_hostname }};
5+
6+
ssl_certificate /etc/letsencrypt/live/keycloak.{{ canonical_hostname }}/fullchain.pem;
7+
ssl_certificate_key /etc/letsencrypt/live/keycloak.{{ canonical_hostname }}/privkey.pem;
8+
ssl_trusted_certificate /etc/letsencrypt/live/keycloak.{{ canonical_hostname }}/chain.pem;
9+
10+
location / {
11+
proxy_pass http://localhost:{{ keycloak_port }}/;
12+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
13+
proxy_set_header X-Forwarded-Proto https;
14+
proxy_set_header Host $http_host;
15+
proxy_set_header Upgrade $http_upgrade;
16+
proxy_set_header Connection "upgrade";
17+
}
18+
}
19+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
keycloak_port: 6666
3+
keycloak_project_source: /var/www/keycloak

0 commit comments

Comments
 (0)