1 Star 1 Fork 0

安家/tidb-ansible

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
stop.yml 9.10 KB
一键复制 编辑 原始数据 按行查看 历史
---
# Copyright 2016 PingCAP, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# See the License for the specific language governing permissions and
# limitations under the License.
# The playbook of TiDB
- name: check config locally
hosts: localhost
any_errors_fatal: true
tags:
- always
roles:
- check_config_static
- name: gather all facts, and check dest
hosts: all
any_errors_fatal: true
tags:
- always
roles:
- check_config_dynamic
- hosts: monitored_servers
tags:
- node_exporter
tasks:
- name: stop node_exporter by supervise
shell: cd {{ deploy_dir }}/scripts && ./stop_{{ item }}.sh
with_items:
- node_exporter
when: process_supervision == 'supervise'
- name: stop node_exporter by systemd
systemd: name={{ item }} state=stopped
become: true
when: process_supervision == 'systemd'
with_items:
- node_exporter-{{ node_exporter_port }}.service
- name: wait until the node_exporter port is down
wait_for:
host: "{{ ansible_host }}"
port: "{{ node_exporter_port }}"
state: stopped
msg: "the node_exporter port {{ node_exporter_port }} is not down"
- hosts: monitored_servers
tags:
- blackbox_exporter
tasks:
- name: stop blackbox_exporter by supervise
shell: cd {{ deploy_dir }}/scripts && ./stop_{{ item }}.sh
with_items:
- blackbox_exporter
when: process_supervision == 'supervise'
- name: stop node_exporter/blackbox_exporter by systemd
systemd: name={{ item }} state=stopped
become: true
when: process_supervision == 'systemd'
with_items:
- blackbox_exporter-{{ blackbox_exporter_port }}.service
- name: wait until the blackbox_exporter port is down
wait_for:
host: "{{ ansible_host }}"
port: "{{ blackbox_exporter_port }}"
state: stopped
msg: "the blackbox_exporter port {{ blackbox_exporter_port }} is not down"
- hosts: alertmanager_servers
tags:
- alertmanager
tasks:
- name: stop alertmanager by supervise
shell: cd {{ deploy_dir }}/scripts && ./stop_alertmanager.sh
when: process_supervision == 'supervise'
- name: stop alertmanager by systemd
systemd: name=alertmanager-{{ alertmanager_port }}.service state=stopped
become: true
when: process_supervision == 'systemd'
- name: wait until the alertmanager port is down
wait_for:
host: "{{ ansible_host }}"
port: "{{ alertmanager_port }}"
state: stopped
msg: "the alertmanager port {{ alertmanager_port }} is not down"
- hosts: monitoring_servers
tags:
- pushgateway
tasks:
- name: stop pushgateway by supervise
shell: cd {{ deploy_dir }}/scripts && ./stop_{{ item }}.sh
with_items:
- pushgateway
when: process_supervision == 'supervise'
- name: stop pushgateway by systemd
systemd: name={{ item }} state=stopped
when: process_supervision == 'systemd'
become: true
with_items:
- pushgateway-{{ pushgateway_port }}.service
- name: wait until the pushgateway port is down
wait_for:
host: "{{ ansible_host }}"
port: "{{ pushgateway_port }}"
state: stopped
msg: "the pushgateway port {{ pushgateway_port }} is not down"
- hosts: monitoring_servers
tags:
- prometheus
tasks:
- name: stop prometheus by supervise
shell: cd {{ deploy_dir }}/scripts && ./stop_{{ item }}.sh
with_items:
- prometheus
when: process_supervision == 'supervise'
- name: stop prometheus by systemd
systemd: name={{ item }} state=stopped
when: process_supervision == 'systemd'
become: true
with_items:
- prometheus-{{ prometheus_port }}.service
- name: wait until the prometheus port is down
wait_for:
host: "{{ ansible_host }}"
port: "{{ prometheus_port }}"
state: stopped
msg: "the prometheus port {{ prometheus_port }} is not down"
- hosts: kafka_exporter_servers
tags:
- kafka_exporter
tasks:
- name: stop kafka_exporter by supervise
shell: cd {{ deploy_dir }}/scripts && ./stop_kafka_exporter.sh
when:
- enable_binlog|default(false)
- process_supervision == 'supervise'
- name: stop kafka_exporter by systemd
become: true
systemd: name=kafka_exporter-{{ kafka_exporter_port }}.service state=stopped enabled=no
when:
- enable_binlog|default(false)
- process_supervision == 'systemd'
- name: wait until the kafka_exporter port is down
wait_for:
host: "{{ ansible_host }}"
port: "{{ kafka_exporter_port }}"
state: stopped
msg: "the kafka_exporter port {{ kafka_exporter_port }} is not down"
when: enable_binlog|default(false)
- hosts: tidb_servers
tags:
- tidb
tasks:
- name: stop TiDB by supervise
shell: cd {{ deploy_dir }}/scripts && ./stop_{{ item }}.sh
when: process_supervision == 'supervise'
with_items:
- tidb
- name: stop TiDB by systemd
systemd: name=tidb-{{ tidb_port }}.service state=stopped
become: true
when: process_supervision == 'systemd'
- name: wait until the TiDB port is down
wait_for:
host: "{{ ansible_host }}"
port: "{{ tidb_port }}"
state: stopped
msg: "the TiDB port {{ tidb_port }} is not down"
- hosts: pump_servers
tags:
- pump
tasks:
- name: stop pump by supervise
shell: cd {{ deploy_dir }}/scripts && ./stop_{{ item }}.sh
when:
- enable_binlog|default(false)
- process_supervision == 'supervise'
with_items:
- pump
- name: stop pump by systemd
systemd: name=pump-{{ pump_port }}.service state=stopped
become: true
when:
- enable_binlog|default(false)
- process_supervision == 'systemd'
- name: wait until the pump port is down
wait_for:
host: "{{ ansible_host }}"
port: "{{ pump_port }}"
state: stopped
msg: "the pump port {{ pump_port }} is not down"
when: enable_binlog|default(false)
- hosts: tikv_servers
tags:
- tikv
tasks:
- name: stop TiKV by supervise
shell: cd {{ deploy_dir }}/scripts && ./stop_{{ item }}.sh
when: process_supervision == 'supervise'
with_items:
- tikv
- name: stop TiKV by systemd
systemd: name=tikv-{{ tikv_port }}.service state=stopped
become: true
when: process_supervision == 'systemd'
- name: wait until the TiKV port is down
wait_for:
host: "{{ ansible_host }}"
port: "{{ tikv_port }}"
state: stopped
msg: "the TiKV port {{ tikv_port }} is not down"
- command: cat {{ deploy_dir }}/status/tikv.pid
register: old_tikv_pid
ignore_errors: yes
changed_when: false
- name: display old tikv pid
debug:
msg: "tikv binary or docker pid: {{ old_tikv_pid.stdout }}"
- hosts: pd_servers
tags:
- pd
tasks:
- name: stop PD by supervise
shell: cd {{ deploy_dir }}/scripts && ./stop_{{ item }}.sh
when: process_supervision == 'supervise'
with_items:
- pd
- name: stop PD by systemd
systemd: name=pd-{{ pd_client_port }}.service state=stopped
become: true
when: process_supervision == 'systemd'
- name: wait until the PD port is down
wait_for:
host: "{{ ansible_host }}"
port: "{{ pd_client_port }}"
state: stopped
msg: "the PD port {{ pd_client_port }} is not down"
- hosts: grafana_servers
tags:
- grafana
tasks:
- name: stop grafana by supervise
shell: cd {{ deploy_dir }}/scripts && ./stop_{{ item }}.sh
when: process_supervision == 'supervise'
with_items:
- grafana
- name: stop grafana by systemd
systemd: name=grafana-{{ grafana_port }}.service state=stopped
become: true
when: process_supervision == 'systemd'
- name: wait until the grafana port is down
wait_for:
host: "{{ ansible_host }}"
port: "{{ grafana_port }}"
state: stopped
msg: "the grafana port {{ grafana_port }} is not down"
- name: stop grafana_collector by supervise
shell: cd {{ deploy_dir }}/scripts && ./stop_{{ item }}.sh
when: process_supervision == 'supervise'
with_items:
- grafana_collector
- name: stop grafana_collector by systemd
systemd: name=grafana_collector-{{ grafana_collector_port }}.service state=stopped
become: true
when: process_supervision == 'systemd'
- name: wait until the grafana_collector port is down
wait_for:
host: "{{ ansible_host }}"
port: "{{ grafana_collector_port }}"
state: stopped
msg: "the grafana_collector port {{ grafana_collector_port }} is not down"
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/anjia/tidb-ansible.git
git@gitee.com:anjia/tidb-ansible.git
anjia
tidb-ansible
tidb-ansible
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385