-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2ad2e7
commit f1f8200
Showing
13 changed files
with
320 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
- import_playbook: install_prometheus.yml | ||
- import_playbook: install_node_exporter.yml | ||
- import_playbook: install_grafana.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
[prometheus] | ||
server3 ansible_host=34.170.180.55 ansible_user=ismoilovdev | ||
debian ansible_host=34.170.180.55 ansible_user=ismoilovdev | ||
ubuntu ansible_host=34.27.32.115 ansible_user=ismoilovdev | ||
centos ansible_host=34.69.104.233 ansible_user=ismoilovdev | ||
|
||
[node_exporter] | ||
server1 ansible_host=34.69.104.233 ansible_user=ismoilovdev | ||
server2 ansible_host=34.27.32.115 ansible_user=ismoilovdev | ||
server3 ansible_host=34.170.180.55 ansible_user=ismoilovdev | ||
debian ansible_host=34.170.180.55 ansible_user=ismoilovdev | ||
ubuntu ansible_host=34.27.32.115 ansible_user=ismoilovdev | ||
centos ansible_host=34.69.104.233 ansible_user=ismoilovdev | ||
|
||
[grafana] | ||
server2 ansible_host=34.27.32.115 ansible_user=ismoilovdev | ||
debian ansible_host=34.170.180.55 ansible_user=ismoilovdev | ||
ubuntu ansible_host=34.27.32.115 ansible_user=ismoilovdev | ||
centos ansible_host=34.69.104.233 ansible_user=ismoilovdev |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
- import_playbook: uninstall_prometheus.yml | ||
- import_playbook: uninstall_node_exporter.yml | ||
- import_playbook: uninstall_grafana.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
--- | ||
- name: Uninstall Grafana and cleanup | ||
hosts: grafana | ||
become: true | ||
tasks: | ||
|
||
- name: Check if Grafana service is present | ||
ansible.builtin.systemd: | ||
name: grafana-server | ||
state: stopped | ||
register: grafana_service_status | ||
ignore_errors: yes | ||
failed_when: false | ||
|
||
- name: Stop Grafana service if it exists | ||
ansible.builtin.systemd: | ||
name: grafana-server | ||
state: stopped | ||
when: grafana_service_status.failed is not defined | ||
|
||
- name: Remove Grafana package (Debian/Ubuntu) | ||
ansible.builtin.apt: | ||
name: grafana | ||
state: absent | ||
when: ansible_distribution in ['Ubuntu', 'Debian'] | ||
|
||
- name: Remove Grafana package (CentOS/RHEL/Fedora) | ||
ansible.builtin.yum: | ||
name: grafana | ||
state: absent | ||
when: ansible_distribution in ['CentOS', 'RedHat', 'Fedora'] | ||
|
||
- name: Remove Grafana package (SUSE/openSUSE) | ||
ansible.builtin.zypper: | ||
name: grafana | ||
state: absent | ||
when: ansible_distribution in ['openSUSE', 'SUSE Linux Enterprise Server'] | ||
|
||
- name: Remove Grafana repository (Debian/Ubuntu) | ||
ansible.builtin.apt_repository: | ||
repo: "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | ||
state: absent | ||
when: ansible_distribution in ['Ubuntu', 'Debian'] | ||
|
||
- name: Remove Grafana repository (CentOS/RHEL/Fedora) | ||
ansible.builtin.file: | ||
path: /etc/yum.repos.d/grafana.repo | ||
state: absent | ||
when: ansible_distribution in ['CentOS', 'RedHat', 'Fedora'] | ||
|
||
- name: Remove Grafana repository (SUSE/openSUSE) | ||
ansible.builtin.zypper_repository: | ||
name: grafana | ||
state: absent | ||
when: ansible_distribution in ['openSUSE', 'SUSE Linux Enterprise Server'] | ||
|
||
- name: Remove Grafana configuration and data directories | ||
ansible.builtin.file: | ||
path: "{{ item }}" | ||
state: absent | ||
loop: | ||
- /etc/grafana | ||
- /var/lib/grafana | ||
- /var/log/grafana | ||
|
||
- name: Clean up Grafana GPG key (Debian/Ubuntu) | ||
ansible.builtin.file: | ||
path: /etc/apt/keyrings/grafana.gpg | ||
state: absent | ||
when: ansible_distribution in ['Ubuntu', 'Debian'] | ||
|
||
- name: Find all installed GPG keys (CentOS/RHEL/Fedora) | ||
ansible.builtin.shell: "rpm -q gpg-pubkey --qf '%{VERSION}-%{RELEASE}\\n'" | ||
register: gpg_keys | ||
changed_when: false | ||
when: ansible_distribution in ['CentOS', 'RedHat', 'Fedora'] | ||
|
||
- name: Clean up Grafana GPG keys (CentOS/RHEL/Fedora) | ||
ansible.builtin.shell: | | ||
rpm --erase gpg-pubkey-{{ item }} | ||
loop: "{{ gpg_keys.stdout_lines }}" | ||
when: | ||
- ansible_distribution in ['CentOS', 'RedHat', 'Fedora'] | ||
- gpg_keys.stdout != '' | ||
- item != '' | ||
ignore_errors: yes | ||
|
||
- name: Check if Grafana GPG key exists (SUSE/openSUSE) | ||
ansible.builtin.shell: "rpm -q gpg-pubkey" | ||
register: gpg_key_check_suse | ||
changed_when: false | ||
ignore_errors: yes | ||
when: ansible_distribution in ['openSUSE', 'SUSE Linux Enterprise Server'] | ||
|
||
- name: Clean up Grafana GPG key (SUSE/openSUSE) if it exists | ||
ansible.builtin.shell: | | ||
rpm --erase gpg-pubkey-$(rpm -q --qf "%{version}-%{release}" gpg-pubkey*) | ||
when: | ||
- ansible_distribution in ['openSUSE', 'SUSE Linux Enterprise Server'] | ||
- gpg_key_check_suse.rc == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
- name: Uninstall Node Exporter and cleanup | ||
hosts: node_exporter | ||
become: yes | ||
vars_files: | ||
- vars.yml | ||
tasks: | ||
|
||
- name: Check if Node Exporter service is present | ||
ansible.builtin.systemd: | ||
name: node_exporter | ||
state: stopped | ||
register: node_exporter_service_status | ||
ignore_errors: yes | ||
failed_when: false | ||
|
||
- name: Stop Node Exporter service if it exists | ||
ansible.builtin.systemd: | ||
name: node_exporter | ||
state: stopped | ||
when: node_exporter_service_status.failed is not defined | ||
|
||
- name: Disable Node Exporter service if it exists | ||
ansible.builtin.systemd: | ||
name: node_exporter | ||
enabled: no | ||
when: node_exporter_service_status.failed is not defined | ||
|
||
- name: Remove Node Exporter systemd service file | ||
ansible.builtin.file: | ||
path: /etc/systemd/system/node_exporter.service | ||
state: absent | ||
|
||
- name: Reload systemd daemon to remove Node Exporter service | ||
ansible.builtin.systemd: | ||
daemon_reload: yes | ||
|
||
- name: Remove Node Exporter binary | ||
ansible.builtin.file: | ||
path: /usr/local/bin/node_exporter | ||
state: absent | ||
|
||
- name: Remove Node Exporter user | ||
ansible.builtin.user: | ||
name: node_exporter | ||
state: absent | ||
remove: yes | ||
|
||
- name: Remove /tmp directory and any remaining files | ||
ansible.builtin.file: | ||
path: /tmp/node_exporter-{{ node_exporter_version }}.linux-amd64* | ||
state: absent | ||
|
||
- name: Clean up Node Exporter cache (if exists) | ||
ansible.builtin.file: | ||
path: /var/cache/node_exporter | ||
state: absent | ||
|
||
- name: Remove Node Exporter logs (if exists) | ||
ansible.builtin.file: | ||
path: /var/log/node_exporter | ||
state: absent | ||
|
||
- name: Remove any additional Node Exporter related directories | ||
ansible.builtin.find: | ||
paths: | ||
- "/tmp" | ||
- "/usr/local" | ||
patterns: "node_exporter*" | ||
register: node_exporter_dirs | ||
|
||
- name: Clean found Node Exporter directories | ||
ansible.builtin.file: | ||
path: "{{ item.path }}" | ||
state: absent | ||
loop: "{{ node_exporter_dirs.files }}" |
Oops, something went wrong.