blob: dd6432dc141a088daed114ecb96fa4fd1d2b2999 [file] [log] [blame]
Matteo Scandolo7781b5b2017-08-08 13:05:26 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
Scott Baker7a327592016-06-20 17:34:06 -070017---
18- hosts: 127.0.0.1
19 connection: local
20 vars:
21 appname: {{ appname }}
22 dependencies: {{ dependencies }}
23{% if component_configs %}
24 component_configs:
25{% for component_config in component_configs %}
26 - component: {{ component_config.component }}
27 config_params: {{ component_config.config_params }}
28{% endfor %}
29{% endif %}
30{% if rest_configs %}
Sapan Bhatiaf14cf232017-02-04 08:44:37 -080031 var_rest_configs:
Scott Baker7a327592016-06-20 17:34:06 -070032{% for rest_config in rest_configs %}
33 - endpoint: {{ rest_config.endpoint }}
34 body: "{{ '{{' }} lookup('file', '{{ files_dir }}/{{ rest_config.fn }}') {{ '}}' }}"
35{% endfor %}
36{% endif %}
Scott Baker7a327592016-06-20 17:34:06 -070037 rest_hostname: {{ rest_hostname }}
38 rest_port: {{ rest_port }}
39
40 tasks:
Andy Bavier4a503b12016-06-21 11:41:29 -040041{% if install_dependencies %}
42 # Couldn't figure out how to get uri module to accept JSON in a string
43 - name: Install ONOS apps by URL
44 command: curl -sS --user onos:rocks -X POST -HContent-Type:application/json -d '{{ '{{' }} item.body | to_json {{ '}}' }}' http://{{ rest_hostname }}:{{ rest_port }}/{{ '{{' }} item.endpoint {{ '}}' }}
45 with_items:
46 {% for install_dependency in install_dependencies %}
47 - endpoint: "onos/v1/applications"
48 body:
49 url: "{{ install_dependency }}"
50 activate: "true"
51 {% endfor %}
52{% endif %}
53
Scott Baker7a327592016-06-20 17:34:06 -070054{% if dependencies %}
55 - name: Add dependencies to ONOS
56 uri:
Andy Bavier4a503b12016-06-21 11:41:29 -040057 url: http://{{ rest_hostname }}:{{ rest_port }}/onos/v1/applications/{{ '{{' }} item {{ '}}' }}/active
Scott Baker7a327592016-06-20 17:34:06 -070058 method: POST
59 user: karaf
60 password: karaf
61 with_items:
62 {% for dependency in dependencies %}
63 - {{ dependency }}
64 {% endfor %}
65{% endif %}
66
67{% if rest_configs %}
68# Do this after services have been activated, or it will cause an exception.
69# vOLT will re-read its net config; vbng may not.
70 - name: Add ONOS configuration values
71 uri:
Andy Bavier4a503b12016-06-21 11:41:29 -040072 url: http://{{ rest_hostname }}:{{ rest_port }}/{{ '{{' }} item.endpoint {{ '}}' }} #http://localhost:8181/onos/v1/network/configuration/
Scott Baker7a327592016-06-20 17:34:06 -070073 body: "{{ '{{' }} item.body {{ '}}' }}"
Zack Williamsd60c7732016-06-27 13:15:21 -070074 body_format: json
Scott Baker7a327592016-06-20 17:34:06 -070075 method: POST
76 user: karaf
77 password: karaf
Sapan Bhatiaf14cf232017-02-04 08:44:37 -080078 with_items: "{{ '{{' }} var_rest_configs {{ '}}' }}"
Scott Baker7a327592016-06-20 17:34:06 -070079{% endif %}