Skip to content

Commit

Permalink
add rm_pgpool2_install_config
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahms authored and vibhorkumar123 committed Mar 21, 2023
1 parent 11b5746 commit c77c9be
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 4 deletions.
9 changes: 5 additions & 4 deletions roles/setup_pgbouncer/tasks/setup_pgbouncer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
Available authentication types are {{ available_auth_type }}"
when: pgbouncer_auth_type not in available_auth_type

- name: Remove pgbouncer install and configuration based on force_pgbouncer
- name: Remove pgbouncer install and configuration based on force_initdb/force_replication/force_pgbouncer
ansible.builtin.include_tasks: rm_pgbouncer_install_config.yml
when:
- force_pgbouncer is defined
- force_pgbouncer
when: >
((force_pgbouncer is defined and force_pgbouncer) or
(force_initdb is defined and force_initdb) or
(force_replication is defined and force_replication))
- name: Include the pgbouncer_install
ansible.builtin.include_tasks: pgbouncer_install.yml
Expand Down
85 changes: 85 additions & 0 deletions roles/setup_pgpool2/tasks/rm_pgpool2_install_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
- name: Gather service facts
ansible.builtin.service_facts:

- name: Stop pgpool2 service
ansible.builtin.systemd:
name: "{{ pgpool2_service_name }}"
state: stopped
enabled: false
when:
- ansible_facts.services[pgpool2_service_name + '.service'] is defined
- ansible_facts.services[pgpool2_service_name + '.service'].state == 'running'
become: true

- name: Remove pgpoolII system user {{ pgpool2_user }}
ansible.builtin.user:
name: "{{ pgpool2_user }}"
group: "{{ pgpool2_group }}"
state: absent
remove: true
force: true
become: true

- name: Remove pgpoolII system group {{ pgpool2_group }}
ansible.builtin.group:
name: "{{ pgpool2_group }}"
state: absent
become: true

- name: Remove pgpoolII files and directory
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- "{{ pgpool2_configuration_file | dirname }}"
- "{{ pgpool2_logdir }}"
- "{{ pgpool2_systemd_config_file | dirname }}"
- "{{ pgpool2_pid_file_name | dirname }}"
become: true

- name: Remove optional pgpoolII directory
ansible.builtin.file:
path: "{{ pgpool2_logdir }}"
state: absent
when: pgpool2_logdir is defined

- name: Remove optional pgpoolII directory
ansible.builtin.file:
path: "{{ pgpool2_pid_file_name | dirname }}"
state: absent
when: pgpool2_pid_file_name is defined

- name: Remove pgpoolII package
ansible.builtin.package:
name: "{{ pgpool2_package_name }}"
state: absent
become: true

- name: Remove openssl package
ansible.builtin.package:
name: "openssl"
state: absent
when:
- pgpool2_ssl
become: true

- name: Remove pgpool-II-pcp package on RedHat
ansible.builtin.package:
name: "pgpool-II-pcp"
state: absent
when:
- ansible_os_family == 'RedHat'
- pg_type == 'PG'
become: true

- name: Remove dependent packages on Debian
ansible.builtin.package:
name:
- libpgpool2
- postgresql-client-common
state: absent
when:
- ansible_os_family == 'Debian'
- pg_type == 'PG'
become: true
6 changes: 6 additions & 0 deletions roles/setup_pgpool2/tasks/setup_pgpool2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@
when:
- use_hostname|bool

- name: Remove pgpool2 install and configuration based on force_pgpool2
ansible.builtin.include_tasks: rm_pgpool2_install_config.yml
when:
- force_pgpool2 is defined
- force_pgpool2

- name: Include the pgpool2_install
ansible.builtin.include_tasks: pgpool2_install.yml

Expand Down

0 comments on commit c77c9be

Please sign in to comment.