From 26632f88d7d8e76e90f22db8b5f829e5973b08c2 Mon Sep 17 00:00:00 2001 From: Adw8 Date: Tue, 22 Oct 2024 17:29:52 +0530 Subject: [PATCH] Add steps to clean up service provider setup --- hosts.example.ini | 2 +- service-provider-setup/README.md | 87 +++++++++++++++++++++++++++- service-provider-setup/setup-k8s.yml | 1 + user-setup/README.md | 2 +- 4 files changed, 89 insertions(+), 3 deletions(-) diff --git a/hosts.example.ini b/hosts.example.ini index 05fd65c..a5aa882 100644 --- a/hosts.example.ini +++ b/hosts.example.ini @@ -1,2 +1,2 @@ [deployment_host] - ansible_host= ansible_user= ansible_ssh_common_args='-o ForwardAgent=yes' \ No newline at end of file + ansible_host= ansible_user= ansible_ssh_common_args='-o ForwardAgent=yes' diff --git a/service-provider-setup/README.md b/service-provider-setup/README.md index 4ba9d89..a3071d1 100644 --- a/service-provider-setup/README.md +++ b/service-provider-setup/README.md @@ -65,7 +65,13 @@ auction_bid_amount: "100000" # bid amount for deployment auctions in alnt, eg: 500000 ``` -- Update the [`hosts.ini`](./hosts.ini) file: +- Create a new `hosts.ini` file: + + ```bash + cp ../hosts.example.ini hosts.ini + ``` + +- Edit the [`hosts.ini`](./hosts.ini) file: ```ini [deployment_host] @@ -112,3 +118,82 @@ After the playbook finishes executing, the following services will be deployed ( - laconic console: - webapp deployer API: - webapp deployer UI: + +## Cleanup + +Follow the steps given below to stop the webapp-deployer, container-registry, fixturenet-laconicd and laconic-console-deployment, undeploy k8s, remove GPG keys and DNS records +- Stop deployments + + ``` + $ laconic-so deployment --dir webapp-ui stop + $ laconic-so deployment --dir webapp-deployer + $ laconic-so deployment --dir container-registry stop + $ laconic-so deployment --dir laconic-console-deployment stop --delete-volumes + $ laconic-so deployment --dir fixturenet-laconicd-deployment stop --delete-volumes + ``` + +- Remove deployment directories + ``` + sudo rm -rf webapp-ui + sudo rm -rf webapp-deployer + sudo rm -rf container-registry + sudo rm -rf laconic-console-deployment + sudo rm -rf fixturenet-laconicd-deployment + ``` + +- Remove spec files + + ``` + rm webapp-deployer.spec + rm container-registry.spec + rm laconic-console-spec.yml + rm fixturenet-laconicd-spec.yml + ``` + +- Undeploy the k8s + + ``` + $ cd service-provider-template + $ export VAULT_KEY= + $ bash .vault/vault-rekey.sh + $ ansible-playbook -i hosts site.yml --tags=k8s --limit=_ --user --extra-vars 'k8s_action=destroy' + ``` + +- Remove service-provider-template repo + ``` + $ rm -rf service-provider-template + ``` + +- Remove any existing GPG keys + ``` + $ rm -rf gpg-keys/ + $ gpg --list-secret-keys --keyid-format=long + /home/dev/.gnupg/pubring.kbx + ---------------------------- + sec rsa4096/DA9E3D638930A699 2024-10-15 [SCEA] + 69A3200727091E72B773BBEBDA9E3D638930A699 + uid [ultimate] deepstack + ssb rsa3072/2B5D80CF44753EFD 2024-10-15 [SEA] + + sec rsa3072/2449A62C838440AB 2024-10-15 [SC] + 646A42164F978DC1415C11F12449A62C838440AB + uid [ultimate] webapp-deployer-api.deepstack.com + ssb rsa3072/67576558A2F2FE91 2024-10-15 [E] + + $ gpg --delete-secret-key 69A3200727091E72B773BBEBDA9E3D638930A699 + $ gpg --delete-key 69A3200727091E72B773BBEBDA9E3D638930A699 + $ gpg --delete-secret-key 646A42164F978DC1415C11F12449A62C838440AB + $ gpg --delete-key 646A42164F978DC1415C11F12449A62C838440AB + ``` +- Remove the user if required + + ```bash + $ userdel + + # If required, kill process that is using the user + # userdel: user is currently used by process 1639 + # $ kill -9 1639 + ``` + +- Remove DNS records using DigitalOcean's API: + - \ No newline at end of file diff --git a/service-provider-setup/setup-k8s.yml b/service-provider-setup/setup-k8s.yml index bc77ea2..d672695 100644 --- a/service-provider-setup/setup-k8s.yml +++ b/service-provider-setup/setup-k8s.yml @@ -66,6 +66,7 @@ command: gpg-agent --daemon ignore_errors: yes + # Cache GPG passphrase by signing a dummy string to avoid passphrase prompts in later steps - name: Sign a dummy string using gpg-key shell: echo "This is a dummy string." | gpg --batch --yes --local-user "{{ gpg_key_id }}" --passphrase "{{ vault_passphrase }}" --pinentry-mode loopback --sign - diff --git a/user-setup/README.md b/user-setup/README.md index 36cb980..5a7e964 100644 --- a/user-setup/README.md +++ b/user-setup/README.md @@ -12,7 +12,7 @@ To get started, follow the [installation](../README.md#installation) guide to se cp ../hosts.example.ini hosts.ini ``` -- Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine: +- Edit the [`hosts.ini`](./hosts.ini) file: ```ini [deployment_host]