
# Copyright 2017-present Open Networking Foundation
#
# 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,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


---
# monitoringservice-onboard/tasks/main.yml

- name: Disable onboarding
  command: "python /opt/xos/tosca/run.py {{ xos_admin_user }} {{ head_cord_profile_dir }}/disable-onboarding.yaml"
  tags:
    - skip_ansible_lint # TOSCA loading should be idempotent

- name: Have XOS container mount monitoringservice volume
  command: "python /opt/xos/tosca/run.py {{ xos_admin_user }} {{ head_cord_profile_dir }}/xos-monitoringservice.yaml"
  tags:
    - skip_ansible_lint # TOSCA loading should be idempotent

- name: Onboard monitoringservice
  command: "python /opt/xos/tosca/run.py {{ xos_admin_user }} {{ head_cord_profile_dir }}/monitoring-onboard.yaml"
  tags:
    - skip_ansible_lint # TOSCA loading should be idempotent

- name: Enable onboarding
  command: "python /opt/xos/tosca/run.py {{ xos_admin_user }} {{ head_cord_profile_dir }}/enable-onboarding.yaml"
  tags:
    - skip_ansible_lint # TOSCA loading should be idempotent

- name: Wait for monitoring to be onboarded
  uri:
    url: "http://localhost:{{ xos_bootstrap_ui_port }}/api/utility/onboarding/services/monitoring/ready/"
    method: GET
    return_content: yes
  register: xos_onboard_status
  until: '"true" in xos_onboard_status.content'
  retries: 60
  delay: 2

- name: Wait for XOS to be onboarded after monitoringservice onboarding
  uri:
    url: "http://localhost:{{ xos_bootstrap_ui_port }}/api/utility/onboarding/xos/ready/"
    method: GET
    return_content: yes
  register: xos_onboard_status
  until: '"true" in xos_onboard_status.content'
  retries: 60
  delay: 2

