blob: 03a7b88c7f6042a3bdd998bc779a1492543112fa [file] [log] [blame]
Andy Bavier89a95422016-11-02 14:38:39 -04001---
2- hosts: 127.0.0.1
3 connection: local
4 # These variables are expanded by the Synchronizer framework
5 # and used to create the TOSCA recipe from a template
Andy Bavier89a95422016-11-02 14:38:39 -04006 tasks:
Andy Bavier89a95422016-11-02 14:38:39 -04007 - name: Lookup local name of remote site
8 uri:
9 url: "{{ endpoint }}/api/core/sites/"
10 method: GET
11 user: "{{ admin_user }}"
12 password: "{{ admin_password }}"
13 return_content: yes
14 force_basic_auth: yes
15 register: sites
16
17 - name: Save site name in local_site variable
18 set_fact:
Sapan Bhatiaa6ae7d62017-02-09 16:49:22 -080019 local_site: "{{ sites.json[0]['name'] }}"
Andy Bavier89a95422016-11-02 14:38:39 -040020
21 - name: Get list of images
22 uri:
23 url: "{{ endpoint }}/api/core/images/"
24 method: GET
25 user: "{{ admin_user }}"
26 password: "{{ admin_password }}"
27 return_content: yes
28 force_basic_auth: yes
29 register: images
30
31 - fail: msg="Image {{ image }} is not present at {{ endpoint }}"
32 when: not ((images.json | selectattr('name', 'equalto', image)) | list)
33
34 - name: Get list of networks
35 uri:
36 url: "{{ endpoint }}/api/core/networks/"
37 method: GET
38 user: "{{ admin_user }}"
39 password: "{{ admin_password }}"
40 return_content: yes
41 force_basic_auth: yes
42 register: networks
43
Sapan Bhatiaa6ae7d62017-02-09 16:49:22 -080044 - fail: msg="Network {{ item }} is not present at {{ endpoint }}"
Andy Bavier89a95422016-11-02 14:38:39 -040045 when: not ((networks.json | selectattr('name', 'equalto', item)) | list)
46 with_items:
47 - "management"
48 - "public"
49
50 - name: Ensure TOSCA directory exists
51 file:
52 path=/opt/xos/synchronizers/globalxos/tosca/slices/
53 state=directory
54
55 - name: Create TOSCA recipe from the template
56 template:
57 src=/opt/xos/synchronizers/globalxos/templates/slice.yaml.j2
58 dest=/opt/xos/synchronizers/globalxos/tosca/slices/{{ ansible_tag }}.yml
59
60 - name: Create slice "{{ slice }}"
61 uri:
62 url: "{{ endpoint }}/api/utility/tosca/run/"
63 method: POST
64 user: "{{ admin_user }}"
65 password: "{{ admin_password }}"
Sapan Bhatiaa6ae7d62017-02-09 16:49:22 -080066 body: { "recipe": "{{ lookup('file', '/opt/xos/synchronizers/globalxos/tosca/slices/{{ ansible_tag }}.yml') }}" }
Andy Bavier89a95422016-11-02 14:38:39 -040067 force_basic_auth: yes
68 body_format: json