Get IP address, replace first three octets

Hello,
I'm trying to assign ILO IP addresses to a range of systems, using a different subnet than their host IP, just matching the fourth octet. For example, if their IP would be 10.10.10.10, I want their ILO IP to be 11.11.11.10.( Plan is to use "hponcfg" module to configure the host's ILO after I obtain this address)
What is the best way to achieve this with ansible?

I don't know the hponcfg module, but from
https://docs.ansible.com/ansible/latest/modules/hponcfg_module.html#examples
it looks like you have to first copy an XML fragment with some
specific configuration code, and then use that with the hponcfg
module.
If you are able to use ansible 2.7, then you can use this expression
for the new ILO IP in your XML fragment:

{{ ansible_default_ipv4.address | ipmath(2**24 + 2**16 + 2**8) }}"

This basically increases the first 3 octets by 1, by adding 2^24,
2^16, and 2^8 to them.
If you don't like your co-workers, use:

{{ ansible_default_ipv4.address | ipmath(16843008) }}"

Dick

Hello!
Unfortunately, we are using version 2.4, don’t think upgrading is an option (at least at this point) any other ideas ?

What are the part that you struggle with?
For the IP you can do something like this

  - debug: msg="11.11.11.{{ ansible_default_ipv4.address.split('.').3 }}"

sorry, dummy question: But where does the "split" come from? It's not a YAML statement, its not a standard Jinja2 filter and its not one of the special ansible Jinja2 filters. I'm confused.

frank

Jinja is a template language for Python.
I guess a Jinja strings has some, if not all the method a Python string object has
https://docs.python.org/2/library/stdtypes.html#str.split

Not an ansible response (use command or shell to execute), but can retrieve the iLO network settings and change with:

`

This is coded against iLO4!

Run as root

cd /var/tmp # or where ever you would like to have your temporary files

Thank you all very much for your feedback! All the replies helped me solve the task.
cheers!