Skip to content

Commit bfc9090

Browse files
committed
postgres: New role
1 parent 8963c0e commit bfc9090

File tree

3 files changed

+151
-0
lines changed

3 files changed

+151
-0
lines changed

roles/postgres/defaults/main.yml

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
##########################################################################
2+
# Title: Saltbox: PostgreSQL | Default Variables #
3+
# Author(s): salty #
4+
# URL: https://github.com/saltyorg/Saltbox #
5+
# -- #
6+
##########################################################################
7+
# GNU General Public License v3.0 #
8+
##########################################################################
9+
---
10+
################################
11+
# Basics
12+
################################
13+
14+
postgres_name: postgres
15+
16+
################################
17+
# Paths
18+
################################
19+
20+
postgres_paths_folder: "{{ postgres_name }}"
21+
postgres_paths_location: "{{ server_appdata_path }}/{{ postgres_paths_folder }}"
22+
postgres_paths_folders_list:
23+
- "{{ postgres_paths_location }}"
24+
25+
################################
26+
# Settings
27+
################################
28+
29+
postgres_docker_env_password: "password4321"
30+
postgres_docker_env_user: "{{ user.name }}"
31+
postgres_docker_env_db: "saltbox"
32+
33+
################################
34+
# Docker
35+
################################
36+
37+
# Container
38+
postgres_docker_container: "{{ postgres_name }}"
39+
40+
# Image
41+
postgres_docker_image_pull: true
42+
postgres_docker_image_tag: "12-alpine"
43+
postgres_docker_image: "postgres:{{ postgres_docker_image_tag }}"
44+
45+
# Ports
46+
postgres_docker_ports_defaults: []
47+
postgres_docker_ports_custom: []
48+
postgres_docker_ports: "{{ postgres_docker_ports_defaults
49+
+ postgres_docker_ports_custom
50+
if (not reverse_proxy_is_enabled)
51+
else [] + postgres_docker_ports_custom }}"
52+
53+
# Envs
54+
postgres_docker_envs_default:
55+
TZ: "{{ tz }}"
56+
POSTGRES_PASSWORD: "{{ postgres_docker_env_password }}"
57+
POSTGRES_USER: "{{ postgres_docker_env_user }}"
58+
POSTGRES_DB: "{{ postgres_docker_env_db }}"
59+
postgres_docker_envs_custom: {}
60+
postgres_docker_envs: "{{ postgres_docker_envs_default
61+
| combine(postgres_docker_envs_custom) }}"
62+
63+
# Commands
64+
postgres_docker_commands_default: []
65+
postgres_docker_commands_custom: []
66+
postgres_docker_commands: "{{ postgres_docker_commands_default
67+
+ postgres_docker_commands_custom }}"
68+
69+
# Volumes
70+
postgres_docker_volumes_default:
71+
- "{{ postgres_paths_location }}:/var/lib/postgresql/data"
72+
- "/etc/passwd:/etc/passwd:ro"
73+
postgres_docker_volumes_custom: []
74+
postgres_docker_volumes: "{{ postgres_docker_volumes_default
75+
+ postgres_docker_volumes_custom }}"
76+
77+
# Devices
78+
postgres_docker_devices_default: []
79+
postgres_docker_devices_custom: []
80+
postgres_docker_devices: "{{ postgres_docker_devices_default
81+
+ postgres_docker_devices_custom }}"
82+
83+
# Hosts
84+
postgres_docker_hosts_default: []
85+
postgres_docker_hosts_custom: []
86+
postgres_docker_hosts: "{{ docker_hosts_common
87+
| combine(postgres_docker_hosts_default)
88+
| combine(postgres_docker_hosts_custom) }}"
89+
90+
# Labels
91+
postgres_docker_labels_default: {}
92+
postgres_docker_labels_custom: {}
93+
postgres_docker_labels: "{{ docker_labels_common
94+
| combine(postgres_docker_labels_default)
95+
| combine(postgres_docker_labels_custom) }}"
96+
97+
# Hostname
98+
postgres_docker_hostname: "{{ postgres_name }}"
99+
100+
# Networks
101+
postgres_docker_networks_alias: "{{ postgres_name }}"
102+
postgres_docker_networks_default: []
103+
postgres_docker_networks_custom: []
104+
postgres_docker_networks: "{{ docker_networks_common
105+
+ postgres_docker_networks_default
106+
+ postgres_docker_networks_custom }}"
107+
108+
# Capabilities
109+
postgres_docker_capabilities_default: []
110+
postgres_docker_capabilities_custom: []
111+
postgres_docker_capabilities: "{{ postgres_docker_capabilities_default
112+
+ postgres_docker_capabilities_custom }}"
113+
114+
# Security Opts
115+
postgres_docker_security_opts_default: []
116+
postgres_docker_security_opts_custom: []
117+
postgres_docker_security_opts: "{{ postgres_docker_security_opts_default
118+
+ postgres_docker_security_opts_custom }}"
119+
120+
# Restart Policy
121+
postgres_docker_restart_policy: unless-stopped
122+
123+
# State
124+
postgres_docker_state: started
125+
126+
# User
127+
postgres_docker_user: "{{ uid }}:{{ gid }}"

roles/postgres/tasks/main.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#########################################################################
2+
# Title: Saltbox: PostgreSQL Role #
3+
# Author(s): salty #
4+
# URL: https://github.com/saltyorg/Saltbox #
5+
# -- #
6+
#########################################################################
7+
# GNU General Public License v3.0 #
8+
#########################################################################
9+
---
10+
- name: Remove existing Docker container
11+
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/docker/remove_docker_container.yml"
12+
13+
- name: Create directories
14+
ansible.builtin.file:
15+
path: "{{ item }}"
16+
state: directory
17+
owner: "{{ user.name }}"
18+
group: "{{ user.name }}"
19+
mode: "0775"
20+
with_items: "{{ lookup('vars', role_name + '_paths_folders_list') }}"
21+
22+
- name: Create Docker container
23+
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/docker/create_docker_container.yml"

saltbox.yml

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
- { role: petio, tags: ['petio'] }
6666
- { role: plex, tags: ['plex'] }
6767
- { role: plex_autoscan, tags: ['plex_autoscan'] }
68+
- { role: postgres, tags: ['postgres'] }
6869
- { role: prowlarr, tags: ['prowlarr'] }
6970
- { role: qbittorrent, tags: ['qbittorrent'] }
7071
- { role: readarr, tags: ['readarr'] }

0 commit comments

Comments
 (0)