Hi Matt,

A solution like this should work for you:

   - name: "set new hostname fact"
      set_fact:
        my_host: "{{ inventory_hostname.split('.')[0] }}.{{
inventory_hostname.split('.')[1] }}.{{ inventory_hostname,split('.')[-1] }}"

On Sat, Oct 26, 2019 at 1:18 AM Matti Herrmann <matti-zehnka...@web.de>
wrote:

> Hello,
>
> I wan´t to split the hostname of my inventory hostnames. The hostnames
> have two or three subdomains. For Exampel "host.sub1.sub2.domain"
> I need two splits. One bevor the first dot (in our example: host) and one
> after the first dot. (sub1.sub2.domain).
> I tried with {{ HOST.split(".")[0] }}, but there will be split after every
> dot.
>
> Any idea?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-devel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-devel/cf96882c-a294-4ef7-9c35-a27ef8202caa%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-devel/cf96882c-a294-4ef7-9c35-a27ef8202caa%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/CA%2Bs1_jTOomRGtCyi2NXBUnjCXcrrBU8Ld6x5DFiXOMNYtPYryg%40mail.gmail.com.

Reply via email to