+check_prerequisites() {
+ info "Check prerequisites"
+
+ #-------------------------------------------------------------------------------
+ # Check for DEPLOYMENT type
+ #-------------------------------------------------------------------------------
+ DEPLOYMENT=${DEPLOYMENT:-full}
+ if ! [[ "$DEPLOYMENT" =~ ^(full|k8s)$ ]]; then
+ error "Unsupported value for DEPLOYMENT ($DEPLOYMENT)"
+ fi
+
+ #-------------------------------------------------------------------------------
+ # We shouldn't be running as root
+ #-------------------------------------------------------------------------------
+ if [[ "$(whoami)" == "root" ]] && [[ "$DEPLOYMENT" != "k8s" ]]; then
+ error "This script must not be run as root! Please switch to a regular user before running the script."
+ fi
+
+ #-------------------------------------------------------------------------------
+ # Check for passwordless sudo
+ #-------------------------------------------------------------------------------
+ if ! sudo -n "true"; then
+ error "passwordless sudo is needed for '$(id -nu)' user."
+ fi
+
+ #-------------------------------------------------------------------------------
+ # Check if SSH key exists
+ #-------------------------------------------------------------------------------
+ if [[ ! -f "$HOME/.ssh/id_rsa" ]]; then
+ error "You must have SSH keypair in order to run this script!"
+ fi
+
+ #-------------------------------------------------------------------------------
+ # We are using sudo so we need to make sure that env_reset is not present
+ #-------------------------------------------------------------------------------
+ sudo sed -i "s/^Defaults.*env_reset/#&/" /etc/sudoers
+
+ #-------------------------------------------------------------------------------
+ # Check if some tools are installed
+ #-------------------------------------------------------------------------------
+ for tool in ansible yq virsh jq; do
+ if ! command -v "$tool" &> /dev/null; then
+ error "$tool not found. Please install."
+ fi