---
- name: Verify all masters has etcd3 storage backend set
  hosts: oo_masters_to_config
  gather_facts: no
  roles:
  - lib_utils
  tasks:
  - name: Read master storage backend setting
    yedit:
      state: list
      src: /etc/origin/master/master-config.yaml
      key: kubernetesMasterConfig.apiServerArguments.storage-backend
    register: _storage_backend

  - fail:
      msg: "Storage backend in /etc/origin/master/master-config.yaml must be set to 'etcd3' before the upgrade can continue"
    when:
    # assuming the master-config.yml is properly configured, i.e. the value is a list
    - _storage_backend.result | default([], true) | length == 0 or _storage_backend.result[0] != "etcd3"

  - debug:
      msg: "Storage backend is set to etcd3"
