Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 1 | --- |
| 2 | - hosts: 127.0.0.1 |
| 3 | connection: local |
| 4 | vars: |
| 5 | appname: {{ appname }} |
| 6 | dependencies: {{ dependencies }} |
| 7 | {% if component_configs %} |
| 8 | component_configs: |
| 9 | {% for component_config in component_configs %} |
| 10 | - component: {{ component_config.component }} |
| 11 | config_params: {{ component_config.config_params }} |
| 12 | {% endfor %} |
| 13 | {% endif %} |
| 14 | {% if rest_configs %} |
| 15 | rest_configs: |
| 16 | {% for rest_config in rest_configs %} |
| 17 | - endpoint: {{ rest_config.endpoint }} |
| 18 | body: "{{ '{{' }} lookup('file', '{{ files_dir }}/{{ rest_config.fn }}') {{ '}}' }}" |
| 19 | {% endfor %} |
| 20 | {% endif %} |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 21 | rest_hostname: {{ rest_hostname }} |
| 22 | rest_port: {{ rest_port }} |
| 23 | |
| 24 | tasks: |
Andy Bavier | 4a503b1 | 2016-06-21 11:41:29 -0400 | [diff] [blame] | 25 | {% if install_dependencies %} |
| 26 | # Couldn't figure out how to get uri module to accept JSON in a string |
| 27 | - name: Install ONOS apps by URL |
| 28 | command: curl -sS --user onos:rocks -X POST -HContent-Type:application/json -d '{{ '{{' }} item.body | to_json {{ '}}' }}' http://{{ rest_hostname }}:{{ rest_port }}/{{ '{{' }} item.endpoint {{ '}}' }} |
| 29 | with_items: |
| 30 | {% for install_dependency in install_dependencies %} |
| 31 | - endpoint: "onos/v1/applications" |
| 32 | body: |
| 33 | url: "{{ install_dependency }}" |
| 34 | activate: "true" |
| 35 | {% endfor %} |
| 36 | {% endif %} |
| 37 | |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 38 | {% if dependencies %} |
| 39 | - name: Add dependencies to ONOS |
| 40 | uri: |
Andy Bavier | 4a503b1 | 2016-06-21 11:41:29 -0400 | [diff] [blame] | 41 | url: http://{{ rest_hostname }}:{{ rest_port }}/onos/v1/applications/{{ '{{' }} item {{ '}}' }}/active |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 42 | method: POST |
| 43 | user: karaf |
| 44 | password: karaf |
| 45 | with_items: |
| 46 | {% for dependency in dependencies %} |
| 47 | - {{ dependency }} |
| 48 | {% endfor %} |
| 49 | {% endif %} |
| 50 | |
| 51 | {% if rest_configs %} |
| 52 | # Do this after services have been activated, or it will cause an exception. |
| 53 | # vOLT will re-read its net config; vbng may not. |
| 54 | - name: Add ONOS configuration values |
| 55 | uri: |
Andy Bavier | 4a503b1 | 2016-06-21 11:41:29 -0400 | [diff] [blame] | 56 | url: http://{{ rest_hostname }}:{{ rest_port }}/{{ '{{' }} item.endpoint {{ '}}' }} #http://localhost:8181/onos/v1/network/configuration/ |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 57 | body: "{{ '{{' }} item.body {{ '}}' }}" |
Zack Williams | d60c773 | 2016-06-27 13:15:21 -0700 | [diff] [blame] | 58 | body_format: json |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 59 | method: POST |
| 60 | user: karaf |
| 61 | password: karaf |
| 62 | with_items: "rest_configs" |
| 63 | {% endif %} |