Initial prototype of synchronizer
Change-Id: I45de04debd89e7007d7985728d51aa5d03178675
diff --git a/xos/synchronizer/steps/sync_controller_users.yaml b/xos/synchronizer/steps/sync_controller_users.yaml
new file mode 100644
index 0000000..2d4cc00
--- /dev/null
+++ b/xos/synchronizer/steps/sync_controller_users.yaml
@@ -0,0 +1,53 @@
+---
+- hosts: 127.0.0.1
+ connection: local
+ # These variables are expanded by the Synchronizer framework
+ # and used to create the TOSCA recipe from a template
+ vars:
+ name: "{{ name }}"
+ email: "{{ email }}"
+ password: "{{ password }}"
+ firstname: "{{ firstname }}"
+ lastname: "{{ lastname }}"
+ phone: "{{ phone }}"
+ user_url: "{{ user_url }}"
+ public_key: "{{ public_key }}"
+ is_active: "{{ is_active }}"
+ is_admin: "{{ is_admin }}"
+ is_readonly: "{{ is_readonly }}"
+ is_appuser: "{{ is_appuser }}"
+ tasks:
+
+ - name: Lookup local name of remote site
+ uri:
+ url: "{{ endpoint }}/api/core/sites/"
+ method: GET
+ user: "{{ admin_user }}"
+ password: "{{ admin_password }}"
+ return_content: yes
+ force_basic_auth: yes
+ register: sites
+
+ - name: Save site name in local_site variable
+ set_fact:
+ local_site: "{{ '{{' }} sites.json[0]['name'] {{ '}}' }}"
+
+ - name: Ensure TOSCA directory exists
+ file:
+ path=/opt/xos/synchronizers/globalxos/tosca/users/
+ state=directory
+
+ - name: Create TOSCA recipe from the template
+ template:
+ src=/opt/xos/synchronizers/globalxos/templates/user.yaml.j2
+ dest=/opt/xos/synchronizers/globalxos/tosca/users/{{ ansible_tag }}.yml
+
+ - name: Create user account for "{{ name }}"
+ uri:
+ url: "{{ endpoint }}/api/utility/tosca/run/"
+ method: POST
+ user: "{{ admin_user }}"
+ password: "{{ admin_password }}"
+ body: { "recipe": "{{ '{{' }} lookup('file', '/opt/xos/synchronizers/globalxos/tosca/users/{{ ansible_tag }}.yml') {{ '}}' }}" }
+ force_basic_auth: yes
+ body_format: json