ansible-taler-exchange

Ansible playbook to deploy a production Taler Exchange
Log | Files | Refs | Submodules | README | LICENSE

commit 77ed462ade273cff078c3e96750c73aac177dd5a
parent 999a0d73c08417f3cc5fbc56d76f5219046914f1
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu, 26 Dec 2024 12:35:34 +0100

first draft for import/export playbooks

Diffstat:
MREADME | 11++++++++++-
Aexport.sh | 6++++++
Aimport.sh | 5+++++
Aplaybooks/libeufin-export.yml | 5+++++
Aplaybooks/libeufin-import.yml | 5+++++
Aroles/libeufin-transaction-export/tasks/main.yml | 29+++++++++++++++++++++++++++++
Aroles/libeufin-transaction-import/tasks/main.yml | 29+++++++++++++++++++++++++++++
7 files changed, 89 insertions(+), 1 deletion(-)

diff --git a/README b/README @@ -10,7 +10,7 @@ Depending on your local installation, you may also need: $ ansible-galaxy collection install community.postgresql -## Running the Playbook +## Running the main Playbook To run the main playbook (playbooks/setup.yml): @@ -30,6 +30,15 @@ you can pass an inventory file. See `inventories/`, and update accordingly. For production, replace the "test-secrets.yml" file with the actual secrets for your deployment. + +## Running the import/export Playbooks (TOPS-only) + +``` +$ ./export.sh +$ ./import.sh $FILE.xml +``` + + ## Testing Locally With podman and ansible installed locally one can run `./test.sh`. diff --git a/export.sh b/export.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -eu + +mkdir -p exports +ansible-playbook --verbose --inventory inventories/tops --user root playbooks/libeufin-export.yml diff --git a/import.sh b/import.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -eu +mkdir -p exports +ansible-playbook --extra-vars "SOURCE=$1" --verbose --inventory inventories/tops --user root playbooks/libeufin-import.yml diff --git a/playbooks/libeufin-export.yml b/playbooks/libeufin-export.yml @@ -0,0 +1,5 @@ +--- +- name: Export pending outgoing transactions from libeufin-nexus + hosts: all + roles: + - libeufin-transaction-export diff --git a/playbooks/libeufin-import.yml b/playbooks/libeufin-import.yml @@ -0,0 +1,5 @@ +--- +- name: Import pending outgoing transactions from libeufin-nexus + hosts: all + roles: + - libeufin-transaction-import diff --git a/roles/libeufin-transaction-export/tasks/main.yml b/roles/libeufin-transaction-export/tasks/main.yml @@ -0,0 +1,29 @@ +--- +- name: Get current date + ansible.builtin.shell: + cmd: "date +%F" + register: today + +- name: Create temporary file as destination for the export + ansible.builtin.template: + path: /tmp + prefix: "libeufin-transaction-export-{{ today.stdout }}" + suffix: .zip + register: exportfile + +- name: Export from libeufin-nexus + ansible.builtin.shell: + cmd: "libeufin-nexus manual export {{ exportfile }}" + become: yes + become_user: libeufin-nexus + +- name: Fetch file to local system + fetch: + src: "{{ exportfile }}" + dest: "exports/{{ today.stdout }}" + +#- name: Remove the temporary file on the server +# ansible.builtin.file: +# path: "{{ exportfile.path }}" +# state: absent +# when: exportfile.path is defined diff --git a/roles/libeufin-transaction-import/tasks/main.yml b/roles/libeufin-transaction-import/tasks/main.yml @@ -0,0 +1,29 @@ +--- +- name: Get current date + ansible.builtin.shell: + cmd: "date +%F" + register: today + +- name: Create temporary file as destination for the import + ansible.builtin.template: + path: /tmp + prefix: "libeufin-transaction-import-{{ today.stdout }}" + suffix: .xml + register: importfile + +- name: Push file to local system + copy: + src: "{{ SOURCE }}" + dest: "{{ importfile }}" + +- name: Import into libeufin-nexus + ansible.builtin.shell: + cmd: "libeufin-nexus manual import {{ importfile }}" + become: yes + become_user: libeufin-nexus + +#- name: Remove the temporary file on the server +# ansible.builtin.file: +# path: "{{ importfile.path }}" +# state: absent +# when: importfile.path is defined