Files
2026-10-18 16:41:04 +02:00

51 lines
1.1 KiB
YAML

---
- name: Remove Postgres
hosts: Ubuntu
become: yes
vars_files:
- vars.yml
tasks:
- name: PostgreSQL uninstallation (Debian)
apt:
name: "{{ item }}"
state: absent
purge: true
loop:
- postgresql
- postgresql-contrib
- python3-psycopg2
when: (ansible_os_family == "Debian")
- name: PostgreSQL uninstallation (RedHat)
apt:
name: "{{ item }}"
state: absent
purge: true
loop:
- postgresql
- postgresql-server
- python3-psycopg2
# - python3-pip
# - acl # Only for Docker containers
when: (ansible_os_family == "RedHat")
- name: Remove database
ansible.builtin.file:
path: "/var/lib/postgresql"
state: absent
- name: Create timestamp for log file
set_fact:
now: "{{ lookup('pipe', 'date +%Y%m%d-%H:%M:%S') }}"
handlers:
- name: Trace operation into local log file
delegate_to: localhost
ansible.builtin.lineinfile:
create: true
path: /var/log/Ansible.log
line: "{{ now }} - database {{ db_name }} destroyed!"