aboutsummaryrefslogtreecommitdiffhomepage
path: root/tasks/postgres-database.yml
diff options
context:
space:
mode:
Diffstat (limited to 'tasks/postgres-database.yml')
-rw-r--r--tasks/postgres-database.yml20
1 files changed, 20 insertions, 0 deletions
diff --git a/tasks/postgres-database.yml b/tasks/postgres-database.yml
new file mode 100644
index 0000000..c7b09a8
--- /dev/null
+++ b/tasks/postgres-database.yml
@@ -0,0 +1,20 @@
1- name: Test if the PostgreSQL server is up
2 become: true
3 become_user: postgres
4 become_method: su
5 command: psql --port={{ postgres_port }} --command='select NOW()'
6 register: postgres_up
7 ignore_errors: yes
8 check_mode: no
9 changed_when: false
10
11- name: Create PostgreSQL database
12 become: true
13 become_user: postgres
14 become_method: su
15 postgresql_db:
16 port: "{{ postgres_port }}"
17 name: "{{ postgres_dbname }}"
18 owner: "{{ postgres_owner }}"
19 when:
20 - postgres_up.rc == 0