---
# tasks file for pd

- name: create deploy directories
  file: path={{ item }} state=directory mode=0755
  with_items:
  - "{{ pd_log_dir }}"
  - "{{ pd_data_dir }}"

- name: "load customized config: pd.yml"
  include_vars: file={{ playbook_dir }}/conf/pd.yml name=pd_conf_custom

- name: load default config
  include_vars: file=default.yml name=pd_conf_default

- name: generate dynamic config
  set_fact:
    pd_conf_generated:
      replication:
        location-labels: "{{ location_labels }}"

- name: generate final config
  set_fact:
    pd_conf: "{{ pd_conf_custom | with_default_dicts(pd_conf_generated, pd_conf_default) }}"

- debug: var=pd_conf

- name: create configuration file
  template: src=pd.toml.j2 dest=/etc/pd.toml mode=0644

- include_tasks: "binary_deployment.yml"

- name: prepare firewalld white list
  set_fact:
    firewalld_ports: "{{ [pd_peer_port ~ '/tcp', pd_client_port ~ '/tcp'] + firewalld_ports }}"
