Instead of modifying add_host to ignore case, why not just pass the values
through the jinja2 'lower' filter when passing them to add_host in your
playbook? You can even do something like the following to de-dupe with
existing inventory hosts:

{{ (list_with_new_hosts | map("lower")) | difference(groups.all |
map("lower")) }}

This will give you a list of hosts that only exist in the new list, taking
into account case differences, with all results in lowercase.

Andrew Gaffney
agaffney.org

On Wed, Apr 11, 2018 at 8:37 AM, Marek Slebodnik <mslebod...@gmail.com>
wrote:

> Hello,
>
> I've got playbook with dynamic inventory. And what bothers me is, that
> add_host is case sensitive.
>
> So when I have in my initial inventory
> ----
> kserVer3
> ---
> and tasks which which returns hostname from VCS cluster, returns:
> ['Kserver3', 'KServer4']
>
> I end up with inventory.
>
> -------
> kserVer3
> Kserver3
> Kserver4
> -------
> And as kserver3 and Kserver3 are same host.
>
> What I would suggest is additional add_host: attributes.
>
> e.g. *ignore_case: True*,
> and then final inventory would be
> ---
> kserVer3
> Kserver4
> ---
> and *ireplace_hostname: True*
> with result
> ---
> Kserver3
> Kserver4
> ---
>
> Before I start implementation, I would appreciate other's opinions.
>
> Regards
> Marek Slebodnik
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to