Hi,
I posted something similar yesterday but for some reason it didn't appear
in the list, I've waited nearly 24 hours just in case it hadn't yet been
moderated before posting this, so apologies if it this becomes a duplicate.
I have a case where we can have a different Hide NAT address (or addresses)
per network. I need to pass the list of addresses specific to a particular
network to my hosts.allow.j2 template.
To achieve this, I have a separate vars file per network and use
include_vars in my task to get the appropriate file.
For example,
# file 10.18.101.yml
nathide:
- 10.18.101.5
- 10.18.101.10
# file 10.18.102.yml
nathide:
- 10.18.102.3
Now in my task file I want to include the appropriate vars file, at the
moment I do this as follows;
- include_vars: "{{ ansible_default_ipv4.network[:-2] }}.yml"
The above is just a work around and is fine while I only work with networks
that, for example, end in '.0' (e.g. 10.18.101.0). However, we also have
networks where the netmask varies so dropping the last two characters as
above won't do.
Can anyone help me with the correct (or at least a working method) to
dropping all characters after (and including) the last '.' in {{
ansible_default_ipv4.network }}?
Any suggestions of alternative ways of achieving the same would be more
than welcome (I know I can do this using shell and sed or something
similar, but wondered if there was a simple way of just manipulation the
variable retrieved from facts).
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/363ee12b-4afd-4f5e-a685-dcea21558722%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.