---
# compute-node-enable-maas/tasks/main.yml

- name: Fetch generated nodes.yaml file
  fetch:
    src: "{{ cord_profile_dir + '/' + item }}"
    dest: "/tmp/{{ item }}"
    flat: yes
    fail_on_missing: yes
  with_items:
    - openstack.yaml
    - vtn-service.yaml
    - openstack-compute.yaml
    - openstack-compute-vtn.yaml

- name: Load TOSCA to add OpenStack compute nodes, over REST
  xostosca:
    url: "http://xos.{{ site_suffix }}:{{ xos_ui_port }}/api/utility/tosca/run/"
    user: "{{ xos_admin_user }}"
    password:  "{{ xos_admin_pass }}"
    recipe: "{{ lookup('file', '/tmp/' + item ) }}"
  with_items:
    - openstack.yaml
    - openstack-compute.yaml

- name: Pause to work around race in VTN or ONOS synchronizers
  pause:
    seconds: 20

- name: Load TOSCA to enable VTN on OpenStack compute nodes, over REST
  xostosca:
    url: "http://xos.{{ site_suffix }}:{{ xos_ui_port }}/api/utility/tosca/run/"
    user: "{{ xos_admin_user }}"
    password:  "{{ xos_admin_pass }}"
    recipe: "{{ lookup('file', '/tmp/' + item ) }}"
  with_items:
    - vtn-service.yaml
    - openstack-compute-vtn.yaml

