36 lines
948 B
YAML
36 lines
948 B
YAML
- name: install psycopg2
|
|
pip:
|
|
name: psycopg2-binary
|
|
state: present
|
|
- name: ensure directories exist
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
mode: "0755"
|
|
loop:
|
|
- "{{ data_folder }}/postgres/data"
|
|
- "{{ data_folder }}/postgres/init"
|
|
- name: copy init sql files
|
|
template:
|
|
src: "{{ item }}"
|
|
dest: "{{ data_folder }}/postgres/init/{{ item | basename | regex_replace('.j2$', '') }}"
|
|
with_fileglob:
|
|
- "../templates/*.sql.j2"
|
|
- name: create network
|
|
docker_network:
|
|
name: postgres
|
|
attachable: true
|
|
internal: true
|
|
state: present
|
|
- name: run container
|
|
docker_container:
|
|
name: "postgres"
|
|
image: "postgres:13"
|
|
networks:
|
|
- name: postgres
|
|
volumes:
|
|
- "{{ data_folder }}/postgres/data:/var/lib/postgresql/data"
|
|
- "{{ data_folder }}/postgres/init:/docker-entrypoint-initdb.d"
|
|
env:
|
|
POSTGRES_PASSWORD: "{{ vault_postgres_password }}"
|
|
state: started |