Accept int input for ipaddr ipv4 and ipv6 filters (#224)
* Accept int input for ipaddr ipv4 and ipv6 filters * Fix fragment * Fix testspull/228/head
parent
4f38c362f7
commit
baba9ca7ea
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
bugfixes:
|
||||
- Accept int input for ipaddr filters.
|
|
@ -261,6 +261,8 @@ def _ipaddr(*args, **kwargs):
|
|||
pass
|
||||
elif isinstance(data["value"], list):
|
||||
pass
|
||||
elif isinstance(data["value"], int):
|
||||
pass
|
||||
else:
|
||||
raise AnsibleFilterError(
|
||||
"Unrecognized type <{0}> for ipaddr filter <{1}>".format(
|
||||
|
|
|
@ -138,6 +138,8 @@ def _ipv4(*args, **kwargs):
|
|||
pass
|
||||
elif isinstance(data["value"], list):
|
||||
pass
|
||||
elif isinstance(data["value"], int):
|
||||
pass
|
||||
else:
|
||||
raise AnsibleFilterError(
|
||||
"Unrecognized type <{0}> for ipv4 filter <{1}>".format(
|
||||
|
|
|
@ -156,6 +156,8 @@ def _ipv6(*args, **kwargs):
|
|||
pass
|
||||
elif isinstance(data["value"], list):
|
||||
pass
|
||||
elif isinstance(data["value"], int):
|
||||
pass
|
||||
else:
|
||||
raise AnsibleFilterError(
|
||||
"Unrecognized type <{0}> for ipv6 filter <{1}>".format(
|
||||
|
|
|
@ -57,3 +57,18 @@
|
|||
- name: Assert result for ipaddr filter with chained filters
|
||||
assert:
|
||||
that: "{{ result6 == '192.168.255.123' }}"
|
||||
|
||||
- debug:
|
||||
msg: "Test int input for ipaddr filter"
|
||||
|
||||
- name: set fact 1
|
||||
set_fact:
|
||||
ip1: "172.20.0.1"
|
||||
|
||||
- name: Set fact 2
|
||||
set_fact:
|
||||
ip2: "{{ ((ip1 | ansible.utils.ipaddr('int')) + 6) | ansible.utils.ipaddr }}"
|
||||
|
||||
- name: Assert result for ipaddr filter
|
||||
assert:
|
||||
that: "{{ ip2 == '172.20.0.7' }}"
|
||||
|
|
Loading…
Reference in New Issue