From 2cd88bb06da5ed941c267a26de5021bdabe3ad90 Mon Sep 17 00:00:00 2001 From: ismoilovdevml Date: Tue, 17 Sep 2024 21:03:41 +0500 Subject: [PATCH] fixed --- Ansible/redis/uninstall_redis.yml | 37 ++++++++++++------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/Ansible/redis/uninstall_redis.yml b/Ansible/redis/uninstall_redis.yml index 56964e7..09ebb5a 100644 --- a/Ansible/redis/uninstall_redis.yml +++ b/Ansible/redis/uninstall_redis.yml @@ -3,7 +3,6 @@ hosts: all become: yes tasks: - # Check if Redis is installed - name: Check if Redis is installed ansible.builtin.command: which redis-server register: redis_installed @@ -11,7 +10,6 @@ failed_when: false changed_when: false - # Stop Redis service only if installed - name: Stop Redis service if installed ansible.builtin.systemd: name: "{{ 'redis-server' if ansible_distribution in ['Debian', 'Ubuntu'] else 'redis' }}" @@ -19,7 +17,6 @@ when: redis_installed.rc == 0 ignore_errors: yes - # Uninstall Redis packages (Debian/Ubuntu) - name: Remove Redis packages (Debian/Ubuntu) ansible.builtin.apt: name: redis-server @@ -27,28 +24,25 @@ purge: yes when: redis_installed.rc == 0 and ansible_distribution in ['Debian', 'Ubuntu'] - # Uninstall Redis packages (RHEL/CentOS) - name: Remove Redis packages (RHEL/CentOS) ansible.builtin.yum: name: redis state: absent when: redis_installed.rc == 0 and ansible_distribution in ['CentOS', 'RedHat'] - # Remove Redis user only if it exists - - name: Remove Redis user - ansible.builtin.user: - name: redis - state: absent - ignore_errors: yes + # - name: Remove Redis user + # ansible.builtin.user: + # name: redis + # state: absent + # ignore_errors: yes - # Remove Redis group only if it exists - - name: Remove Redis group - ansible.builtin.group: - name: redis - state: absent - ignore_errors: yes + # # Redis guruhini o'chirish + # - name: Remove Redis group + # ansible.builtin.group: + # name: redis + # state: absent + # ignore_errors: yes - # Remove Redis data, logs, and configuration directories only if they exist - name: Remove Redis data, logs, and configuration directories ansible.builtin.file: path: "{{ item }}" @@ -59,10 +53,10 @@ - /var/log/redis - /etc/redis - /var/run/redis - when: redis_installed.rc == 0 + - /usr/bin/redis-server + when: redis_installed.rc == 0 and ansible.builtin.stat.path is directory ignore_errors: yes - # Remove Redis APT repository list - name: Remove Redis APT repository list (Debian/Ubuntu) ansible.builtin.file: path: /etc/apt/sources.list.d/redis.list @@ -70,7 +64,6 @@ when: ansible_distribution in ['Debian', 'Ubuntu'] ignore_errors: yes - # Remove Redis GPG key (Debian/Ubuntu) - name: Remove Redis GPG key (Debian/Ubuntu) ansible.builtin.apt_key: id: "9DC858229FC7DD38854AE2D88D81803C0EBFCD88" @@ -78,7 +71,6 @@ when: ansible_distribution in ['Debian', 'Ubuntu'] ignore_errors: yes - # Remove Redis YUM repository (RHEL/CentOS/Fedora) - name: Remove Redis YUM repository ansible.builtin.file: path: /etc/yum.repos.d/redis.repo @@ -86,10 +78,9 @@ when: ansible_distribution in ['CentOS', 'RedHat', 'Fedora'] ignore_errors: yes - # Remove Redis GPG key (RHEL/CentOS/Fedora) - name: Remove Redis GPG key (RHEL/CentOS/Fedora) ansible.builtin.rpm_key: key: https://packages.redis.io/gpg state: absent when: ansible_distribution in ['CentOS', 'RedHat', 'Fedora'] - ignore_errors: yes \ No newline at end of file + ignore_errors: yes