improve uninstallation mechanism and prevent accidental removal

This commit is contained in:
max.mehl 2022-03-03 17:40:44 +01:00
parent e0b5bf5ebb
commit 75c2682bef
No known key found for this signature in database
GPG Key ID: 2704E4AB371E2E92
3 changed files with 36 additions and 4 deletions

View File

@ -6,6 +6,20 @@
- hosts: all
remote_user: root
tasks:
- pause:
prompt: "You are using a function to UNINSTALL innernet on the chosen hosts {{ play_hosts }}. Continue? (yes/no)?"
tags: [never, uninstall]
register: uninstall_confirm
delegate_to: localhost
run_once: yes
- fail:
msg: Aborted uninstallation of innernet.
tags: [never, uninstall]
when: not uninstall_confirm.user_input | bool
delegate_to: localhost
run_once: yes
- name: Get innernet-server hostname from inventory groups
set_fact:
# Assuming that we only have one innernet server, we take the first

View File

@ -18,7 +18,7 @@
- ['-fsfe-be', '']
- name: Gather which packages are installed on the client
tags: [update]
tags: [update, uninstall]
package_facts:
manager: auto
@ -31,12 +31,21 @@
- wireguard-tools
- ufw
- name: Remove existing innernet
- name: Remove existing innernet configuration on client
tags: [never, uninstall]
expect:
command: "innernet uninstall {{ network_name }}"
responses:
(?i)delete: "yes"
when: "'innernet' in ansible_facts.packages"
- name: Remove innernet package on client
tags: [never, uninstall]
apt:
name: innernet
state: absent
purge: yes
when: "'innernet' in ansible_facts.packages"
- name: Install innernet package on client
tags: [update]

View File

@ -4,7 +4,7 @@
---
- name: Gather which packages are installed on the server
tags: [update]
tags: [update, uninstall]
package_facts:
manager: auto
@ -18,12 +18,21 @@
- wireguard-tools
- ufw
- name: Remove existing innernet
- name: Remove existing innernet configuration
tags: [never, uninstall]
expect:
command: "innernet-server uninstall {{ network_name }}"
responses:
(?i)delete: "yes"
when: "'innernet-server' in ansible_facts.packages"
- name: Remove innernet package on server
tags: [never, uninstall]
apt:
name: innernet-server
state: absent
purge: yes
when: "'innernet-server' in ansible_facts.packages"
- name: Install innernet package on server
tags: [update]