check for duplicate ips on startup
This commit is contained in:
committed by
Andrew Paglusch
parent
8e69bd0375
commit
c73ebba5b6
@@ -4,7 +4,10 @@
|
|||||||
- name: Uninstall Nebula (clean install)
|
- name: Uninstall Nebula (clean install)
|
||||||
include_tasks: uninstall.yml
|
include_tasks: uninstall.yml
|
||||||
when: nebula_clean_install|bool
|
when: nebula_clean_install|bool
|
||||||
|
|
||||||
|
- name: Preflight checks
|
||||||
|
include_tasks: preflight.yml
|
||||||
|
|
||||||
- name: Install Nebula on all hosts
|
- name: Install Nebula on all hosts
|
||||||
include_tasks: nebula.yml
|
include_tasks: nebula.yml
|
||||||
|
|
||||||
|
|||||||
22
tasks/preflight.yml
Normal file
22
tasks/preflight.yml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
- name: Preflight checks
|
||||||
|
block:
|
||||||
|
- name: Collecting all nebula_internal_ip_addr values
|
||||||
|
set_fact:
|
||||||
|
sorted_ips: "{{ hostvars | map('extract', hostvars, ['nebula_internal_ip_addr']) | list | sort }}"
|
||||||
|
|
||||||
|
- name: Initialize duplicated_ips list
|
||||||
|
set_fact:
|
||||||
|
duplicated_ips: []
|
||||||
|
|
||||||
|
- name: Looking for duplicate IP addresses
|
||||||
|
set_fact:
|
||||||
|
duplicated_ips: "{{ duplicated_ips + [item] }}"
|
||||||
|
loop: "{{ sorted_ips | unique }}"
|
||||||
|
when: "sorted_ips | select('equalto', item) | list | length > 1"
|
||||||
|
|
||||||
|
- name: Fail if duplicate IP addresses are found
|
||||||
|
fail:
|
||||||
|
msg: "You have one or more hosts with duplicate IP addresses assigned: {{ duplicated_ips }}"
|
||||||
|
when: duplicated_ips | length > 0
|
||||||
|
run_once: true
|
||||||
Reference in New Issue
Block a user