From e65f1d15a67bd2cd62d2b5e151218dfa3aee3ced Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Fri, 1 Sep 2023 15:42:27 -0400 Subject: [PATCH] Add coordinator state to MOTD --- roles/base/tasks/main.yml | 5 +++++ roles/base/templates/usr/local/sbin/update-motd.sh.j2 | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/roles/base/tasks/main.yml b/roles/base/tasks/main.yml index f837252..1bffff8 100644 --- a/roles/base/tasks/main.yml +++ b/roles/base/tasks/main.yml @@ -15,6 +15,11 @@ when: newhost_check.changed tags: always +# Set coordinator state fact +- set_fact: + is_coordinator: "{% for node in pvc_nodes if node.hostname == inventory_hostname %}{{ node.is_coordinator }}{% endfor %}" + tags: always + # # Set Debian details # diff --git a/roles/base/templates/usr/local/sbin/update-motd.sh.j2 b/roles/base/templates/usr/local/sbin/update-motd.sh.j2 index c48c6fe..de8a8f9 100755 --- a/roles/base/templates/usr/local/sbin/update-motd.sh.j2 +++ b/roles/base/templates/usr/local/sbin/update-motd.sh.j2 @@ -22,7 +22,7 @@ MANUFACTURER="$( /usr/sbin/dmidecode | grep -A1 'Chassis Information' | tail -1 if [[ -z ${MANUFACTURER} ]]; then MANUFACTURER='Unknown' fi -echo "> \033[1;37mPVC node\033[0m on \033[1;31m${MANUFACTURER}\033[0m hardware" >> $TMPFILE +echo "> \033[1;37mPVC {% if is_coordinator %}coordinator{% else %}hypervisor{% endif %} node\033[0m on \033[1;31m${MANUFACTURER}\033[0m hardware" >> $TMPFILE echo "> $(/bin/uname -srvmo)" >> $TMPFILE mv $TMPFILE $TGTFILE || rm $TMPFILE