2021-07-06 02:07:05 +08:00
|
|
|
---
|
|
|
|
# This playbook purges the Ceph MGR Dashboard and Monitoring
|
|
|
|
# (alertmanager/prometheus/grafana/node-exporter) stack.
|
|
|
|
# It removes: packages, configuration files and ALL THE DATA
|
|
|
|
#
|
|
|
|
# Use it like this:
|
|
|
|
# ansible-playbook purge-dashboard.yml
|
|
|
|
# Prompts for confirmation to purge, defaults to no and
|
|
|
|
# doesn't purge anything. yes purges the dashboard and
|
|
|
|
# monitoring stack.
|
|
|
|
#
|
|
|
|
# ansible-playbook -e ireallymeanit=yes|no purge-dashboard.yml
|
|
|
|
# Overrides the prompt using -e option. Can be used in
|
|
|
|
# automation scripts to avoid interactive prompt.
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Confirm whether user really meant to purge the dashboard
|
2021-07-06 02:07:05 +08:00
|
|
|
hosts: localhost
|
|
|
|
gather_facts: false
|
|
|
|
vars_prompt:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: ireallymeanit # noqa: name[casing]
|
2021-07-06 02:07:05 +08:00
|
|
|
prompt: Are you sure you want to purge the dashboard?
|
|
|
|
default: 'no'
|
2024-02-14 18:14:02 +08:00
|
|
|
private: false
|
2021-07-06 02:07:05 +08:00
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Exit playbook, if user did not mean to purge dashboard
|
|
|
|
ansible.builtin.fail:
|
2021-07-06 02:07:05 +08:00
|
|
|
msg: >
|
|
|
|
"Exiting purge-dashboard playbook, dashboard was NOT purged.
|
|
|
|
To purge the dashboard, either say 'yes' on the prompt or
|
|
|
|
or use `-e ireallymeanit=yes` on the command line when
|
|
|
|
invoking the playbook"
|
|
|
|
when: ireallymeanit != 'yes'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import_role ceph-defaults
|
|
|
|
ansible.builtin.import_role:
|
2022-07-29 19:19:13 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Gather facts on all hosts
|
2021-07-06 02:07:05 +08:00
|
|
|
hosts:
|
|
|
|
- "{{ mon_group_name|default('mons') }}"
|
|
|
|
- "{{ osd_group_name|default('osds') }}"
|
|
|
|
- "{{ mds_group_name|default('mdss') }}"
|
|
|
|
- "{{ rgw_group_name|default('rgws') }}"
|
|
|
|
- "{{ rbdmirror_group_name|default('rbdmirrors') }}"
|
|
|
|
- "{{ client_group_name|default('clients') }}"
|
|
|
|
- "{{ mgr_group_name|default('mgrs') }}"
|
|
|
|
- "{{ monitoring_group_name | default('monitoring') }}"
|
|
|
|
become: true
|
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Gather facts on all Ceph hosts for following reference
|
|
|
|
ansible.builtin.debug:
|
|
|
|
msg: "gather facts on all Ceph hosts for following reference"
|
2021-07-06 02:07:05 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Purge node exporter
|
2021-07-06 02:07:05 +08:00
|
|
|
hosts:
|
|
|
|
- "{{ mon_group_name|default('mons') }}"
|
|
|
|
- "{{ osd_group_name|default('osds') }}"
|
|
|
|
- "{{ mds_group_name|default('mdss') }}"
|
|
|
|
- "{{ rgw_group_name|default('rgws') }}"
|
|
|
|
- "{{ rbdmirror_group_name|default('rbdmirrors') }}"
|
|
|
|
- "{{ client_group_name|default('clients') }}"
|
|
|
|
- "{{ mgr_group_name|default('mgrs') }}"
|
|
|
|
- "{{ monitoring_group_name | default('monitoring') }}"
|
|
|
|
gather_facts: false
|
|
|
|
become: true
|
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
2021-07-06 02:07:05 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-facts role
|
|
|
|
ansible.builtin.import_role:
|
2021-07-06 02:07:05 +08:00
|
|
|
name: ceph-facts
|
|
|
|
tasks_from: container_binary
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Disable node_exporter service
|
|
|
|
ansible.builtin.service:
|
2021-07-06 02:07:05 +08:00
|
|
|
name: node_exporter
|
|
|
|
state: stopped
|
2024-02-14 18:14:02 +08:00
|
|
|
enabled: false
|
2021-07-06 02:07:05 +08:00
|
|
|
failed_when: false
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove node_exporter service files
|
|
|
|
ansible.builtin.file:
|
2021-09-08 00:13:37 +08:00
|
|
|
name: "{{ item }}"
|
2021-07-06 02:07:05 +08:00
|
|
|
state: absent
|
2021-09-08 00:13:37 +08:00
|
|
|
loop:
|
|
|
|
- /etc/systemd/system/node_exporter.service
|
|
|
|
- /run/node_exporter.service-cid
|
2021-07-06 02:07:05 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove node-exporter image
|
|
|
|
ansible.builtin.command: "{{ container_binary }} rmi {{ node_exporter_container_image }}"
|
2021-07-06 02:07:05 +08:00
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Purge ceph monitoring
|
2021-07-06 02:07:05 +08:00
|
|
|
hosts: "{{ monitoring_group_name | default('monitoring') }}"
|
|
|
|
gather_facts: false
|
|
|
|
become: true
|
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
2021-07-06 02:07:05 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-facts role
|
|
|
|
ansible.builtin.import_role:
|
2021-07-06 02:07:05 +08:00
|
|
|
name: ceph-facts
|
|
|
|
tasks_from: container_binary
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Stop services
|
|
|
|
ansible.builtin.service:
|
2021-07-06 02:07:05 +08:00
|
|
|
name: "{{ item }}"
|
|
|
|
state: stopped
|
2024-02-14 18:14:02 +08:00
|
|
|
enabled: false
|
2021-07-06 02:07:05 +08:00
|
|
|
failed_when: false
|
|
|
|
loop:
|
|
|
|
- alertmanager
|
|
|
|
- prometheus
|
|
|
|
- grafana-server
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove systemd service files
|
|
|
|
ansible.builtin.file:
|
2021-09-08 00:13:37 +08:00
|
|
|
name: "{{ item }}"
|
2021-07-06 02:07:05 +08:00
|
|
|
state: absent
|
|
|
|
loop:
|
2021-09-08 00:13:37 +08:00
|
|
|
- /etc/systemd/system/alertmanager.service
|
|
|
|
- /etc/systemd/system/prometheus.service
|
|
|
|
- /etc/systemd/system/grafana-server.service
|
|
|
|
- /run/alertmanager.service-cid
|
|
|
|
- /run/prometheus.service-cid
|
|
|
|
- /run/grafana-server.service-cid
|
2021-07-06 02:07:05 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove ceph dashboard container images
|
|
|
|
ansible.builtin.command: "{{ container_binary }} rmi {{ item }}"
|
2021-07-06 02:07:05 +08:00
|
|
|
loop:
|
|
|
|
- "{{ alertmanager_container_image }}"
|
|
|
|
- "{{ prometheus_container_image }}"
|
|
|
|
- "{{ grafana_container_image }}"
|
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove ceph-grafana-dashboards package on RedHat or SUSE
|
|
|
|
ansible.builtin.package:
|
2021-07-06 02:07:05 +08:00
|
|
|
name: ceph-grafana-dashboards
|
|
|
|
state: absent
|
|
|
|
when:
|
|
|
|
- not containerized_deployment | bool
|
|
|
|
- ansible_facts['os_family'] in ['RedHat', 'Suse']
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove data
|
|
|
|
ansible.builtin.file:
|
2021-07-06 02:07:05 +08:00
|
|
|
name: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
loop:
|
|
|
|
- "{{ alertmanager_conf_dir }}"
|
|
|
|
- "{{ prometheus_conf_dir }}"
|
|
|
|
- /etc/grafana
|
|
|
|
- "{{ alertmanager_data_dir }}"
|
|
|
|
- "{{ prometheus_data_dir }}"
|
|
|
|
- /var/lib/grafana
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Purge ceph dashboard
|
2021-07-06 02:07:05 +08:00
|
|
|
hosts: "{{ groups[mgr_group_name] | default(groups[mon_group_name]) | default(omit) }}"
|
|
|
|
gather_facts: false
|
|
|
|
become: true
|
|
|
|
environment:
|
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
2021-07-06 02:07:05 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-facts role
|
|
|
|
ansible.builtin.import_role:
|
2021-07-06 02:07:05 +08:00
|
|
|
name: ceph-facts
|
|
|
|
tasks_from: container_binary
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove the dashboard admin user
|
2021-07-06 02:07:05 +08:00
|
|
|
ceph_dashboard_user:
|
|
|
|
name: "{{ dashboard_admin_user }}"
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
state: absent
|
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove radosgw system user
|
2021-07-06 02:07:05 +08:00
|
|
|
radosgw_user:
|
|
|
|
name: "{{ dashboard_rgw_api_user_id }}"
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
state: absent
|
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
when: groups.get(rgw_group_name, []) | length > 0
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Disable mgr dashboard and prometheus modules
|
2021-07-06 02:07:05 +08:00
|
|
|
ceph_mgr_module:
|
|
|
|
name: "{{ item }}"
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
state: disable
|
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
loop:
|
|
|
|
- dashboard
|
|
|
|
- prometheus
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove TLS certificate and key files
|
|
|
|
ansible.builtin.file:
|
2021-07-06 02:07:05 +08:00
|
|
|
name: "/etc/ceph/ceph-dashboard.{{ item }}"
|
|
|
|
state: absent
|
|
|
|
loop:
|
|
|
|
- crt
|
|
|
|
- key
|
|
|
|
when: dashboard_protocol == "https"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove ceph-mgr-dashboard package
|
|
|
|
ansible.builtin.package:
|
2021-07-06 02:07:05 +08:00
|
|
|
name: ceph-mgr-dashboard
|
|
|
|
state: absent
|
|
|
|
when: not containerized_deployment | bool
|