---
- name: etcd Install Checkpoint Start
  hosts: all
  gather_facts: false
  tasks:
  - name: Set etcd install 'In Progress'
    run_once: true
    set_stats:
      data:
        installer_phase_etcd:
          title: "etcd Install"
          playbook: "playbooks/openshift-etcd/config.yml"
          status: "In Progress"
          start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"

- import_playbook: ca.yml

- import_playbook: certificates.yml

- name: Configure etcd
  hosts: oo_etcd_to_config
  any_errors_fatal: true
  tasks:
  - fail:
      msg: >
        etcd stand-alone hosts on atomic is no longer supported. Please
        co-locate your etcd hosts with masters.
    when:
    - openshift_is_atomic | bool
    - not inventory_hostname in groups['oo_masters']

  - import_role:
      name: etcd
      tasks_from: set_facts.yml

  # Setup etcd as a static pod if collocated with a master
  - import_role:
      name: etcd
      tasks_from: static.yml
    vars:
      etcd_peers: "{{ groups.oo_etcd_to_config | default([], true) }}"
      etcd_certificates_etcd_hosts: "{{ groups.oo_etcd_to_config | default([], true) }}"
    when: inventory_hostname in groups['oo_masters']

  - import_role:
      name: etcd
      tasks_from: rpm.yml
    when: not inventory_hostname in groups['oo_masters']
    vars:
      etcd_peers: "{{ groups.oo_etcd_to_config | default([], true) }}"
      etcd_certificates_etcd_hosts: "{{ groups.oo_etcd_to_config | default([], true) }}"

- name: etcd Install Checkpoint End
  hosts: all
  gather_facts: false
  tasks:
  - name: Set etcd install 'Complete'
    run_once: true
    set_stats:
      data:
        installer_phase_etcd:
          status: "Complete"
          end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
