Compare commits
2 commits
6f36c11791
...
3eab5611fd
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3eab5611fd | ||
![]() |
598be43d73 |
6 changed files with 177 additions and 0 deletions
7
roles/postgresql-for-zeitbild_backend/defaults/main.json
Normal file
7
roles/postgresql-for-zeitbild_backend/defaults/main.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"var_postgresql_for_zeitbild_username": "zeitbild_user",
|
||||||
|
"var_postgresql_for_zeitbild_password": "REPLACE_ME",
|
||||||
|
"var_postgresql_for_zeitbild_schema": "zeitbild",
|
||||||
|
"var_postgresql_for_zeitbild_git_reference": "master",
|
||||||
|
"var_postgresql_for_zeitbild_revision": "."
|
||||||
|
}
|
85
roles/postgresql-for-zeitbild_backend/tasks/main.json
Normal file
85
roles/postgresql-for-zeitbild_backend/tasks/main.json
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "packages",
|
||||||
|
"become": true,
|
||||||
|
"ansible.builtin.apt": {
|
||||||
|
"update_cache": true,
|
||||||
|
"pkg": [
|
||||||
|
"acl",
|
||||||
|
"python3-psycopg2"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "user",
|
||||||
|
"become": true,
|
||||||
|
"become_user": "postgres",
|
||||||
|
"community.postgresql.postgresql_user": {
|
||||||
|
"state": "present",
|
||||||
|
"name": "{{var_postgresql_for_zeitbild_username}}",
|
||||||
|
"password": "{{var_postgresql_for_zeitbild_password}}"
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"PGOPTIONS": "-c password_encryption=scram-sha-256"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "schema",
|
||||||
|
"become": true,
|
||||||
|
"become_user": "postgres",
|
||||||
|
"community.postgresql.postgresql_db": {
|
||||||
|
"state": "present",
|
||||||
|
"name": "{{var_postgresql_for_zeitbild_schema}}",
|
||||||
|
"owner": "{{var_postgresql_for_zeitbild_username}}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "rights",
|
||||||
|
"become": true,
|
||||||
|
"become_user": "postgres",
|
||||||
|
"community.postgresql.postgresql_privs": {
|
||||||
|
"state": "present",
|
||||||
|
"db": "{{var_postgresql_for_zeitbild_schema}}",
|
||||||
|
"objs": "ALL_IN_SCHEMA",
|
||||||
|
"roles": "{{var_postgresql_for_zeitbild_username}}",
|
||||||
|
"privs": "ALL",
|
||||||
|
"grant_option": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "structure | fetch",
|
||||||
|
"delegate_to": "localhost",
|
||||||
|
"ansible.builtin.git": {
|
||||||
|
"repo": "https://forgejo.linke.sx/zeitbild/datamodel",
|
||||||
|
"version": "{{var_postgresql_for_zeitbild_git_reference}}",
|
||||||
|
"dest": "/tmp/zeitbild-datamodel-repo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "structure | build",
|
||||||
|
"delegate_to": "localhost",
|
||||||
|
"ansible.builtin.shell": {
|
||||||
|
"chdir": "/tmp/zeitbild-datamodel-repo",
|
||||||
|
"cmd": "tools/build --revision='{{var_postgresql_for_zeitbild_revision}}' --format='postgresql' > /tmp/zeitbild.sql"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "structure | transfer",
|
||||||
|
"ansible.builtin.copy": {
|
||||||
|
"src": "/tmp/zeitbild.sql",
|
||||||
|
"dest": "/tmp/zeitbild.sql"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "structure | apply",
|
||||||
|
"become": true,
|
||||||
|
"become_user": "postgres",
|
||||||
|
"community.postgresql.postgresql_query": {
|
||||||
|
"db": "{{var_postgresql_for_zeitbild_schema}}",
|
||||||
|
"login_host": "localhost",
|
||||||
|
"login_user": "{{var_postgresql_for_zeitbild_username}}",
|
||||||
|
"login_password": "{{var_postgresql_for_zeitbild_password}}",
|
||||||
|
"query": "{{lookup('ansible.builtin.file','/tmp/zeitbild.sql')}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
18
roles/postgresql-for-zeitbild_backend/vardef.json
Normal file
18
roles/postgresql-for-zeitbild_backend/vardef.json
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"username": {
|
||||||
|
"type": "string",
|
||||||
|
"mandatory": false
|
||||||
|
},
|
||||||
|
"password": {
|
||||||
|
"type": "string",
|
||||||
|
"mandatory": true
|
||||||
|
},
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"mandatory": false
|
||||||
|
},
|
||||||
|
"git_reference": {
|
||||||
|
"type": "string",
|
||||||
|
"mandatory": false
|
||||||
|
}
|
||||||
|
}
|
5
roles/zeitbild_backend-and-nginx/defaults/main.json
Normal file
5
roles/zeitbild_backend-and-nginx/defaults/main.json
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"var_zeitbild_backend_and_nginx_domain": "zeitbild.example.org",
|
||||||
|
"var_zeitbild_backend_and_nginx_port": 7845,
|
||||||
|
"var_zeitbild_backend_and_nginx_tls": true
|
||||||
|
}
|
35
roles/zeitbild_backend-and-nginx/tasks/main.json
Normal file
35
roles/zeitbild_backend-and-nginx/tasks/main.json
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "deactivate default site",
|
||||||
|
"become": true,
|
||||||
|
"ansible.builtin.file": {
|
||||||
|
"state": "absent",
|
||||||
|
"dest": "/etc/nginx/sites-enabled/default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "emplace configuration | data",
|
||||||
|
"become": true,
|
||||||
|
"ansible.builtin.template": {
|
||||||
|
"src": "conf.j2",
|
||||||
|
"dest": "/etc/nginx/sites-available/{{var_zeitbild_backend_and_nginx_domain}}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "emplace configuration | link",
|
||||||
|
"become": true,
|
||||||
|
"ansible.builtin.file": {
|
||||||
|
"state": "link",
|
||||||
|
"src": "/etc/nginx/sites-available/{{var_zeitbild_backend_and_nginx_domain}}",
|
||||||
|
"dest": "/etc/nginx/sites-enabled/{{var_zeitbild_backend_and_nginx_domain}}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "restart nginx",
|
||||||
|
"become": true,
|
||||||
|
"ansible.builtin.systemd_service": {
|
||||||
|
"state": "restarted",
|
||||||
|
"name": "nginx"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
27
roles/zeitbild_backend-and-nginx/templates/conf.j2
Normal file
27
roles/zeitbild_backend-and-nginx/templates/conf.j2
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
map $http_upgrade $connection_upgrade {
|
||||||
|
default upgrade;
|
||||||
|
'' close;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
server_name {{var_zeitbild_backend_and_nginx_domain}};
|
||||||
|
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
{% if var_zeitbild_backend_and_nginx_tls %}
|
||||||
|
listen [::]:443 ssl http2;
|
||||||
|
listen 443 ssl http2;
|
||||||
|
|
||||||
|
ssl_certificate /etc/ssl/certs/{{var_zeitbild_backend_and_nginx_domain}}.pem;
|
||||||
|
ssl_certificate_key /etc/ssl/private/{{var_zeitbild_backend_and_nginx_domain}}.pem;
|
||||||
|
include /etc/nginx/ssl-hardening.conf;
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://localhost:{{var_zeitbild_backend_and_nginx_port | string}};
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue