blob: e732814aa256b1ecc98811e9b046a5f8cf7d8033 [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: {{ instance_name }}
19 gather_facts: False
20 connection: ssh
21 user: {{ username }}
Sapan Bhatia38ef8b82017-02-07 11:32:56 -080022 become: yes
Scott Baker7a327592016-06-20 17:34:06 -070023 vars:
24 appname: {{ appname }}
25 dependencies: {{ dependencies }}
26{% if component_configs %}
27 component_configs:
28{% for component_config in component_configs %}
29 - component: {{ component_config.component }}
30 config_params: {{ component_config.config_params }}
31{% endfor %}
32{% endif %}
33{% if rest_configs %}
Sapan Bhatiaf14cf232017-02-04 08:44:37 -080034 var_rest_configs:
Scott Baker7a327592016-06-20 17:34:06 -070035{% for rest_config in rest_configs %}
36 - endpoint: {{ rest_config.endpoint }}
37 body: "{{ '{{' }} lookup('file', '{{ files_dir }}/{{ rest_config.fn }}') {{ '}}' }}"
38{% endfor %}
39{% endif %}
40{% if early_rest_configs %}
Sapan Bhatiaf14cf232017-02-04 08:44:37 -080041 var_early_rest_configs:
Scott Baker7a327592016-06-20 17:34:06 -070042{% for early_rest_config in early_rest_configs %}
43 - endpoint: {{ early_rest_config.endpoint }}
44 body: "{{ '{{' }} lookup('file', '{{ files_dir }}/{{ early_rest_config.fn }}') {{ '}}' }}"
45{% endfor %}
46{% endif %}
47
48 tasks:
49
50 - name: Get Docker IP
51 script: /opt/xos/synchronizers/onos/scripts/dockerip.sh {{ ONOS_container }}
52 register: onosaddr
53
54 - name: Wait for ONOS to come up
55 wait_for:
56 host={{ '{{' }} onosaddr.stdout {{ '}}' }}
57 port={{ '{{' }} item {{ '}}' }}
58 state=present
59 with_items:
60 - 8101
61 - 8181
62 - 9876
63
64 - name: Config file directory
65 file:
66 path=/home/ubuntu/{{ appname }}/
67 state=directory
68
69{% if node_key_fn %}
70 - name: Copy over key
71 copy:
72 src={{ files_dir }}/{{ node_key_fn }}
73 dest=/home/ubuntu/node_key
74
75 - name: Copy node key into container
76 shell: docker cp /home/ubuntu/node_key {{ ONOS_container }}:/root/node_key
77{% endif %}
78
79{% if config_fns %}
80 - name: Copy over configuration files
81 copy:
82 src={{ files_dir }}/{{ '{{' }} item {{ '}}' }}
83 dest=/home/ubuntu/{{ appname }}/{{ '{{' }} item {{ '}}' }}
84 with_items:
85 {% for config_fn in config_fns %}
86 - {{ config_fn }}
87 {% endfor %}
88
89 - name: Make sure config directory exists
90 shell: docker exec {{ ONOS_container }} mkdir -p /root/onos/config/
91 sudo: yes
92
93 - name: Copy config files into container
94 shell: docker cp {{ appname }}/{{ '{{' }} item {{ '}}' }} {{ ONOS_container }}:/root/onos/config/
95 sudo: yes
96 with_items:
97 {% for config_fn in config_fns %}
98 - {{ config_fn }}
99 {% endfor %}
100{% endif %}
101
102 # Don't know how to check for this condition, just wait
103 - name: Wait for ONOS to install the apps
104 wait_for: timeout=15
105
106{% if early_rest_configs %}
107 - name: Add ONOS early configuration values
108 uri:
109 url: http://{{ '{{' }} onosaddr.stdout {{ '}}' }}:8181/{{ '{{' }} item.endpoint {{ '}}' }}
110 body: "{{ '{{' }} item.body {{ '}}' }}"
Zack Williamsd60c7732016-06-27 13:15:21 -0700111 body_format: json
Scott Baker7a327592016-06-20 17:34:06 -0700112 method: POST
113 user: karaf
114 password: karaf
Sapan Bhatiaf14cf232017-02-04 08:44:37 -0800115 with_items: "var_early_rest_configs"
Scott Baker7a327592016-06-20 17:34:06 -0700116
117 # Don't know how to check for this condition, just wait
118 - name: Wait for ONOS to restart
119 wait_for: timeout=15
120{% endif %}
121
122{% if install_dependencies %}
123 - name: Install app file directory
124 file:
125 path=/home/ubuntu/{{ appname }}/apps/
126 state=directory
127
128 - name: Copy over app install files to ONOS host
129 copy:
130 src=/opt/xos/synchronizers/onos/{{ '{{' }} item {{ '}}' }}
131 dest=/home/ubuntu/{{ appname }}/apps/{{ '{{' }} item {{ '}}' }}
132 with_items:
133 {% for install_app in install_dependencies %}
134 - {{ install_app }}
135 {% endfor %}
136
137 - name: POST onos-app install command
138 command: >
139 curl -XPOST -HContent-Type:application/octet-stream -u karaf:karaf --data-binary @/home/ubuntu/{{ appname }}/apps/{{ '{{' }} item {{ '}}' }} http://{{ '{{' }} onosaddr.stdout {{ '}}' }}:8181/onos/v1/applications
140 with_items:
141 {% for dependency in install_dependencies %}
142 - {{ dependency }}
143 {% endfor %}
144{% endif %}
145
146{% if dependencies %}
147 - name: Add dependencies to ONOS
148 uri:
149 url: http://{{ '{{' }} onosaddr.stdout {{ '}}' }}:8181/onos/v1/applications/{{ '{{' }} item {{ '}}' }}/active
150 method: POST
151 user: karaf
152 password: karaf
153 with_items:
154 {% for dependency in dependencies %}
155 - {{ dependency }}
156 {% endfor %}
157{% endif %}
158
159{% if component_configs %}
160 - name: Add ONOS component configuration values
161 command: >
162 curl -XPOST -HContent-Type:application/json -u karaf:karaf -d {{ '{{' }} item.config_params | to_json {{ '}}' }} http://{{ '{{' }} onosaddr.stdout {{ '}}' }}:8181/onos/v1/configuration/{{
163 '{{' }} item.component {{ '}}' }}
164 with_items: "component_configs"
165
166# uri:
167# url: http://{{ '{{' }} onosaddr.stdout {{ '}}' }}:8181/onos/v1/configuration/{{ '{{' }} item.component {{ '}}' }} #http://localhost:8181/onos/v1/configuration/
168# body: "{{ '{{' }} item.config_params | to_json {{ '}}' }}"
169# body_format: json
170# method: POST
171# user: karaf
172# password: karaf
173# with_items: "component_configs"
174{% endif %}
175
176{% if rest_configs %}
177# Do this after services have been activated, or it will cause an exception.
178# vOLT will re-read its net config; vbng may not.
179 - name: Add ONOS configuration values
180 uri:
181 url: http://{{ '{{' }} onosaddr.stdout {{ '}}' }}:8181/{{ '{{' }} item.endpoint {{ '}}' }} #http://localhost:8181/onos/v1/network/configuration/
182 body: "{{ '{{' }} item.body {{ '}}' }}"
Zack Williamsd60c7732016-06-27 13:15:21 -0700183 body_format: json
Scott Baker7a327592016-06-20 17:34:06 -0700184 method: POST
185 user: karaf
186 password: karaf
Sapan Bhatiaf14cf232017-02-04 08:44:37 -0800187 with_items: "var_rest_configs"
Scott Baker7a327592016-06-20 17:34:06 -0700188{% endif %}