initial commit
This commit is contained in:
commit
e206487577
4 changed files with 54 additions and 0 deletions
0
README.md
Normal file
0
README.md
Normal file
6
defaults/main.yml
Normal file
6
defaults/main.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
postgres_password: t0t4l!S3cur1tY.
|
||||||
|
postgres_data_folder: ./psql_data
|
||||||
|
postgres_version: alpine
|
||||||
|
compose_dir: /srv
|
||||||
28
tasks/main.yml
Normal file
28
tasks/main.yml
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
- name: Create directory if it does not exists
|
||||||
|
become: true
|
||||||
|
file:
|
||||||
|
path: "{{ compose_dir }}/postgres"
|
||||||
|
state: directory
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- name: Place docker-compose file
|
||||||
|
become: true
|
||||||
|
template:
|
||||||
|
src: templates/docker-compose.yml.j2
|
||||||
|
dest: "{{ compose_dir }}/postgres/docker-compose.yml"
|
||||||
|
mode: 0700
|
||||||
|
|
||||||
|
- name: Update and start services
|
||||||
|
become: true
|
||||||
|
docker_compose:
|
||||||
|
project_src: "{{ compose_dir }}/postgres"
|
||||||
|
pull: true
|
||||||
|
state: present
|
||||||
|
remove_orphans: true
|
||||||
|
register: output
|
||||||
|
|
||||||
|
- name: Check all containers are running
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "output.ansible_facts.postgres.db.state.running": true
|
||||||
20
templates/docker-compose.yml.j2
Normal file
20
templates/docker-compose.yml.j2
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
# {{ ansible_managed }}
|
||||||
|
# commit: {{ lookup('pipe', 'git rev-parse --short HEAD') }}
|
||||||
|
|
||||||
|
version: '3.4'
|
||||||
|
|
||||||
|
services:
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: postgres:{{ postgres_version }}
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
POSTGRES_PASSWORD: {{ postgres_password }}
|
||||||
|
volumes:
|
||||||
|
- {{ postgres_data_folder }}:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
adminer:
|
||||||
|
image: adminer
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 8080:8080
|
||||||
Loading…
Add table
Add a link
Reference in a new issue