Generate server name during enlistment based on ipmi and lldp information


We are deploying MAAS in my company to manage a wide kubernetes cluster (90 servers at least).

I have already managed to handle post install using curtin cloud-init and ansible playbooks.

The only thing remaining for me is how can I define servername programatically based on the following criteria

  • Chassis serial number / particular information on ipmi
  • Switch name (based on lldp discover that I could do at enlistment)
  • Port name (like switch name)

I have tried to modify the enlist script without success.

Does anybody knows if it’s at least possible ?


Still trying to dig arround enlist and found that enlist_userdata is not being honored at all.

Querying http://maas:5240/MAAS/metadata/enlist/latest/user-data gives you what is available at /usr/lib/python3/dist-packages/metadataserver/user_data/templates/enlistment.template

Putting an enlist_userdata file in /etc/maas/preseeds/ don’t change the output of the http call.

enlist phase seems to work differently compared to curtin…

Does anybody knows if it’s at least possible ?

I am running maas 2.6 and already found enlist_userdata scripts on various sites but it seems to be related to an old version.

Thanks a lot


no, currently it’s not possible to script how the names should be generated.

What you could do, though, so to write an API script that goes through the enlisted machines and renames them the way you want to.

OK that’s sad…

Thanks for the feedback, I’ll stop searching in the code so :slight_smile:

maas-enlist script has -h (hostname) option which is not used by calling script (enlistment.template) so I’d start there probably.

I solved similar issue by editing directly

which handles enlistment process. You should probably generate hostname from lldp and ipmi from there.

I know that, I wanted to find a solution persistent to upgrades

My idea was to do that :
switch_name=$(lldpcli -f keyvalue show neighbors | grep | awk -F ‘=’ ‘{print $2}’ |awk -F’.’ ‘{print tolower($1)}’)
port_number=$(lldpcli -f keyvalue show neighbors | grep ifname | awk -F ‘=’ ‘{print $2}’ |awk -F’.’ ‘{print tolower($1)}’ | grep -o ‘[[:digit:]]+’)
host=$(echo $switch_name"-"$port_number)

and then
output=$(maas-enlist --quite --serverurl “{{server_url}}”
${host:±-hostname “${host}”} ${power_params:±-power-params “${power_params}”
–power-type “${power_type}”}{{if enlist_commissioning}} --commission{{endif}})

I’m using that with configuration management (ansible in pull mode) so if upgrade is done, it will automatically replace new files.

But I agree that this should have more elegant solution.