From 0cbadab3495f0a63a2ab199e6ec8de3ced4a9dfd Mon Sep 17 00:00:00 2001 From: yohan <783b8c87@scimetis.net> Date: Sat, 14 Oct 2023 09:47:04 +0200 Subject: [PATCH] first commit --- ansible.cfg | 2 ++ collections/requirements.yml | 7 +++++++ down.sh | 13 ++++++++++++ down.yml | 39 ++++++++++++++++++++++++++++++++++++ script.sh | 5 +++++ 5 files changed, 66 insertions(+) create mode 100644 ansible.cfg create mode 100644 collections/requirements.yml create mode 100755 down.sh create mode 100755 down.yml create mode 100755 script.sh diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..14c8065 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +host_key_checking = False diff --git a/collections/requirements.yml b/collections/requirements.yml new file mode 100644 index 0000000..b201efe --- /dev/null +++ b/collections/requirements.yml @@ -0,0 +1,7 @@ +collections: + - name: openstack.cloud + version: 2.1.0 + source: https://galaxy.ansible.com + - name: community.docker + version: 3.4.8 + source: https://galaxy.ansible.com diff --git a/down.sh b/down.sh new file mode 100755 index 0000000..20c17c5 --- /dev/null +++ b/down.sh @@ -0,0 +1,13 @@ +#!/bin/bash +#Absolute path to this script +SCRIPT=$(readlink -f $0) +#Absolute path this script is in +SCRIPTPATH=$(dirname $SCRIPT) + +cd $SCRIPTPATH +USER=$(whoami) +/home/$USER/get_secrets.sh + +cd $SCRIPTPATH + +sudo docker run --net=host --rm -v ./id_rsa:/root/.ssh/id_rsa -v ~/repository/docker-duplicity-stack:/root/docker-duplicity-stack -v ./:/root/duplicity_playbooks -v ~/openrc.sh:/root/openrc.sh -i ansible /root/duplicity_playbooks/script.sh diff --git a/down.yml b/down.yml new file mode 100755 index 0000000..2b50cdd --- /dev/null +++ b/down.yml @@ -0,0 +1,39 @@ +--- +- name: Shutdown duplicity + hosts: localhost + gather_facts: false + tasks: + - name: Tear down existing services + community.docker.docker_compose: + project_src: /root/docker-duplicity-stack + docker_host: tcp://127.0.0.1:2375 + state: absent + + - name: unmount /mnt/cloud + ansible.posix.mount: + path: /mnt/cloud + state: unmounted + remote_user: centos + delegate_to: 172.17.0.1 + become: true + + - name: unmount /mnt/volumes/tmp_duplicity_workdir + ansible.posix.mount: + path: /mnt/volumes/tmp_duplicity_workdir + state: unmounted + remote_user: centos + delegate_to: 172.17.0.1 + become: true + + - name: Detach tmp_duplicity_workdir volume from instance + openstack.cloud.server_volume: + state: absent + server: ovh1.scimetis.net + volume: tmp_duplicity_workdir + register: output + failed_when: output is failed and output.msg != "No Volume found for tmp_duplicity_workdir" + + - name: remove tmp_duplicity_workdir volume + openstack.cloud.volume: + state: absent + name: tmp_duplicity_workdir diff --git a/script.sh b/script.sh new file mode 100755 index 0000000..a6682f9 --- /dev/null +++ b/script.sh @@ -0,0 +1,5 @@ +#!/bin/bash +cd /root/duplicity_playbooks +ansible-galaxy collection install -r collections/requirements.yml +source /root/openrc.sh +ansible-playbook down.yml