IP address to hexadecimal conversion

589 views
Skip to first unread message

Madhu

unread,
Mar 11, 2017, 11:07:04 AM3/11/17
to ansible...@googlegroups.com
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


Mischa ter Smitten

unread,
Mar 11, 2017, 1:51:44 PM3/11/17
to Ansible Project
You might want to have a look at the netaddr package:

Madhu

unread,
Mar 12, 2017, 12:21:10 PM3/12/17
to ansible...@googlegroups.com
I looked at it. How do you use it in the tasks or variable file?

--
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 ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/13e393ee-39ba-430f-8746-5a89e85c08f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mischa ter Smitten

unread,
Mar 13, 2017, 4:29:05 AM3/13/17
to Ansible Project


On Sunday, March 12, 2017 at 5:21:10 PM UTC+1, Madhusudhanan Santhanam wrote:
I looked at it. How do you use it in the tasks or variable file?
On Sat, Mar 11, 2017 at 10:51 AM, Mischa ter Smitten <mis...@tersmitten.nl> wrote:
You might want to have a look at the netaddr package:

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


On Saturday, March 11, 2017 at 5:07:04 PM UTC+1, Madhusudhanan Santhanam wrote:
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 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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages