IP address to hexadecimal conversion

Hi,

I want to convert the IP address to hexadecimal format. Can you please tell me how to do it in ansible/jinja2? Below is my playbook.

  • name: Generate the routes and store in file
    set_fact:

variable: “[{% for i in range(0,256,16) %}{% for j in range(0,256,1) %}‘120.100.{{ j }}.{{ i }}’,{% endfor %}{% endfor %}]”

  • name: Dump the routes
    debug: var=variable

Thanks,
Madhu

You might want to have a look at the netaddr package:

http://netaddr.readthedocs.io/en/latest/tutorial_01.html

I looked at it. How do you use it in the tasks or variable file?

Did you find:

http://docs.ansible.com/ansible/playbooks_filters_ipaddr.html