diff --git a/defaults/main.yml b/defaults/main.yml index bc031bd..2e3b366 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -3,6 +3,7 @@ nebula_network_name: "My Nebula Mesh Network" nebula_network_cidr: 24 nebula_ca_cert_duration: "87600h0m0s" #10 years nebula_client_cert_duration: "43800h0m0s" #5 years +nebula_clean_install: false nebula_lighthouse_hostname: lighthouse nebula_lighthouse_internal_ip_addr: 192.168.77.1 @@ -13,3 +14,4 @@ nebula_default_inbound_rules: - { port: "any", proto: "any", host: "any" } nebula_default_outbound_rules: - { port: "any", proto: "any", host: "any" } + diff --git a/tasks/main.yml b/tasks/main.yml index 0f7b6de..872a8c4 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: Uninstall Nebula (clean install) + include: uninstall.yml + when: nebula_clean_install + - name: Install Nebula on all hosts include: nebula.yml diff --git a/tasks/uninstall.yml b/tasks/uninstall.yml new file mode 100644 index 0000000..aaf6be0 --- /dev/null +++ b/tasks/uninstall.yml @@ -0,0 +1,48 @@ +--- +- name: Remove Nebula Lighthouse + block: + - name: Stop lighthouse service + systemd: + name: lighthouse + state: stopped + daemon_reload: yes + enabled: no + ignore_errors: true + + - name: Remove lighthouse systemd service + file: + path: /etc/systemd/system/lighthouse.service + state: absent + when: inventory_hostname in groups['nebula_lighthouse'] + +- name: Remove Nebula nodes + block: + - name: Stop nebula service + systemd: + name: nebula + state: stopped + daemon_reload: yes + enabled: no + ignore_errors: true + + - name: Remove nebula systemd service + file: + path: /etc/systemd/system/nebula.service + state: absent + when: inventory_hostname not in groups['nebula_lighthouse'] + +- name: Remove Nebula installation directory + file: + path: /opt/nebula + state: absent + +- name: Remove Nebula check from cron + cron: + name: "nebula-check" + state: absent + +- name: Clear .neb entries from /etc/hosts + replace: + path: /etc/hosts + backup: yes + regexp: '^.+\.neb$\n'