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

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

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

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

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

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

- name: Wait for XOS to be onboarded after exampleservice 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: 10

