Skip to content

Commit

Permalink
add rm_pgbouncer_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 df4bc62 commit 11b5746
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
53 changes: 53 additions & 0 deletions roles/setup_pgbouncer/tasks/rm_pgbouncer_install_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
- name: Gather service facts
ansible.builtin.service_facts:

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

- name: Remove PgBouncer system user {{ pgbouncer_user }}
ansible.builtin.user:
name: "{{ pgbouncer_user }}"
group: "{{ pgbouncer_group }}"
state: absent
remove: true
force: true
become: true

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

- name: Remove PgBouncer files and directory
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- "{{ pgbouncer_config_file | dirname }}"
- "{{ pgbouncer_systemd_unit_file | dirname }}"
- "{{ pgbouncer_pid_file | dirname }}"
- "{{ pgbouncer_log_file | dirname }}"
become: true

- name: Remove PgBouncer package
ansible.builtin.package:
name: "{{ pgbouncer_package_name }}"
state: absent
become: true

- name: Remove openssl package
ansible.builtin.package:
name: "openssl"
state: absent
when:
- pgbouncer_ssl
become: true
6 changes: 6 additions & 0 deletions roles/setup_pgbouncer/tasks/setup_pgbouncer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +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
ansible.builtin.include_tasks: rm_pgbouncer_install_config.yml
when:
- force_pgbouncer is defined
- force_pgbouncer

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

Expand Down

0 comments on commit 11b5746

Please sign in to comment.