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 - hosts: all
remote_user: root remote_user: root
tasks: 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 - name: Get innernet-server hostname from inventory groups
set_fact: set_fact:
# Assuming that we only have one innernet server, we take the first # Assuming that we only have one innernet server, we take the first

View File

@ -18,7 +18,7 @@
- ['-fsfe-be', ''] - ['-fsfe-be', '']
- name: Gather which packages are installed on the client - name: Gather which packages are installed on the client
tags: [update] tags: [update, uninstall]
package_facts: package_facts:
manager: auto manager: auto
@ -31,12 +31,21 @@
- wireguard-tools - wireguard-tools
- ufw - ufw
- name: Remove existing innernet - name: Remove existing innernet configuration on client
tags: [never, uninstall] tags: [never, uninstall]
expect: expect:
command: "innernet uninstall {{ network_name }}" command: "innernet uninstall {{ network_name }}"
responses: responses:
(?i)delete: "yes" (?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 - name: Install innernet package on client
tags: [update] tags: [update]

View File

@ -4,7 +4,7 @@
--- ---
- name: Gather which packages are installed on the server - name: Gather which packages are installed on the server
tags: [update] tags: [update, uninstall]
package_facts: package_facts:
manager: auto manager: auto
@ -18,12 +18,21 @@
- wireguard-tools - wireguard-tools
- ufw - ufw
- name: Remove existing innernet - name: Remove existing innernet configuration
tags: [never, uninstall] tags: [never, uninstall]
expect: expect:
command: "innernet-server uninstall {{ network_name }}" command: "innernet-server uninstall {{ network_name }}"
responses: responses:
(?i)delete: "yes" (?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 - name: Install innernet package on server
tags: [update] tags: [update]