blob: 496fad01db850abecec077b79d1f7e5ee376ae37 [file] [log] [blame]
Scott Baker9ae092c2015-10-19 21:20:24 -07001---
2- hosts: {{ instance_name }}
3 gather_facts: False
4 connection: ssh
Scott Baker8795e1a2015-12-14 21:16:46 -08005 user: {{ username }}
Scott Baker9ae092c2015-10-19 21:20:24 -07006 sudo: yes
7 vars:
8 appname: {{ appname }}
9 dependencies: {{ dependencies }}
Scott Bakerc6628bb2015-12-03 21:14:39 -080010{% if rest_configs %}
11 rest_configs:
12{% for rest_config in rest_configs %}
13 - endpoint: {{ rest_config.endpoint }}
14 body: "{{ '{{' }} lookup('file', '{{ files_dir }}/{{ rest_config.fn }}') {{ '}}' }}"
15{% endfor %}
16{% endif %}
Scott Baker9ae092c2015-10-19 21:20:24 -070017
18 tasks:
19
Scott Baker8795e1a2015-12-14 21:16:46 -080020 - name: Get Docker IP
21 script: /opt/xos/observers/onos/scripts/dockerip.sh {{ ONOS_container }}
22 register: onosaddr
23
24 - name: Wait for ONOS to come up
25 wait_for:
26 host={{ '{{' }} onosaddr.stdout {{ '}}' }}
27 port={{ '{{' }} item {{ '}}' }}
28 state=present
29 with_items:
30 - 8101
31 - 8181
32 - 9876
33
Scott Baker9ae092c2015-10-19 21:20:24 -070034 - name: Config file directory
Andy Bavier52faf2c2015-10-26 12:19:33 -040035 file:
36 path=/home/ubuntu/{{ appname }}/
37 state=directory
38
Scott Bakera587c442015-10-26 11:09:57 -070039{% if config_fns %}
Andy Bavier52faf2c2015-10-26 12:19:33 -040040 - name: Copy over configuration files
41 copy:
42 src={{ files_dir }}/{{ '{{' }} item {{ '}}' }}
43 dest=/home/ubuntu/{{ appname }}/{{ '{{' }} item {{ '}}' }}
44 with_items:
45 {% for config_fn in config_fns %}
Scott Baker9ae092c2015-10-19 21:20:24 -070046 - {{ config_fn }}
Andy Bavier52faf2c2015-10-26 12:19:33 -040047 {% endfor %}
48
49 - name: Make sure config directory exists
50 shell: docker exec {{ ONOS_container }} mkdir -p /root/onos/config/
51 sudo: yes
52
53 - name: Copy config files into container
54 shell: docker cp {{ appname }}/{{ '{{' }} item {{ '}}' }} {{ ONOS_container }}:/root/onos/config/
55 sudo: yes
56 with_items:
57 {% for config_fn in config_fns %}
Scott Baker9ae092c2015-10-19 21:20:24 -070058 - {{ config_fn }}
Andy Bavier52faf2c2015-10-26 12:19:33 -040059 {% endfor %}
Scott Bakera587c442015-10-26 11:09:57 -070060{% endif %}
Andy Bavier52faf2c2015-10-26 12:19:33 -040061
62 # Don't know how to check for this condition, just wait
63 - name: Wait for ONOS to install the apps
64 wait_for: timeout=15
65
Scott Baker8795e1a2015-12-14 21:16:46 -080066{% if dependencies %}
Andy Bavier52faf2c2015-10-26 12:19:33 -040067 - name: Add dependencies to ONOS
68 uri:
Scott Baker8795e1a2015-12-14 21:16:46 -080069 url: http://{{ '{{' }} onosaddr.stdout {{ '}}' }}:8181/onos/v1/applications/{{ '{{' }} item {{ '}}' }}/active
Andy Bavier52faf2c2015-10-26 12:19:33 -040070 method: POST
71 user: karaf
72 password: karaf
73 with_items:
74 {% for dependency in dependencies %}
Scott Baker9ae092c2015-10-19 21:20:24 -070075 - {{ dependency }}
Andy Bavier52faf2c2015-10-26 12:19:33 -040076 {% endfor %}
Scott Baker8795e1a2015-12-14 21:16:46 -080077{% endif %}
Scott Baker69b74da2015-12-07 22:21:33 -080078
79{% if rest_configs %}
80# Do this after services have been activated, or it will cause an exception.
81# vOLT will re-read its net config; vbng may not.
82 - name: Add ONOS configuration values
83 uri:
Scott Baker8795e1a2015-12-14 21:16:46 -080084 url: http://{{ '{{' }} onosaddr.stdout {{ '}}' }}:8181/{{ '{{' }} item.endpoint {{ '}}' }} #http://localhost:8181/onos/v1/network/configuration/
Scott Baker69b74da2015-12-07 22:21:33 -080085 body: "{{ '{{' }} item.body {{ '}}' }}"
86 body_format: raw
87 method: POST
88 user: karaf
89 password: karaf
90 with_items: "rest_configs"
91{% endif %}