---
# 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: check node config
  hosts: all
  any_errors_fatal: true
  gather_facts: false
  become: true
  roles:
    - bootstrap

- name: initializing deployment target
  hosts: all
  any_errors_fatal: true
  tags:
    - always
  roles:
    - check_config_dynamic

- name: deploying pushgateway
  hosts: monitoring_servers
  tags:
    - pushgateway
  roles:
    - pushgateway

- name: deploying prometheus
  hosts: monitoring_servers
  tags:
    - prometheus
  roles:
    - prometheus

# deploying TiDB cluster
- name: deploying PD cluster
  hosts: pd_servers
  tags:
    - pd
  roles:
    - pd

- name: deploying TiKV cluster
  hosts: tikv_servers
  tags:
    - tikv
  roles:
    - tikv

- name: deploying TiDB cluster
  hosts: tidb_servers
  tags:
    - tidb
  roles:
    - tidb

- name: deploying dashboard
  hosts: monitoring_servers
  tags:
    - dashboard
  roles:
    - dashboard

- name: finalizing deployment target
  hosts: all
  become: true
  roles:
    - { role: firewalld, when: enable_firewalld is defined and enable_firewalld }
