From d0bc90e08c29e881c388c6803ed9c49dff1f1776 Mon Sep 17 00:00:00 2001 From: Paul B Date: Fri, 31 Aug 2018 11:49:09 +0200 Subject: Initial commit open sourcing Postgresql Ansible role --- tasks/postgres-database.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tasks/postgres-database.yml (limited to 'tasks/postgres-database.yml') 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 @@ +- name: Test if the PostgreSQL server is up + become: true + become_user: postgres + become_method: su + command: psql --port={{ postgres_port }} --command='select NOW()' + register: postgres_up + ignore_errors: yes + check_mode: no + changed_when: false + +- name: Create PostgreSQL database + become: true + become_user: postgres + become_method: su + postgresql_db: + port: "{{ postgres_port }}" + name: "{{ postgres_dbname }}" + owner: "{{ postgres_owner }}" + when: + - postgres_up.rc == 0 -- cgit v1.2.3