forked from GeoNode/ansible-geonode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbservers.yml
48 lines (43 loc) · 1.59 KB
/
dbservers.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
- hosts: localhost
connection: local
tasks:
- name: Create multi-zone Postgres on RDS
rds:
command: create
instance_name: "{{ db_instance }}"
region: "{{ db_region }}"
db_engine: postgres
instance_type: "{{ db_instance_type }}"
multi_zone: "{{ db_multi_zone}}"
publicly_accessible: "{{ db_publicly_accessible }}"
size: "{{ db_size }}"
maint_window: "{{ db_maint_window }}"
backup_retention: "{{ db_backup_retention }}"
backup_window: "{{ db_backup_window }}"
license_model: "{{ db_license_model }}"
storage_type: "{{ db_storage_type }}"
subnet: "{{ db_vpc_subnet }}"
vpc_security_groups: "{{ db_vpc_group }}"
db_name: "{{ db_name }}"
username: "{{ db_user }}"
password: "{{ db_password }}"
tags:
environment: testing
application: worldmap
owner: ariel
- name: Get facts about postgres instance.
rds:
command: facts
instance_name: "{{ db_instance }}"
region: "{{ db_region }}"
register: postgres_facts
- name: Set host name
set_fact:
db_host: "{{ postgres_facts.instance.endpoint}}"
- debug: var=postgres_facts
- name: Ensure postgresql postgis extension is created
shell: "PGPASSWORD='{{db_password}}' psql -h {{db_host}} -d {{db_name}} -U {{db_user}} -c 'CREATE EXTENSION postgis;'"
register: psql_result
failed_when: >
psql_result.rc != 0 and ("already exists" not in psql_result.stderr)
changed_when: "psql_result.rc == 0"