Implement postgresql ansible role

This commit is contained in:
ionutboangiu
2023-07-11 04:43:34 -04:00
committed by Dan Christian Bogos
parent ef4a59c31e
commit afb170734f
4 changed files with 38 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
---
- hosts: local
- hosts: all
tasks:
- name: Install RabbitMQ
import_role:
@@ -29,6 +29,10 @@
import_role:
name: ../roles/install_mongodb
- name: Install PostgreSQL
import_role:
name: ../roles/postgresql
- name: Install Go
import_role:
name: ../roles/go

View File

@@ -9,7 +9,5 @@ cgrates_dependencies:
- git
- redis-server
- mariadb-server
- postgresql
- postgresql-contrib
- make
- gcc

View File

@@ -0,0 +1,6 @@
---
postgresql_version: "postgresql"
postgresql_repo: "http://apt.postgresql.org/pub/repos/apt"
postgresql_key_url: "https://www.postgresql.org/media/keys/ACCC4CF8.asc"
postgresql_service_state: "started"
postgresql_service_enabled: "no"

View File

@@ -0,0 +1,27 @@
---
- name: Create the PostgreSQL repository configuration
become: yes
ansible.builtin.copy:
content: "deb {{ postgresql_repo }} {{ ansible_distribution_release }}-pgdg main"
dest: /etc/apt/sources.list.d/pgdg.list
when: not (ansible.builtin.stat.exists is defined and ansible.builtin.stat.exists)
- name: Import the PostgreSQL repository signing key
become: yes
ansible.builtin.apt_key:
url: "{{ postgresql_key_url }}"
state: present
- name: Update the package lists and ensure PostgreSQL is the latest version
become: yes
ansible.builtin.apt:
name: "{{ postgresql_version }}"
state: latest
update_cache: yes
- name: Manage the PostgreSQL service
become: yes
ansible.builtin.systemd:
name: postgresql
state: "{{ postgresql_service_state }}"
enabled: "{{ postgresql_service_enabled }}"