Skip to content

Commit 21a308e

Browse files
authored
Merge pull request #74 from wiseflat/dev/mgarcia/saas-postgresql
feat(postgresql): switch to official postgres image and adjust paths
2 parents 699f494 + 0de5ea4 commit 21a308e

4 files changed

Lines changed: 14 additions & 18 deletions

File tree

ansible/playbooks/saas/roles/postgresql/tasks/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
- name: Set custom variables
33
ansible.builtin.set_fact:
4-
image_version: "{{ latest_version }}"
4+
image_version: "18.0"
55
image_name: "{{ image.name }}"
66
image_labels: "{{ image.labels }}"
77
image_build: "{{ image.build }}"

ansible/playbooks/saas/roles/postgresql/tasks/main.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,12 @@
55
state: directory
66
owner: "{{ item.owner | default('root') }}"
77
group: "{{ item.group | default('root') }}"
8-
mode: "{{ item.mode | default('0755') }}"
8+
mode: "{{ item.mode | default('0755') }}"
99
loop:
10-
- path: "{{ software_path }}/bitnami/postgresql"
11-
- path: "{{ software_path }}/bitnami/postgresql/data"
12-
owner: 1001
13-
group: root
14-
- path: "{{ software_path }}/var/backup"
15-
owner: nobody
16-
group: nogroup
17-
mode: '777'
18-
- path: "{{ software_path }}/tmp"
10+
- path: "{{ software_path }}/var/lib/postgresql"
1911
owner: root
2012
group: root
21-
mode: '1777'
13+
delegate_to: "{{ software.instance }}"
2214

2315
- name: Copy script to operate software
2416
ansible.builtin.copy:
@@ -30,6 +22,7 @@
3022
loop:
3123
- backup
3224
- restore
25+
delegate_to: "{{ software.instance }}"
3326

3427
- name: Copy nomad job
3528
ansible.builtin.template:

ansible/playbooks/saas/roles/postgresql/templates/nomad.hcl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ job "{{ domain }}" {
2121
network {
2222
port "postgresql" {
2323
to = 5432
24+
{% if software.static_port is defined %}
25+
static = {{ software.static_port }}
26+
{% endif %}
2427
}
2528
}
2629

2730
service {
28-
name = "{{ service_name }}-postgresql"
31+
name = "{{ service_name }}"
2932
port = "postgresql"
3033
provider = "nomad"
3134
tags = []
@@ -36,13 +39,15 @@ job "{{ domain }}" {
3639
driver = "docker"
3740

3841
env {
39-
POSTGRESQL_PASSWORD = "{{ lookup('simple-stack-ui', type='secret', key=domain, subkey='passwd', missing='create', length=12) }}"
42+
POSTGRES_PASSWORD = "{{ lookup('simple-stack-ui', type='secret', key=domain, subkey='passwd', missing='create', length=12) }}"
43+
POSTGRES_HOST_AUTH_METHOD = "trust"
4044
}
4145

4246
config {
43-
image = "bitnami/postgresql:{{ softwares.postgresql.version }}"
47+
image = "postgres:{{ softwares.postgresql.version }}"
48+
ports = ["postgresql"]
4449
volumes = [
45-
"{{ software_path }}/bitnami/postgresql:/bitnami/postgresql:rw",
50+
"{{ software_path }}/var/lib/postgresql:/var/lib/postgresql:rw",
4651
"{{ software_path }}/tmp:/tmp:rw"
4752
]
4853
}

ansible/playbooks/saas/roles/postgresql/vars/main.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@ image:
1111
os: linux
1212
labels: {}
1313
name: postgresql
14-
15-
latest_version: "17.4.0"

0 commit comments

Comments
 (0)