blob: 496fad01db850abecec077b79d1f7e5ee376ae37 [file] [log] [blame]
---
- hosts: {{ instance_name }}
gather_facts: False
connection: ssh
user: {{ username }}
sudo: yes
vars:
appname: {{ appname }}
dependencies: {{ dependencies }}
{% if rest_configs %}
rest_configs:
{% for rest_config in rest_configs %}
- endpoint: {{ rest_config.endpoint }}
body: "{{ '{{' }} lookup('file', '{{ files_dir }}/{{ rest_config.fn }}') {{ '}}' }}"
{% endfor %}
{% endif %}
tasks:
- name: Get Docker IP
script: /opt/xos/observers/onos/scripts/dockerip.sh {{ ONOS_container }}
register: onosaddr
- name: Wait for ONOS to come up
wait_for:
host={{ '{{' }} onosaddr.stdout {{ '}}' }}
port={{ '{{' }} item {{ '}}' }}
state=present
with_items:
- 8101
- 8181
- 9876
- name: Config file directory
file:
path=/home/ubuntu/{{ appname }}/
state=directory
{% if config_fns %}
- name: Copy over configuration files
copy:
src={{ files_dir }}/{{ '{{' }} item {{ '}}' }}
dest=/home/ubuntu/{{ appname }}/{{ '{{' }} item {{ '}}' }}
with_items:
{% for config_fn in config_fns %}
- {{ config_fn }}
{% endfor %}
- name: Make sure config directory exists
shell: docker exec {{ ONOS_container }} mkdir -p /root/onos/config/
sudo: yes
- name: Copy config files into container
shell: docker cp {{ appname }}/{{ '{{' }} item {{ '}}' }} {{ ONOS_container }}:/root/onos/config/
sudo: yes
with_items:
{% for config_fn in config_fns %}
- {{ config_fn }}
{% endfor %}
{% endif %}
# Don't know how to check for this condition, just wait
- name: Wait for ONOS to install the apps
wait_for: timeout=15
{% if dependencies %}
- name: Add dependencies to ONOS
uri:
url: http://{{ '{{' }} onosaddr.stdout {{ '}}' }}:8181/onos/v1/applications/{{ '{{' }} item {{ '}}' }}/active
method: POST
user: karaf
password: karaf
with_items:
{% for dependency in dependencies %}
- {{ dependency }}
{% endfor %}
{% endif %}
{% if rest_configs %}
# Do this after services have been activated, or it will cause an exception.
# vOLT will re-read its net config; vbng may not.
- name: Add ONOS configuration values
uri:
url: http://{{ '{{' }} onosaddr.stdout {{ '}}' }}:8181/{{ '{{' }} item.endpoint {{ '}}' }} #http://localhost:8181/onos/v1/network/configuration/
body: "{{ '{{' }} item.body {{ '}}' }}"
body_format: raw
method: POST
user: karaf
password: karaf
with_items: "rest_configs"
{% endif %}