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 |
| 6 | vars: |
| 7 | name: "{{ name }}" |
| 8 | email: "{{ email }}" |
| 9 | password: "{{ password }}" |
| 10 | firstname: "{{ firstname }}" |
| 11 | lastname: "{{ lastname }}" |
| 12 | phone: "{{ phone }}" |
| 13 | user_url: "{{ user_url }}" |
| 14 | public_key: "{{ public_key }}" |
| 15 | is_active: "{{ is_active }}" |
| 16 | is_admin: "{{ is_admin }}" |
| 17 | is_readonly: "{{ is_readonly }}" |
| 18 | is_appuser: "{{ is_appuser }}" |
| 19 | tasks: |
| 20 | |
| 21 | - name: Lookup local name of remote site |
| 22 | uri: |
| 23 | url: "{{ endpoint }}/api/core/sites/" |
| 24 | method: GET |
| 25 | user: "{{ admin_user }}" |
| 26 | password: "{{ admin_password }}" |
| 27 | return_content: yes |
| 28 | force_basic_auth: yes |
| 29 | register: sites |
| 30 | |
| 31 | - name: Save site name in local_site variable |
| 32 | set_fact: |
| 33 | local_site: "{{ '{{' }} sites.json[0]['name'] {{ '}}' }}" |
| 34 | |
| 35 | - name: Ensure TOSCA directory exists |
| 36 | file: |
| 37 | path=/opt/xos/synchronizers/globalxos/tosca/users/ |
| 38 | state=directory |
| 39 | |
| 40 | - name: Create TOSCA recipe from the template |
| 41 | template: |
| 42 | src=/opt/xos/synchronizers/globalxos/templates/user.yaml.j2 |
| 43 | dest=/opt/xos/synchronizers/globalxos/tosca/users/{{ ansible_tag }}.yml |
| 44 | |
| 45 | - name: Create user account for "{{ name }}" |
| 46 | uri: |
| 47 | url: "{{ endpoint }}/api/utility/tosca/run/" |
| 48 | method: POST |
| 49 | user: "{{ admin_user }}" |
| 50 | password: "{{ admin_password }}" |
| 51 | body: { "recipe": "{{ '{{' }} lookup('file', '/opt/xos/synchronizers/globalxos/tosca/users/{{ ansible_tag }}.yml') {{ '}}' }}" } |
| 52 | force_basic_auth: yes |
| 53 | body_format: json |