[add] role:postgresql-for-zeitbild_backend
This commit is contained in:
parent
6f36c11791
commit
598be43d73
3 changed files with 110 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
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue