blob: 28f5e516e30e1f065adee6080b85c59e6e73c989 [file] [log] [blame]
Matteo Scandolof5e10332017-08-08 13:05:25 -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
Andy Bavier89a95422016-11-02 14:38:39 -040017---
18- hosts: 127.0.0.1
19 connection: local
20 # These variables are expanded by the Synchronizer framework
21 # and used to create the TOSCA recipe from a template
Andy Bavier89a95422016-11-02 14:38:39 -040022 tasks:
Andy Bavier89a95422016-11-02 14:38:39 -040023 - name: Lookup local name of remote site
24 uri:
25 url: "{{ endpoint }}/api/core/sites/"
26 method: GET
27 user: "{{ admin_user }}"
28 password: "{{ admin_password }}"
29 return_content: yes
30 force_basic_auth: yes
31 register: sites
32
33 - name: Save site name in local_site variable
34 set_fact:
Sapan Bhatiaa6ae7d62017-02-09 16:49:22 -080035 local_site: "{{ sites.json[0]['name'] }}"
Andy Bavier89a95422016-11-02 14:38:39 -040036
37 - name: Get list of images
38 uri:
39 url: "{{ endpoint }}/api/core/images/"
40 method: GET
41 user: "{{ admin_user }}"
42 password: "{{ admin_password }}"
43 return_content: yes
44 force_basic_auth: yes
45 register: images
46
47 - fail: msg="Image {{ image }} is not present at {{ endpoint }}"
48 when: not ((images.json | selectattr('name', 'equalto', image)) | list)
49
50 - name: Get list of networks
51 uri:
52 url: "{{ endpoint }}/api/core/networks/"
53 method: GET
54 user: "{{ admin_user }}"
55 password: "{{ admin_password }}"
56 return_content: yes
57 force_basic_auth: yes
58 register: networks
59
Sapan Bhatiaa6ae7d62017-02-09 16:49:22 -080060 - fail: msg="Network {{ item }} is not present at {{ endpoint }}"
Andy Bavier89a95422016-11-02 14:38:39 -040061 when: not ((networks.json | selectattr('name', 'equalto', item)) | list)
62 with_items:
63 - "management"
64 - "public"
65
66 - name: Ensure TOSCA directory exists
67 file:
68 path=/opt/xos/synchronizers/globalxos/tosca/slices/
69 state=directory
70
71 - name: Create TOSCA recipe from the template
72 template:
73 src=/opt/xos/synchronizers/globalxos/templates/slice.yaml.j2
74 dest=/opt/xos/synchronizers/globalxos/tosca/slices/{{ ansible_tag }}.yml
75
76 - name: Create slice "{{ slice }}"
77 uri:
78 url: "{{ endpoint }}/api/utility/tosca/run/"
79 method: POST
80 user: "{{ admin_user }}"
81 password: "{{ admin_password }}"
Sapan Bhatiaa6ae7d62017-02-09 16:49:22 -080082 body: { "recipe": "{{ lookup('file', '/opt/xos/synchronizers/globalxos/tosca/slices/{{ ansible_tag }}.yml') }}" }
Andy Bavier89a95422016-11-02 14:38:39 -040083 force_basic_auth: yes
84 body_format: json