# \[ansible-projects\] Hostname trimming help

**URL:** <https://forum.ansible.com/t/ansible-projects-hostname-trimming-help/38289>\
**Category:** Ansible Project\
**Created:** [August 3, 2023, 1:56am UTC](https://forum.ansible.com/t/ansible-projects-hostname-trimming-help/38289 "2023-08-03T01:56:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prady\_A](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/prady_a/32/4792_2.png) [@Prady\_A](https://forum.ansible.com/u/Prady_A)\
**Post date:** [August 3, 2023, 1:56am UTC](https://forum.ansible.com/t/ansible-projects-hostname-trimming-help/38289/1 "2023-08-03T01:56:24Z")

</div>

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  
abc **d** 10001  
abc **f** 10001  
abc **iq** 10001  
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

---

<div class="post-metadata">

**Author:** ![Evan\_Hisey](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@Evan\_Hisey](https://forum.ansible.com/u/Evan_Hisey)\
**Post date:** [August 3, 2023, 2:01am UTC](https://forum.ansible.com/t/ansible-projects-hostname-trimming-help/38289/2 "2023-08-03T02:01:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Prady\_A](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/prady_a/32/4792_2.png) [@Prady\_A](https://forum.ansible.com/u/Prady_A)\
**Post date:** [August 3, 2023, 2:17am UTC](https://forum.ansible.com/t/ansible-projects-hostname-trimming-help/38289/3 "2023-08-03T02:17:42Z")

</div>

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
