Matteo Scandolo | f5e1033 | 2017-08-08 13:05:25 -0700 | [diff] [blame] | 1 | |
| 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 Bavier | 89a9542 | 2016-11-02 14:38:39 -0400 | [diff] [blame] | 17 | --- |
| 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 Bavier | 89a9542 | 2016-11-02 14:38:39 -0400 | [diff] [blame] | 22 | 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 Bhatia | a6ae7d6 | 2017-02-09 16:49:22 -0800 | [diff] [blame] | 36 | local_site: "{{ sites.json[0]['name'] }}" |
Andy Bavier | 89a9542 | 2016-11-02 14:38:39 -0400 | [diff] [blame] | 37 | |
| 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 Bhatia | a6ae7d6 | 2017-02-09 16:49:22 -0800 | [diff] [blame] | 54 | body: { "recipe": "{{ lookup('file', '/opt/xos/synchronizers/globalxos/tosca/users/{{ ansible_tag }}.yml') }}" } |
Andy Bavier | 89a9542 | 2016-11-02 14:38:39 -0400 | [diff] [blame] | 55 | force_basic_auth: yes |
| 56 | body_format: json |