Scott Baker | 9ae092c | 2015-10-19 21:20:24 -0700 | [diff] [blame] | 1 | --- |
| 2 | - hosts: {{ instance_name }} |
| 3 | gather_facts: False |
| 4 | connection: ssh |
Scott Baker | 8795e1a | 2015-12-14 21:16:46 -0800 | [diff] [blame] | 5 | user: {{ username }} |
Scott Baker | 9ae092c | 2015-10-19 21:20:24 -0700 | [diff] [blame] | 6 | sudo: yes |
| 7 | vars: |
| 8 | appname: {{ appname }} |
| 9 | dependencies: {{ dependencies }} |
Scott Baker | c6628bb | 2015-12-03 21:14:39 -0800 | [diff] [blame] | 10 | {% 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 Baker | 9ae092c | 2015-10-19 21:20:24 -0700 | [diff] [blame] | 17 | |
| 18 | tasks: |
| 19 | |
Scott Baker | 8795e1a | 2015-12-14 21:16:46 -0800 | [diff] [blame] | 20 | - 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 Baker | 9ae092c | 2015-10-19 21:20:24 -0700 | [diff] [blame] | 34 | - name: Config file directory |
Andy Bavier | 52faf2c | 2015-10-26 12:19:33 -0400 | [diff] [blame] | 35 | file: |
| 36 | path=/home/ubuntu/{{ appname }}/ |
| 37 | state=directory |
| 38 | |
Scott Baker | a587c44 | 2015-10-26 11:09:57 -0700 | [diff] [blame] | 39 | {% if config_fns %} |
Andy Bavier | 52faf2c | 2015-10-26 12:19:33 -0400 | [diff] [blame] | 40 | - 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 Baker | 9ae092c | 2015-10-19 21:20:24 -0700 | [diff] [blame] | 46 | - {{ config_fn }} |
Andy Bavier | 52faf2c | 2015-10-26 12:19:33 -0400 | [diff] [blame] | 47 | {% 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 Baker | 9ae092c | 2015-10-19 21:20:24 -0700 | [diff] [blame] | 58 | - {{ config_fn }} |
Andy Bavier | 52faf2c | 2015-10-26 12:19:33 -0400 | [diff] [blame] | 59 | {% endfor %} |
Scott Baker | a587c44 | 2015-10-26 11:09:57 -0700 | [diff] [blame] | 60 | {% endif %} |
Andy Bavier | 52faf2c | 2015-10-26 12:19:33 -0400 | [diff] [blame] | 61 | |
| 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 Baker | 8795e1a | 2015-12-14 21:16:46 -0800 | [diff] [blame] | 66 | {% if dependencies %} |
Andy Bavier | 52faf2c | 2015-10-26 12:19:33 -0400 | [diff] [blame] | 67 | - name: Add dependencies to ONOS |
| 68 | uri: |
Scott Baker | 8795e1a | 2015-12-14 21:16:46 -0800 | [diff] [blame] | 69 | url: http://{{ '{{' }} onosaddr.stdout {{ '}}' }}:8181/onos/v1/applications/{{ '{{' }} item {{ '}}' }}/active |
Andy Bavier | 52faf2c | 2015-10-26 12:19:33 -0400 | [diff] [blame] | 70 | method: POST |
| 71 | user: karaf |
| 72 | password: karaf |
| 73 | with_items: |
| 74 | {% for dependency in dependencies %} |
Scott Baker | 9ae092c | 2015-10-19 21:20:24 -0700 | [diff] [blame] | 75 | - {{ dependency }} |
Andy Bavier | 52faf2c | 2015-10-26 12:19:33 -0400 | [diff] [blame] | 76 | {% endfor %} |
Scott Baker | 8795e1a | 2015-12-14 21:16:46 -0800 | [diff] [blame] | 77 | {% endif %} |
Scott Baker | 69b74da | 2015-12-07 22:21:33 -0800 | [diff] [blame] | 78 | |
| 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 Baker | 8795e1a | 2015-12-14 21:16:46 -0800 | [diff] [blame] | 84 | url: http://{{ '{{' }} onosaddr.stdout {{ '}}' }}:8181/{{ '{{' }} item.endpoint {{ '}}' }} #http://localhost:8181/onos/v1/network/configuration/ |
Scott Baker | 69b74da | 2015-12-07 22:21:33 -0800 | [diff] [blame] | 85 | body: "{{ '{{' }} item.body {{ '}}' }}" |
| 86 | body_format: raw |
| 87 | method: POST |
| 88 | user: karaf |
| 89 | password: karaf |
| 90 | with_items: "rest_configs" |
| 91 | {% endif %} |