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