53 lines
1.6 KiB
YAML
53 lines
1.6 KiB
YAML
---
|
|
- name: Gather Information about Database
|
|
hosts: appwrite:&dev
|
|
gather_facts: false
|
|
module_defaults:
|
|
ansible.builtin.uri:
|
|
body_format: json
|
|
headers:
|
|
X-Appwrite-Response-Format: '{{ appwrite_response_format }}'
|
|
X-Appwrite-Project: '{{ appwrite_project }}'
|
|
X-Appwrite-Key: '{{ appwrite_api_key }}'
|
|
return_content: true
|
|
tasks:
|
|
- name: Get Users
|
|
ansible.builtin.uri:
|
|
url: "{{ appwrite_api_uri }}/users"
|
|
method: GET
|
|
register: appwrite_api_result
|
|
delegate_to: localhost
|
|
|
|
- name: Display response
|
|
ansible.builtin.debug:
|
|
var: appwrite_api_result
|
|
|
|
- name: Get database info
|
|
ansible.builtin.uri:
|
|
url: "{{ appwrite_api_uri }}/databases/{{ bab_database.id }}"
|
|
method: GET
|
|
register: appwrite_api_result
|
|
delegate_to: localhost
|
|
|
|
- name: Get collection info
|
|
ansible.builtin.uri:
|
|
url: "{{ appwrite_api_uri }}/databases/{{ bab_database.id }}/collections"
|
|
method: GET
|
|
register: appwrite_collections
|
|
delegate_to: localhost
|
|
|
|
- name: Get documents from each table
|
|
ansible.builtin.uri:
|
|
url: "{{ appwrite_api_uri }}/databases/{{ bab_database.id }}/collections/{{ item['$id'] }}/documents"
|
|
method: GET
|
|
loop: "{{ appwrite_collections.json.collections }}"
|
|
delegate_to: localhost
|
|
register: document_results
|
|
|
|
- name: Save Data
|
|
ansible.builtin.copy:
|
|
dest: 'files/database/{{ item.item.name }}.json'
|
|
content: '{{ item.json }}'
|
|
loop: "{{ document_results.results }}"
|
|
delegate_to: localhost
|