#!/bin/bash
# {{ ansible_managed }}

declare -a arr=("openvpn-client@proton" "unbound" "dhcpd")

for i in "${arr[@]}"; do
  istatus=$(systemctl is-active $i)
  format="%-28s \x1b[32m%s\x1b[0m\n" # green output by default

  if [ "$istatus" != "active" ]; then
    format="%-28s \x1b[31m%s\x1b[0m\n" # make red if service not active
  fi

  printf "$format" "$i:" "$istatus"
done