[ansible-projects] Hostname trimming help

Hi Experts,

Not exactly an ansible issue but any thought would be greatly appreciated.
We use AD for Password synchronization between different kinds of systems. For password synchronization we also use mainframe system which accepts only 8 charters as a hostname.
So now we are trimming the hostname and sending it to the mainframe system.
Ex: domain: ansible_hostname[:3] }}{{ ansible_hostname[-5:] }}
Earlier based on the datacenter the hostnames were given(EX:VANC+1001). Since the datacenter names are quite different, by trimming also there are no duplicates.
But now the hostname will be decided on the business unit so less number of combinations in hostnames.
For Ex: for BU’s : abcd, abcf, abciq
hostnames will be
abcd10001
abcf10001
abciq10001
For above all the hostnames the above ansible will return me the same hostname. which will be duplicated in the mainframe system.
domain: ansible_hostname[:3] }}{{ ansible_hostname[-5:] }}

abc10001
abc10001
abc10001

Any insight would be greatly helpful.

Regards

Something that was done at current job was use the last 5 digits of the mac address was a prefix for the host names. The mac pretty much guarentees a unique name with added bonus of assisting network finding on the network when there is a connectivity issue

Thanks for your comment.
You mean to say that instead of sending the trimmed hostname only something like
prefix 5 digits mac add+ last 3 digits of hostname.

Thanks again for your help