blob: 9105a2eb640b56f714be4a78d0d5d72affdfe0e4 [file] [log] [blame]
---
- hosts: {{ instance_name }}
gather_facts: False
connection: ssh
user: ubuntu
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: 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
- name: Add dependencies to ONOS
uri:
url: http://localhost:8181/onos/v1/applications/{{ '{{' }} item {{ '}}' }}/active
method: POST
user: karaf
password: karaf
with_items:
{% for dependency in dependencies %}
- {{ dependency }}
{% endfor %}
{% 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://localhost: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 %}