Initial commit of PostgreSQL ansible role
Change-Id: Ieb82fed65ac8957058c4269182e1ea06f5bb87ee
diff --git a/tasks/Debian.yml b/tasks/Debian.yml
new file mode 100644
index 0000000..32e20bf
--- /dev/null
+++ b/tasks/Debian.yml
@@ -0,0 +1,33 @@
+---
+# postgresql tasks/Debian.yml
+#
+# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+# Docs: https://www.postgresql.org/download/linux/ubuntu/
+- name: Add PostgreSQL apt repo key
+ apt_key:
+ data: "{{ lookup('file','ACCC4CF8.asc') }}"
+ state: "present"
+
+- name: Add Official PostgreSQL apt repo
+ apt_repository:
+ repo: "deb http://apt.postgresql.org/pub/repos/apt {{ ansible_lsb['codename'] }}-pgdg main"
+ mode: 0644
+ update_cache: true
+
+- name: Install PostgreSQL server, client, and python interface packages
+ apt:
+ name:
+ - "postgresql-{{ pgsql_version }}"
+ - "postgresql-client-{{ pgsql_version }}"
+ - "python3-psycopg2"
+ state: "present"
+ update_cache: true
+ cache_valid_time: 3600
+
+- name: Start and Enable PostgreSQL Service
+ service:
+ name: "{{ pgsql_service }}"
+ state: "started"
+ enabled: true