Re: [ansible-devel] split FQDN

2019-10-27 Thread Matti Herrmann
Hi Andreas, that's exactly what I need. In [12]: s.split('.', 1) Out[12]: ['host', 'sub1.sub2.example.com '] Thanks. Am Sonntag, 27. Oktober 2019 18:25:04 UTC+1

Re: [ansible-devel] split FQDN

2019-10-27 Thread Andreas Härpfer
Hi Matti, I'm not exactly sure what you are trying to accomplish, but I would like to point out that `split()` has an optional parameter `maxsplit` that limits the number of splits that are actually done. Shouldn't that help to solve your problem? In [11]: s='host.sub1.sub2.example.com'

Re: [ansible-devel] split FQDN

2019-10-27 Thread Matti Herrmann
Hi Tom, this give me the result host.sub1.hostname but not host.sub1.sub2.hostname. For Hostnames with one subdomain it works fine, but not for Domains with more subdomains. Am Samstag, 26. Oktober 2019 14:21:38 UTC+2 schrieb Tom Davison: > > Hi Matt, > > A solution like this should work for

Re: [ansible-devel] split FQDN

2019-10-26 Thread Tom Davison
Matti** sorry about the miss spelling On Sat, Oct 26, 2019 at 7:21 AM Tom Davison wrote: > 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('.')

Re: [ansible-devel] split FQDN

2019-10-26 Thread Tom Davison
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 wrote: >