Skip to content

Commit

Permalink
[NEW] addes uninstall playbook
Browse files Browse the repository at this point in the history
  • Loading branch information
ismoilovdevml committed Sep 10, 2024
1 parent 5f103fd commit 7eab0bb
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 2 deletions.
101 changes: 101 additions & 0 deletions Ansible/jenkins/uninstall_jenkins.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
---
- name: Uninstall Jenkins and cleanup on multiple OS
hosts: jenkins_servers
become: true
vars:
java_package_debian: openjdk-17-jre
java_package_rhel: java-17-openjdk

tasks:

- name: Stop Jenkins on Debian/Ubuntu
when: ansible_os_family == "Debian"
systemd:
name: jenkins
state: stopped
ignore_errors: yes # Agar xizmat topilmasa ham, davom ettiradi

- name: Uninstall Jenkins and Java on Debian/Ubuntu
when: ansible_os_family == "Debian"
apt:
name:
- jenkins
- "{{ java_package_debian }}"
- fontconfig
state: absent
purge: yes

- name: Remove Jenkins repo from sources list on Debian/Ubuntu
when: ansible_os_family == "Debian"
ansible.builtin.file:
path: /etc/apt/sources.list.d/jenkins.list
state: absent

- name: Remove Jenkins keyring on Debian/Ubuntu
when: ansible_os_family == "Debian"
ansible.builtin.file:
path: /usr/share/keyrings/jenkins-keyring.asc
state: absent

- name: Remove Jenkins cache and log directories on Debian/Ubuntu
when: ansible_os_family == "Debian"
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- /var/cache/jenkins
- /var/log/jenkins

- name: Check if Jenkins data directory exists on Debian/Ubuntu
when: ansible_os_family == "Debian"
stat:
path: /var/lib/jenkins
register: jenkins_data_dir

- name: Remove Jenkins data directory on Debian/Ubuntu
when: ansible_os_family == "Debian" and jenkins_data_dir.stat.exists
ansible.builtin.file:
path: /var/lib/jenkins
state: absent
recurse: yes
force: yes

- name: Stop Jenkins on Red Hat/Fedora/Alma/Rocky
when: ansible_os_family == "RedHat"
systemd:
name: jenkins
state: stopped
ignore_errors: yes # Agar xizmat topilmasa ham, davom ettiradi

- name: Uninstall Jenkins and Java on Red Hat/Fedora/Alma/Rocky
when: ansible_os_family == "RedHat"
yum:
name:
- jenkins
- "{{ java_package_rhel }}"
- fontconfig
state: absent

- name: Remove Jenkins repo file on Red Hat/Fedora/Alma/Rocky
when: ansible_os_family == "RedHat"
ansible.builtin.file:
path: /etc/yum.repos.d/jenkins.repo
state: absent

- name: Remove Jenkins key on Red Hat/Fedora/Alma/Rocky
when: ansible_os_family == "RedHat"
ansible.builtin.command:
cmd: rpm -e gpg-pubkey-$(rpm -q --qf "%{version}-%{release}\n" gpg-pubkey | grep jenkins | awk '{print $1}')
ignore_errors: yes # Agar kalit topilmasa, davom ettiradi

- name: Remove Jenkins cache, log, and data directories on Red Hat/Fedora/Alma/Rocky
when: ansible_os_family == "RedHat"
ansible.builtin.file:
path: "{{ item }}"
state: absent
recurse: yes
force: yes
loop:
- /var/cache/jenkins
- /var/log/jenkins
- /var/lib/jenkins
4 changes: 2 additions & 2 deletions Ansible/minio/minio_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
- main.yml
tasks:

- name: Install wget
apt:
- name: Install wget on multiple OS
package:
name: wget
state: present
update_cache: yes
Expand Down
68 changes: 68 additions & 0 deletions Ansible/minio/uninstall_minio.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
- name: Uninstall and cleanup MinIO
hosts: minio_servers
become: yes
vars_files:
- main.yml
tasks:

- name: Stop and disable MinIO service
systemd:
name: minio
state: stopped
enabled: no
ignore_errors: yes

- name: Remove MinIO service file
file:
path: /usr/lib/systemd/system/minio.service
state: absent

- name: Reload systemd daemon
systemd:
daemon_reload: yes

- name: Remove MinIO binary
file:
path: /usr/local/bin/minio
state: absent

- name: Remove MinIO environment file
file:
path: /etc/default/minio
state: absent

- name: Remove all files in MinIO data directory
become: yes
file:
path: "{{ minio_directory }}"
state: absent
recurse: yes
ignore_errors: yes

- name: Remove MinIO data directory
become: yes
file:
path: "{{ minio_directory }}"
state: absent
ignore_errors: yes

- name: Remove MinIO user
user:
name: minio-user
state: absent
ignore_errors: yes
become: yes

- name: Remove MinIO group
group:
name: minio-user
state: absent
ignore_errors: yes
become: yes

- name: Remove wget on multiple OS
package:
name: wget
state: absent
purge: yes

0 comments on commit 7eab0bb

Please sign in to comment.