Andy Bavier | 89a9542 | 2016-11-02 14:38:39 -0400 | [diff] [blame] | 1 | --- |
| 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 Bavier | 89a9542 | 2016-11-02 14:38:39 -0400 | [diff] [blame] | 6 | tasks: |
| 7 | |
| 8 | - name: Lookup local name of remote site |
| 9 | uri: |
| 10 | url: "{{ endpoint }}/api/core/sites/" |
| 11 | method: GET |
| 12 | user: "{{ admin_user }}" |
| 13 | password: "{{ admin_password }}" |
| 14 | return_content: yes |
| 15 | force_basic_auth: yes |
| 16 | register: sites |
| 17 | |
| 18 | - name: Save site name in local_site variable |
| 19 | set_fact: |
Sapan Bhatia | a6ae7d6 | 2017-02-09 16:49:22 -0800 | [diff] [blame] | 20 | local_site: "{{ sites.json[0]['name'] }}" |
Andy Bavier | 89a9542 | 2016-11-02 14:38:39 -0400 | [diff] [blame] | 21 | |
| 22 | - name: Ensure TOSCA directory exists |
| 23 | file: |
| 24 | path=/opt/xos/synchronizers/globalxos/tosca/users/ |
| 25 | state=directory |
| 26 | |
| 27 | - name: Create TOSCA recipe from the template |
| 28 | template: |
| 29 | src=/opt/xos/synchronizers/globalxos/templates/user.yaml.j2 |
| 30 | dest=/opt/xos/synchronizers/globalxos/tosca/users/{{ ansible_tag }}.yml |
| 31 | |
| 32 | - name: Create user account for "{{ name }}" |
| 33 | uri: |
| 34 | url: "{{ endpoint }}/api/utility/tosca/run/" |
| 35 | method: POST |
| 36 | user: "{{ admin_user }}" |
| 37 | password: "{{ admin_password }}" |
Sapan Bhatia | a6ae7d6 | 2017-02-09 16:49:22 -0800 | [diff] [blame] | 38 | 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] | 39 | force_basic_auth: yes |
| 40 | body_format: json |