blob: 15c87b6a5981d4733079cb6eb4a1ee9144754327 [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:
23
24 - name: Lookup local name of remote site
25 uri:
26 url: "{{ endpoint }}/api/core/sites/"
27 method: GET
28 user: "{{ admin_user }}"
29 password: "{{ admin_password }}"
30 return_content: yes
31 force_basic_auth: yes
32 register: sites
33
34 - name: Save site name in local_site variable
35 set_fact:
Sapan Bhatiaa6ae7d62017-02-09 16:49:22 -080036 local_site: "{{ sites.json[0]['name'] }}"
Andy Bavier89a95422016-11-02 14:38:39 -040037
38 - name: Ensure TOSCA directory exists
39 file:
40 path=/opt/xos/synchronizers/globalxos/tosca/users/
41 state=directory
42
43 - name: Create TOSCA recipe from the template
44 template:
45 src=/opt/xos/synchronizers/globalxos/templates/user.yaml.j2
46 dest=/opt/xos/synchronizers/globalxos/tosca/users/{{ ansible_tag }}.yml
47
48 - name: Create user account for "{{ name }}"
49 uri:
50 url: "{{ endpoint }}/api/utility/tosca/run/"
51 method: POST
52 user: "{{ admin_user }}"
53 password: "{{ admin_password }}"
Sapan Bhatiaa6ae7d62017-02-09 16:49:22 -080054 body: { "recipe": "{{ lookup('file', '/opt/xos/synchronizers/globalxos/tosca/users/{{ ansible_tag }}.yml') }}" }
Andy Bavier89a95422016-11-02 14:38:39 -040055 force_basic_auth: yes
56 body_format: json