---
- hosts: undercloud
  vars:
    metadata:
      name: Check connectivity to various OpenStack services
      description: >
        # TODO: this could also check for undercloud encpoints
        This will attempt to connect to each service endpoint defined in
        your hosts file's controller_vip variable.
      groups:
      - post-deployment
  tasks:
  # Check connectivity to horizon
  - name: Check Horizon
    uri: url={{ overcloud_horizon_url }}
    when: overcloud_horizon_url|default('')

  - fail: msg="The `HorizonPublic` endpoint is not defined in the `EndpointMap` of the deployed stack. This means Horizon may not have been deployed correctly."
    when: overcloud_horizon_url|default('') == ''

  # Check that we can obtain an auth token from horizon
  - name: Check Keystone
    uri:
      url: "{{ overcloud_keystone_url }}/tokens"
      method: POST
      body_format: json
      body:
        auth:
          passwordCredentials:
            username: admin
            password: "{{ overcloud_admin_password }}"
          tenantName: admin
      return_content: yes
    register: auth_token
    when: overcloud_keystone_url|default('')

  - fail: msg="The `KeystoneURL` output is not available in the deployed stack."
    when: overcloud_keystone_url|default('') == ''

# TODO(shadower): other endpoints
