Last active
December 1, 2017 08:20
-
-
Save ThinGuy/5956fe5db681c87e90260a4a39b64612 to your computer and use it in GitHub Desktop.
Examples how to have maas auto-tag server models at a high level with "contains", or to you can get specific with exact matches for certain generations of hardware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[ ${MAAS_PROFILE} ]] || MAAS_PROFILE=$(maas 2>/dev/null list|awk '{print $1}') | |
if [[ -z ${MAAS_PROFILE} ]];then | |
printf "Cannot determine MaaS profile name. Please log in to maas from the command line.\n\n" | |
#if being called from a function, return | |
[[ $0 = bash ]] && return 1 | |
#if being called from a script, exit | |
[[ -f $0 ]] && exit 1 | |
else | |
#This tag will identify any Generation of HP XL420 Server (G1-G9) | |
maas ${MAAS_PROFILE} tags create name=XL420 \ | |
comment="xpath tag to automatically identify Proliant XL420 Servers" \ | |
definition='contains(//node[@id="core" and @class="bus"]/product,"XL420")' \ | |
kernel_opts='net.ifnames=0 console=tty0 console=ttyS0' | |
#This tag will identify any Generation of HP DL360 Server (G1-G9) | |
maas ${MAAS_PROFILE} tags create name=DL360 \ | |
comment="xpath tag to automatically identify Proliant DL360 Servers" \ | |
definition='contains(//node[@id="core" and @class="bus"]/product,"DL360")' \ | |
kernel_opts='net.ifnames=0 console=tty1 console=ttyS1' | |
#This tag has a definition that should match all SuperMicro Servers | |
maas ${MAAS_PROFILE} tags create name=SuperMicro \ | |
comment="xpath tag to automatically identify SuperMirco Servers" \ | |
definition='//node[@id="core" and @class="bus"]/vendor = "Supermicro"' \ | |
kernel_opts='net.ifnames=0 console=tty1 console=ttyS1' | |
#Get more specific with hardware | |
#This tag will only match Gen9 HP XL420 hardware: | |
maas ${MAAS_PROFILE} tags create name=XL420G9 \ | |
comment="xpath tag to automatically identify Proliant XL420 Gen9 Servers" \ | |
definition='//node[@id="core" and @class="bus"]/product = "ProLiant XL420 Gen9"' \ | |
kernel_opts='net.ifnames=0 console=tty0 console=ttyS0' | |
#This tag will only match Gen9 HP DL360 hardware: | |
maas ${MAAS_PROFILE} tags create name=DL360G9 \ | |
comment="xpath tag to automatically identify Proliant DL360 Gen9 Servers" \ | |
definition='//node[@id="core" and @class="bus"]/product = "ProLiant DL360 Gen9"' \ | |
kernel_opts='net.ifnames=0 console=tty1 console=ttyS1' | |
#Example how Tag boxes based on peripherals | |
#Tag boxes with NVME cards: | |
maas admin tags create name=NVME \ | |
comment="xpath tag for automatically tagging servers that have NVME controllers" \ | |
definition='//node[@id="storage" and @class="storage"]/description = "Non-Volatile memory controller"' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment