Initial commit of PostgreSQL ansible role
Change-Id: Ieb82fed65ac8957058c4269182e1ea06f5bb87ee
diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml
new file mode 100644
index 0000000..ca07158
--- /dev/null
+++ b/molecule/default/converge.yml
@@ -0,0 +1,19 @@
+---
+# postgresql molecule/default/verify.yml
+#
+# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+- name: Converge
+ hosts: all
+ vars:
+ pgsql_users:
+ - name: "exampleuser"
+ password: "examplepass"
+ pgsql_databases:
+ - name: "exampledb"
+ owner: "exampleuser"
+ tasks:
+ - name: "Include postgresql"
+ include_role:
+ name: "postgresql"
diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml
new file mode 100644
index 0000000..bb7890d
--- /dev/null
+++ b/molecule/default/molecule.yml
@@ -0,0 +1,31 @@
+---
+# postgresql molecule/default/molecule.yml
+#
+# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+dependency:
+ name: galaxy
+driver:
+ name: docker
+platforms:
+ - name: "ubuntu-18.04-priv"
+ image: "quay.io/paulfantom/molecule-systemd:ubuntu-18.04"
+ privileged: true
+ volumes:
+ - "/sys/fs/cgroup:/sys/fs/cgroup:ro"
+ - name: "debian-10-priv"
+ image: "quay.io/paulfantom/molecule-systemd:debian-10"
+ privileged: true
+ volumes:
+ - "/sys/fs/cgroup:/sys/fs/cgroup:ro"
+provisioner:
+ name: ansible
+ playbooks:
+ prepare: prepare.yml
+ inventory:
+ host_vars:
+ debian-10-priv:
+ ansible_python_interpreter: /usr/bin/python3
+verifier:
+ name: ansible
diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml
new file mode 100644
index 0000000..e2a2ba0
--- /dev/null
+++ b/molecule/default/prepare.yml
@@ -0,0 +1,15 @@
+---
+# postgresql molecule/default/prepare.yml
+#
+# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+- name: Prepare
+ hosts: all
+
+ tasks:
+ - name: Install GPG to support adding apt repo keys
+ apt:
+ name: "gpg"
+ state: "present"
+ update_cache: true
diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml
new file mode 100644
index 0000000..c5d854c
--- /dev/null
+++ b/molecule/default/verify.yml
@@ -0,0 +1,35 @@
+---
+# postgresql molecule/default/verify.yml
+#
+# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+- name: Verify
+ hosts: all
+ tasks:
+
+ # user/pw/db defined in converge.yaml
+ # docs: https://docs.ansible.com/ansible/latest/modules/postgresql_ping_module.html
+ - name: Check that user can connect to database
+ postgresql_ping:
+ login_host: "localhost"
+ db: "exampledb"
+ login_user: "exampleuser"
+ login_password: "examplepass"
+
+ # docs: https://docs.ansible.com/ansible/latest/modules/postgresql_info_module.html
+ # default version is
+ - name: Check PostgreSQL Info
+ postgresql_info:
+ db: postgres
+ become: true
+ become_user: "postgres"
+ register: pgsql_info
+
+ # print entire pgsql_info if needed
+ # - debug: var=pgsql_info
+
+ - name: Verify PostgreSQL major version
+ assert:
+ that:
+ - pgsql_info['version']['major'] == 12