Really simple thing I want to do in Ansible ... or so you would think.
All I want to do is to set a variable [which I later use in a j2 template] to the value of ansible_default_ipv4.network
, with the last byte chopped off and third incremented.
so, if ansible_default_ipv4.network
is 192.168.10.0, I want to the new variable set to 192.168.11.
Here's how I presently do it:
- set_fact:
x: "{{ ansible_default_ipv4.network.split('.')[0:3] }}"
- set_fact:
x2: "{{ x.2 | int + 1 }}"
- set_fact:
x3: "{{x.0}}.{{x.1}}.{{x2}}"
Works fine, but is as ugly as a box or frogs :(
Is there a cleaner way of doing this?
Thanks!