Added ipv6 test plugins (#70)
Added ipv6 test plugins Reviewed-by: https://github.com/apps/ansible-zuulpull/75/head
parent
e92cc6e78d
commit
842549a236
|
@ -56,6 +56,11 @@ Name | Description
|
||||||
[ansible.utils.ipv4_address](https://github.com/ansible-collections/ansible.utils/blob/main/docs/ansible.utils.ipv4_address_test.rst)|Test if something is an IPv4 address
|
[ansible.utils.ipv4_address](https://github.com/ansible-collections/ansible.utils/blob/main/docs/ansible.utils.ipv4_address_test.rst)|Test if something is an IPv4 address
|
||||||
[ansible.utils.ipv4_hostmask](https://github.com/ansible-collections/ansible.utils/blob/main/docs/ansible.utils.ipv4_hostmask_test.rst)|Test if an address is a valid hostmask
|
[ansible.utils.ipv4_hostmask](https://github.com/ansible-collections/ansible.utils/blob/main/docs/ansible.utils.ipv4_hostmask_test.rst)|Test if an address is a valid hostmask
|
||||||
[ansible.utils.ipv4_netmask](https://github.com/ansible-collections/ansible.utils/blob/main/docs/ansible.utils.ipv4_netmask_test.rst)|Test if an address is a valid netmask
|
[ansible.utils.ipv4_netmask](https://github.com/ansible-collections/ansible.utils/blob/main/docs/ansible.utils.ipv4_netmask_test.rst)|Test if an address is a valid netmask
|
||||||
|
[ansible.utils.ipv6](https://github.com/ansible-collections/ansible.utils/blob/main/docs/ansible.utils.ipv6_test.rst)|Test if something is an IPv6 address or network
|
||||||
|
[ansible.utils.ipv6_address](https://github.com/ansible-collections/ansible.utils/blob/main/docs/ansible.utils.ipv6_address_test.rst)|Test if something is an IPv6 address
|
||||||
|
[ansible.utils.ipv6_ipv4_mapped](https://github.com/ansible-collections/ansible.utils/blob/main/docs/ansible.utils.ipv6_ipv4_mapped_test.rst)|Test if something appears to be a mapped IPv6 to IPv4 mapped address
|
||||||
|
[ansible.utils.ipv6_sixtofour](https://github.com/ansible-collections/ansible.utils/blob/main/docs/ansible.utils.ipv6_sixtofour_test.rst)|Test if something appears to be a 6to4 address
|
||||||
|
[ansible.utils.ipv6_teredo](https://github.com/ansible-collections/ansible.utils/blob/main/docs/ansible.utils.ipv6_teredo_test.rst)|Test if something appears to be an IPv6 teredo address
|
||||||
[ansible.utils.validate](https://github.com/ansible-collections/ansible.utils/blob/main/docs/ansible.utils.validate_test.rst)|Validate data with provided criteria
|
[ansible.utils.validate](https://github.com/ansible-collections/ansible.utils/blob/main/docs/ansible.utils.validate_test.rst)|Validate data with provided criteria
|
||||||
|
|
||||||
<!--end collection content-->
|
<!--end collection content-->
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- Add ipv6, ipv6_address, ipv6_ipv4_mapped, ipv6_sixtofour, ipv6_teredo test plugins
|
|
@ -0,0 +1,150 @@
|
||||||
|
.. _ansible.utils.ipv6_address_test:
|
||||||
|
|
||||||
|
|
||||||
|
**************************
|
||||||
|
ansible.utils.ipv6_address
|
||||||
|
**************************
|
||||||
|
|
||||||
|
**Test if something is an IPv6 address**
|
||||||
|
|
||||||
|
|
||||||
|
Version added: 2.2.0
|
||||||
|
|
||||||
|
.. contents::
|
||||||
|
:local:
|
||||||
|
:depth: 1
|
||||||
|
|
||||||
|
|
||||||
|
Synopsis
|
||||||
|
--------
|
||||||
|
- This plugin checks if the provided value is a valid host IP address with IPv6 addressing scheme
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
|
||||||
|
.. raw:: html
|
||||||
|
|
||||||
|
<table border=0 cellpadding=0 class="documentation-table">
|
||||||
|
<tr>
|
||||||
|
<th colspan="1">Parameter</th>
|
||||||
|
<th>Choices/<font color="blue">Defaults</font></th>
|
||||||
|
<th>Configuration</th>
|
||||||
|
<th width="100%">Comments</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>ip</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
/ <span style="color: red">required</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>A string that represents the value against which the test is going to be performed</div>
|
||||||
|
<div>{'For example': ['10.1.1.1', '10.0.0.0/8', 'fe80::216:3eff:fee4:16f3']}</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
#### Simple examples
|
||||||
|
|
||||||
|
- name: Check if fe80::216:3eff:fee4:16f3 is a valid IPv6 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ 'fe80::216:3eff:fee4:16f3' is ansible.utils.ipv6_address }}"
|
||||||
|
|
||||||
|
# TASK [Check if fe80::216:3eff:fee4:16f3 is a valid IPv6 address] *********************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if 2001:db8:a::123/64 is not a valid IPv6 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '2001:db8:a::123/64' is not ansible.utils.ipv6_address }}"
|
||||||
|
|
||||||
|
# TASK [Check if 2001:db8:a::123/64 is not a valid IPv6 address] ***********************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if 192.169.1.250 is not a valid IPv6 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '192.169.1.250' is not ansible.utils.ipv6_address }}"
|
||||||
|
|
||||||
|
# TASK [Check if 192.169.1.250 is not a valid IPv6 address] ****************************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Return Values
|
||||||
|
-------------
|
||||||
|
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this test:
|
||||||
|
|
||||||
|
.. raw:: html
|
||||||
|
|
||||||
|
<table border=0 cellpadding=0 class="documentation-table">
|
||||||
|
<tr>
|
||||||
|
<th colspan="1">Key</th>
|
||||||
|
<th>Returned</th>
|
||||||
|
<th width="100%">Description</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
||||||
|
<b>data</b>
|
||||||
|
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">-</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
<td>
|
||||||
|
<div>If jinja test satisfies plugin expression <code>true</code></div>
|
||||||
|
<div>If jinja test does not satisfy plugin expression <code>false</code></div>
|
||||||
|
<br/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br/><br/>
|
||||||
|
|
||||||
|
|
||||||
|
Status
|
||||||
|
------
|
||||||
|
|
||||||
|
|
||||||
|
Authors
|
||||||
|
~~~~~~~
|
||||||
|
|
||||||
|
- Priyam Sahoo (@priyamsahoo)
|
||||||
|
|
||||||
|
|
||||||
|
.. hint::
|
||||||
|
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.
|
|
@ -0,0 +1,150 @@
|
||||||
|
.. _ansible.utils.ipv6_ipv4_mapped_test:
|
||||||
|
|
||||||
|
|
||||||
|
******************************
|
||||||
|
ansible.utils.ipv6_ipv4_mapped
|
||||||
|
******************************
|
||||||
|
|
||||||
|
**Test if something appears to be a mapped IPv6 to IPv4 mapped address**
|
||||||
|
|
||||||
|
|
||||||
|
Version added: 2.2.0
|
||||||
|
|
||||||
|
.. contents::
|
||||||
|
:local:
|
||||||
|
:depth: 1
|
||||||
|
|
||||||
|
|
||||||
|
Synopsis
|
||||||
|
--------
|
||||||
|
- This plugin checks if the provided value is a valid IPv4-mapped IPv6 address
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
|
||||||
|
.. raw:: html
|
||||||
|
|
||||||
|
<table border=0 cellpadding=0 class="documentation-table">
|
||||||
|
<tr>
|
||||||
|
<th colspan="1">Parameter</th>
|
||||||
|
<th>Choices/<font color="blue">Defaults</font></th>
|
||||||
|
<th>Configuration</th>
|
||||||
|
<th width="100%">Comments</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>ip</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
/ <span style="color: red">required</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>A string that represents the value against which the test is going to be performed</div>
|
||||||
|
<div>{'For example': ['::FFFF:10.1.1.1', '::AAAA:10.1.1.1', 'helloworld']}</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
#### Simple examples
|
||||||
|
|
||||||
|
- name: Check if ::FFFF:10.1.1.1 is a valid IPv4-mapped IPv6 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '::FFFF:10.1.1.1' is ansible.utils.ipv6_ipv4_mapped }}"
|
||||||
|
|
||||||
|
# TASK [Check if ::FFFF:10.1.1.1 is a valid IPv4-mapped IPv6 address] *************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if ::AAAA:10.1.1.1 is not a valid IPv4-mapped IPv6 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '::AAAA:10.1.1.1' is not ansible.utils.ipv6_ipv4_mapped }}"
|
||||||
|
|
||||||
|
# TASK [Check if ::AAAA:10.1.1.1 is not a valid IPv4-mapped IPv6 address] ******************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if helloworld is not a valid IPv4-mapped IPv6 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ 'helloworld' is not ansible.utils.ipv6_ipv4_mapped }}"
|
||||||
|
|
||||||
|
# TASK [Check if helloworld is not a valid IPv4-mapped IPv6 address] ***********************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Return Values
|
||||||
|
-------------
|
||||||
|
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this test:
|
||||||
|
|
||||||
|
.. raw:: html
|
||||||
|
|
||||||
|
<table border=0 cellpadding=0 class="documentation-table">
|
||||||
|
<tr>
|
||||||
|
<th colspan="1">Key</th>
|
||||||
|
<th>Returned</th>
|
||||||
|
<th width="100%">Description</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
||||||
|
<b>data</b>
|
||||||
|
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">-</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
<td>
|
||||||
|
<div>If jinja test satisfies plugin expression <code>true</code></div>
|
||||||
|
<div>If jinja test does not satisfy plugin expression <code>false</code></div>
|
||||||
|
<br/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br/><br/>
|
||||||
|
|
||||||
|
|
||||||
|
Status
|
||||||
|
------
|
||||||
|
|
||||||
|
|
||||||
|
Authors
|
||||||
|
~~~~~~~
|
||||||
|
|
||||||
|
- Priyam Sahoo (@priyamsahoo)
|
||||||
|
|
||||||
|
|
||||||
|
.. hint::
|
||||||
|
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.
|
|
@ -0,0 +1,150 @@
|
||||||
|
.. _ansible.utils.ipv6_sixtofour_test:
|
||||||
|
|
||||||
|
|
||||||
|
****************************
|
||||||
|
ansible.utils.ipv6_sixtofour
|
||||||
|
****************************
|
||||||
|
|
||||||
|
**Test if something appears to be a 6to4 address**
|
||||||
|
|
||||||
|
|
||||||
|
Version added: 2.2.0
|
||||||
|
|
||||||
|
.. contents::
|
||||||
|
:local:
|
||||||
|
:depth: 1
|
||||||
|
|
||||||
|
|
||||||
|
Synopsis
|
||||||
|
--------
|
||||||
|
- This plugin checks if the provided value is a valid 6to4 address
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
|
||||||
|
.. raw:: html
|
||||||
|
|
||||||
|
<table border=0 cellpadding=0 class="documentation-table">
|
||||||
|
<tr>
|
||||||
|
<th colspan="1">Parameter</th>
|
||||||
|
<th>Choices/<font color="blue">Defaults</font></th>
|
||||||
|
<th>Configuration</th>
|
||||||
|
<th width="100%">Comments</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>ip</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
/ <span style="color: red">required</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>A string that represents the value against which the test is going to be performed</div>
|
||||||
|
<div>{'For example': ['2002:c0a8:6301:1::1', '::AAAA:10.1.1.1', 'hello_world']}</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
#### Simple examples
|
||||||
|
|
||||||
|
- name: Check if 2002:c0a8:6301:1::1 is a valid 6to4 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '2002:c0a8:6301:1::1' is ansible.utils.ipv6_sixtofour }}"
|
||||||
|
|
||||||
|
# TASK [Check if 2002:c0a8:6301:1::1 is a valid 6to4 address] ****************************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if 2001:c0a8:6301:1::1 is not a valid 6to4 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '2001:c0a8:6301:1::1' is not ansible.utils.ipv6_sixtofour }}"
|
||||||
|
|
||||||
|
# TASK [Check if 2001:c0a8:6301:1::1 is not a valid 6to4 address] ************************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if helloworld is not a valid 6to4 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ 'helloworld' is not ansible.utils.ipv6_sixtofour }}"
|
||||||
|
|
||||||
|
# TASK [Check if helloworld is not a valid 6to4 address] *********************************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Return Values
|
||||||
|
-------------
|
||||||
|
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this test:
|
||||||
|
|
||||||
|
.. raw:: html
|
||||||
|
|
||||||
|
<table border=0 cellpadding=0 class="documentation-table">
|
||||||
|
<tr>
|
||||||
|
<th colspan="1">Key</th>
|
||||||
|
<th>Returned</th>
|
||||||
|
<th width="100%">Description</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
||||||
|
<b>data</b>
|
||||||
|
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">-</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
<td>
|
||||||
|
<div>If jinja test satisfies plugin expression <code>true</code></div>
|
||||||
|
<div>If jinja test does not satisfy plugin expression <code>false</code></div>
|
||||||
|
<br/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br/><br/>
|
||||||
|
|
||||||
|
|
||||||
|
Status
|
||||||
|
------
|
||||||
|
|
||||||
|
|
||||||
|
Authors
|
||||||
|
~~~~~~~
|
||||||
|
|
||||||
|
- Priyam Sahoo (@priyamsahoo)
|
||||||
|
|
||||||
|
|
||||||
|
.. hint::
|
||||||
|
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.
|
|
@ -0,0 +1,150 @@
|
||||||
|
.. _ansible.utils.ipv6_teredo_test:
|
||||||
|
|
||||||
|
|
||||||
|
*************************
|
||||||
|
ansible.utils.ipv6_teredo
|
||||||
|
*************************
|
||||||
|
|
||||||
|
**Test if something appears to be an IPv6 teredo address**
|
||||||
|
|
||||||
|
|
||||||
|
Version added: 2.2.0
|
||||||
|
|
||||||
|
.. contents::
|
||||||
|
:local:
|
||||||
|
:depth: 1
|
||||||
|
|
||||||
|
|
||||||
|
Synopsis
|
||||||
|
--------
|
||||||
|
- This plugin checks if the provided value is a valid IPv6 teredo address
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
|
||||||
|
.. raw:: html
|
||||||
|
|
||||||
|
<table border=0 cellpadding=0 class="documentation-table">
|
||||||
|
<tr>
|
||||||
|
<th colspan="1">Parameter</th>
|
||||||
|
<th>Choices/<font color="blue">Defaults</font></th>
|
||||||
|
<th>Configuration</th>
|
||||||
|
<th width="100%">Comments</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>ip</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
/ <span style="color: red">required</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>A string that represents the value against which the test is going to be performed</div>
|
||||||
|
<div>{'For example': ['2001::c0a8:6301:1', '2002::c0a8:6301:1', 'hello_world']}</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
#### Simple examples
|
||||||
|
|
||||||
|
- name: Check if 2001::c0a8:6301:1 is a valid IPv6 teredo address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '2001::c0a8:6301:1' is ansible.utils.ipv6_teredo }}"
|
||||||
|
|
||||||
|
# TASK [Check if 2001::c0a8:6301:1 is a valid IPv6 teredo address] ********************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if 2002::c0a8:6301:1 is not a valid IPv6 teredo address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '2002::c0a8:6301:1' is not ansible.utils.ipv6_teredo }}"
|
||||||
|
|
||||||
|
# TASK [Check if 2002::c0a8:6301:1 is not a valid IPv6 teredo address] ****************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if hello_world is not a valid IPv6 teredo address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ 'hello_world' is not ansible.utils.ipv6_teredo }}"
|
||||||
|
|
||||||
|
# TASK [Check if hello_world is not a valid IPv6 teredo address] **********************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Return Values
|
||||||
|
-------------
|
||||||
|
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this test:
|
||||||
|
|
||||||
|
.. raw:: html
|
||||||
|
|
||||||
|
<table border=0 cellpadding=0 class="documentation-table">
|
||||||
|
<tr>
|
||||||
|
<th colspan="1">Key</th>
|
||||||
|
<th>Returned</th>
|
||||||
|
<th width="100%">Description</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
||||||
|
<b>data</b>
|
||||||
|
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">-</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
<td>
|
||||||
|
<div>If jinja test satisfies plugin expression <code>true</code></div>
|
||||||
|
<div>If jinja test does not satisfy plugin expression <code>false</code></div>
|
||||||
|
<br/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br/><br/>
|
||||||
|
|
||||||
|
|
||||||
|
Status
|
||||||
|
------
|
||||||
|
|
||||||
|
|
||||||
|
Authors
|
||||||
|
~~~~~~~
|
||||||
|
|
||||||
|
- Priyam Sahoo (@priyamsahoo)
|
||||||
|
|
||||||
|
|
||||||
|
.. hint::
|
||||||
|
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.
|
|
@ -0,0 +1,150 @@
|
||||||
|
.. _ansible.utils.ipv6_test:
|
||||||
|
|
||||||
|
|
||||||
|
******************
|
||||||
|
ansible.utils.ipv6
|
||||||
|
******************
|
||||||
|
|
||||||
|
**Test if something is an IPv6 address or network**
|
||||||
|
|
||||||
|
|
||||||
|
Version added: 2.2.0
|
||||||
|
|
||||||
|
.. contents::
|
||||||
|
:local:
|
||||||
|
:depth: 1
|
||||||
|
|
||||||
|
|
||||||
|
Synopsis
|
||||||
|
--------
|
||||||
|
- This plugin checks if the provided value is a valid host or network IP address with IPv6 addressing scheme
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
|
||||||
|
.. raw:: html
|
||||||
|
|
||||||
|
<table border=0 cellpadding=0 class="documentation-table">
|
||||||
|
<tr>
|
||||||
|
<th colspan="1">Parameter</th>
|
||||||
|
<th>Choices/<font color="blue">Defaults</font></th>
|
||||||
|
<th>Configuration</th>
|
||||||
|
<th width="100%">Comments</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>ip</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
/ <span style="color: red">required</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>A string that represents the value against which the test is going to be performed</div>
|
||||||
|
<div>{'For example': ['10.1.1.1', '10.0.0.0/8', 'fe80::216:3eff:fee4:16f3']}</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
#### Simple examples
|
||||||
|
|
||||||
|
- name: Check if fe80::216:3eff:fee4:16f3 is a valid IPv6 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ 'fe80::216:3eff:fee4:16f3' is ansible.utils.ipv6 }}"
|
||||||
|
|
||||||
|
# TASK [Check if fe80::216:3eff:fee4:16f3 is a valid IPv6 address] *************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if 2001:db8:a::/64 is a valid IPv6 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '2001:db8:a::/64' is ansible.utils.ipv6 }}"
|
||||||
|
|
||||||
|
# TASK [Check if 2001:db8:a::/64 is a valid IPv6 address] **********************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if 192.169.1.250 is not a valid IPv6 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '192.169.1.250' is not ansible.utils.ipv6 }}"
|
||||||
|
|
||||||
|
# TASK [Check if 192.169.1.250 is not a valid IPv6 address] ********************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Return Values
|
||||||
|
-------------
|
||||||
|
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this test:
|
||||||
|
|
||||||
|
.. raw:: html
|
||||||
|
|
||||||
|
<table border=0 cellpadding=0 class="documentation-table">
|
||||||
|
<tr>
|
||||||
|
<th colspan="1">Key</th>
|
||||||
|
<th>Returned</th>
|
||||||
|
<th width="100%">Description</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
||||||
|
<b>data</b>
|
||||||
|
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">-</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
<td>
|
||||||
|
<div>If jinja test satisfies plugin expression <code>true</code></div>
|
||||||
|
<div>If jinja test does not satisfy plugin expression <code>false</code></div>
|
||||||
|
<br/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br/><br/>
|
||||||
|
|
||||||
|
|
||||||
|
Status
|
||||||
|
------
|
||||||
|
|
||||||
|
|
||||||
|
Authors
|
||||||
|
~~~~~~~
|
||||||
|
|
||||||
|
- Priyam Sahoo (@priyamsahoo)
|
||||||
|
|
||||||
|
|
||||||
|
.. hint::
|
||||||
|
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.
|
|
@ -0,0 +1,108 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2021 Red Hat
|
||||||
|
# GNU General Public License v3.0+
|
||||||
|
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Test plugin file for netaddr tests: ipv6
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
from ansible_collections.ansible.utils.plugins.plugin_utils.base.ipaddress_utils import (
|
||||||
|
ip_network,
|
||||||
|
_need_ipaddress,
|
||||||
|
_validate_args,
|
||||||
|
)
|
||||||
|
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
DOCUMENTATION = """
|
||||||
|
name: ipv6
|
||||||
|
author: Priyam Sahoo (@priyamsahoo)
|
||||||
|
version_added: "2.2.0"
|
||||||
|
short_description: Test if something is an IPv6 address or network
|
||||||
|
description:
|
||||||
|
- This plugin checks if the provided value is a valid host or network IP address with IPv6 addressing scheme
|
||||||
|
options:
|
||||||
|
ip:
|
||||||
|
description:
|
||||||
|
- A string that represents the value against which the test is going to be performed
|
||||||
|
- For example:
|
||||||
|
- "10.1.1.1"
|
||||||
|
- "10.0.0.0/8"
|
||||||
|
- "fe80::216:3eff:fee4:16f3"
|
||||||
|
type: str
|
||||||
|
required: True
|
||||||
|
notes:
|
||||||
|
"""
|
||||||
|
|
||||||
|
EXAMPLES = r"""
|
||||||
|
|
||||||
|
#### Simple examples
|
||||||
|
|
||||||
|
- name: Check if fe80::216:3eff:fee4:16f3 is a valid IPv6 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ 'fe80::216:3eff:fee4:16f3' is ansible.utils.ipv6 }}"
|
||||||
|
|
||||||
|
# TASK [Check if fe80::216:3eff:fee4:16f3 is a valid IPv6 address] *************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if 2001:db8:a::/64 is a valid IPv6 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '2001:db8:a::/64' is ansible.utils.ipv6 }}"
|
||||||
|
|
||||||
|
# TASK [Check if 2001:db8:a::/64 is a valid IPv6 address] **********************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if 192.169.1.250 is not a valid IPv6 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '192.169.1.250' is not ansible.utils.ipv6 }}"
|
||||||
|
|
||||||
|
# TASK [Check if 192.169.1.250 is not a valid IPv6 address] ********************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
RETURN = """
|
||||||
|
data:
|
||||||
|
description:
|
||||||
|
- If jinja test satisfies plugin expression C(true)
|
||||||
|
- If jinja test does not satisfy plugin expression C(false)
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@_need_ipaddress
|
||||||
|
def _ipv6(ip):
|
||||||
|
"""Test if something in an IPv6 address or network"""
|
||||||
|
|
||||||
|
params = {"ip": ip}
|
||||||
|
_validate_args("ipv6", DOCUMENTATION, params)
|
||||||
|
|
||||||
|
try:
|
||||||
|
return ip_network(ip).version == 6
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
class TestModule(object):
|
||||||
|
""" network jinja test"""
|
||||||
|
|
||||||
|
test_map = {"ipv6": _ipv6}
|
||||||
|
|
||||||
|
def tests(self):
|
||||||
|
return self.test_map
|
|
@ -0,0 +1,108 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2021 Red Hat
|
||||||
|
# GNU General Public License v3.0+
|
||||||
|
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Test plugin file for netaddr tests: ipv6_address
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
from ansible_collections.ansible.utils.plugins.plugin_utils.base.ipaddress_utils import (
|
||||||
|
ip_address,
|
||||||
|
_need_ipaddress,
|
||||||
|
_validate_args,
|
||||||
|
)
|
||||||
|
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
DOCUMENTATION = """
|
||||||
|
name: ipv6_address
|
||||||
|
author: Priyam Sahoo (@priyamsahoo)
|
||||||
|
version_added: "2.2.0"
|
||||||
|
short_description: Test if something is an IPv6 address
|
||||||
|
description:
|
||||||
|
- This plugin checks if the provided value is a valid host IP address with IPv6 addressing scheme
|
||||||
|
options:
|
||||||
|
ip:
|
||||||
|
description:
|
||||||
|
- A string that represents the value against which the test is going to be performed
|
||||||
|
- For example:
|
||||||
|
- "10.1.1.1"
|
||||||
|
- "10.0.0.0/8"
|
||||||
|
- "fe80::216:3eff:fee4:16f3"
|
||||||
|
type: str
|
||||||
|
required: True
|
||||||
|
notes:
|
||||||
|
"""
|
||||||
|
|
||||||
|
EXAMPLES = r"""
|
||||||
|
|
||||||
|
#### Simple examples
|
||||||
|
|
||||||
|
- name: Check if fe80::216:3eff:fee4:16f3 is a valid IPv6 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ 'fe80::216:3eff:fee4:16f3' is ansible.utils.ipv6_address }}"
|
||||||
|
|
||||||
|
# TASK [Check if fe80::216:3eff:fee4:16f3 is a valid IPv6 address] *********************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if 2001:db8:a::123/64 is not a valid IPv6 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '2001:db8:a::123/64' is not ansible.utils.ipv6_address }}"
|
||||||
|
|
||||||
|
# TASK [Check if 2001:db8:a::123/64 is not a valid IPv6 address] ***********************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if 192.169.1.250 is not a valid IPv6 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '192.169.1.250' is not ansible.utils.ipv6_address }}"
|
||||||
|
|
||||||
|
# TASK [Check if 192.169.1.250 is not a valid IPv6 address] ****************************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
RETURN = """
|
||||||
|
data:
|
||||||
|
description:
|
||||||
|
- If jinja test satisfies plugin expression C(true)
|
||||||
|
- If jinja test does not satisfy plugin expression C(false)
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@_need_ipaddress
|
||||||
|
def _ipv6_address(ip):
|
||||||
|
"""Test if something in an IPv6 address"""
|
||||||
|
|
||||||
|
params = {"ip": ip}
|
||||||
|
_validate_args("ipv6_address", DOCUMENTATION, params)
|
||||||
|
|
||||||
|
try:
|
||||||
|
return ip_address(ip).version == 6
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
class TestModule(object):
|
||||||
|
""" network jinja test"""
|
||||||
|
|
||||||
|
test_map = {"ipv6_address": _ipv6_address}
|
||||||
|
|
||||||
|
def tests(self):
|
||||||
|
return self.test_map
|
|
@ -0,0 +1,110 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2021 Red Hat
|
||||||
|
# GNU General Public License v3.0+
|
||||||
|
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Test plugin file for netaddr tests: ipv6_ipv4_mapped
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
from ansible_collections.ansible.utils.plugins.plugin_utils.base.ipaddress_utils import (
|
||||||
|
ip_address,
|
||||||
|
_need_ipaddress,
|
||||||
|
_validate_args,
|
||||||
|
)
|
||||||
|
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
DOCUMENTATION = """
|
||||||
|
name: ipv6_ipv4_mapped
|
||||||
|
author: Priyam Sahoo (@priyamsahoo)
|
||||||
|
version_added: "2.2.0"
|
||||||
|
short_description: Test if something appears to be a mapped IPv6 to IPv4 mapped address
|
||||||
|
description:
|
||||||
|
- This plugin checks if the provided value is a valid IPv4-mapped IPv6 address
|
||||||
|
options:
|
||||||
|
ip:
|
||||||
|
description:
|
||||||
|
- A string that represents the value against which the test is going to be performed
|
||||||
|
- For example:
|
||||||
|
- "::FFFF:10.1.1.1"
|
||||||
|
- "::AAAA:10.1.1.1"
|
||||||
|
- "helloworld"
|
||||||
|
type: str
|
||||||
|
required: True
|
||||||
|
notes:
|
||||||
|
"""
|
||||||
|
|
||||||
|
EXAMPLES = r"""
|
||||||
|
|
||||||
|
#### Simple examples
|
||||||
|
|
||||||
|
- name: Check if ::FFFF:10.1.1.1 is a valid IPv4-mapped IPv6 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '::FFFF:10.1.1.1' is ansible.utils.ipv6_ipv4_mapped }}"
|
||||||
|
|
||||||
|
# TASK [Check if ::FFFF:10.1.1.1 is a valid IPv4-mapped IPv6 address] *************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if ::AAAA:10.1.1.1 is not a valid IPv4-mapped IPv6 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '::AAAA:10.1.1.1' is not ansible.utils.ipv6_ipv4_mapped }}"
|
||||||
|
|
||||||
|
# TASK [Check if ::AAAA:10.1.1.1 is not a valid IPv4-mapped IPv6 address] ******************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if helloworld is not a valid IPv4-mapped IPv6 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ 'helloworld' is not ansible.utils.ipv6_ipv4_mapped }}"
|
||||||
|
|
||||||
|
# TASK [Check if helloworld is not a valid IPv4-mapped IPv6 address] ***********************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
RETURN = """
|
||||||
|
data:
|
||||||
|
description:
|
||||||
|
- If jinja test satisfies plugin expression C(true)
|
||||||
|
- If jinja test does not satisfy plugin expression C(false)
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@_need_ipaddress
|
||||||
|
def _ipv6_ipv4_mapped(ip):
|
||||||
|
""" Test if something appears to be a mapped IPv6 to IPv4 mapped address """
|
||||||
|
|
||||||
|
params = {"ip": ip}
|
||||||
|
_validate_args("ipv6_ipv4_mapped", DOCUMENTATION, params)
|
||||||
|
|
||||||
|
try:
|
||||||
|
if ip_address(ip).ipv4_mapped is None:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
class TestModule(object):
|
||||||
|
""" network jinja test"""
|
||||||
|
|
||||||
|
test_map = {"ipv6_ipv4_mapped": _ipv6_ipv4_mapped}
|
||||||
|
|
||||||
|
def tests(self):
|
||||||
|
return self.test_map
|
|
@ -0,0 +1,110 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2021 Red Hat
|
||||||
|
# GNU General Public License v3.0+
|
||||||
|
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Test plugin file for netaddr tests: ipv6_sixtofour
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
from ansible_collections.ansible.utils.plugins.plugin_utils.base.ipaddress_utils import (
|
||||||
|
ip_address,
|
||||||
|
_need_ipaddress,
|
||||||
|
_validate_args,
|
||||||
|
)
|
||||||
|
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
DOCUMENTATION = """
|
||||||
|
name: ipv6_sixtofour
|
||||||
|
author: Priyam Sahoo (@priyamsahoo)
|
||||||
|
version_added: "2.2.0"
|
||||||
|
short_description: Test if something appears to be a 6to4 address
|
||||||
|
description:
|
||||||
|
- This plugin checks if the provided value is a valid 6to4 address
|
||||||
|
options:
|
||||||
|
ip:
|
||||||
|
description:
|
||||||
|
- A string that represents the value against which the test is going to be performed
|
||||||
|
- For example:
|
||||||
|
- "2002:c0a8:6301:1::1"
|
||||||
|
- "::AAAA:10.1.1.1"
|
||||||
|
- "hello_world"
|
||||||
|
type: str
|
||||||
|
required: True
|
||||||
|
notes:
|
||||||
|
"""
|
||||||
|
|
||||||
|
EXAMPLES = r"""
|
||||||
|
|
||||||
|
#### Simple examples
|
||||||
|
|
||||||
|
- name: Check if 2002:c0a8:6301:1::1 is a valid 6to4 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '2002:c0a8:6301:1::1' is ansible.utils.ipv6_sixtofour }}"
|
||||||
|
|
||||||
|
# TASK [Check if 2002:c0a8:6301:1::1 is a valid 6to4 address] ****************************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if 2001:c0a8:6301:1::1 is not a valid 6to4 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '2001:c0a8:6301:1::1' is not ansible.utils.ipv6_sixtofour }}"
|
||||||
|
|
||||||
|
# TASK [Check if 2001:c0a8:6301:1::1 is not a valid 6to4 address] ************************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if helloworld is not a valid 6to4 address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ 'helloworld' is not ansible.utils.ipv6_sixtofour }}"
|
||||||
|
|
||||||
|
# TASK [Check if helloworld is not a valid 6to4 address] *********************************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
RETURN = """
|
||||||
|
data:
|
||||||
|
description:
|
||||||
|
- If jinja test satisfies plugin expression C(true)
|
||||||
|
- If jinja test does not satisfy plugin expression C(false)
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@_need_ipaddress
|
||||||
|
def _ipv6_sixtofour(ip):
|
||||||
|
""" Test if something appears to be a 6to4 address """
|
||||||
|
|
||||||
|
params = {"ip": ip}
|
||||||
|
_validate_args("ipv6_sixtofour", DOCUMENTATION, params)
|
||||||
|
|
||||||
|
try:
|
||||||
|
if ip_address(ip).sixtofour is None:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
class TestModule(object):
|
||||||
|
""" network jinja test"""
|
||||||
|
|
||||||
|
test_map = {"ipv6_sixtofour": _ipv6_sixtofour}
|
||||||
|
|
||||||
|
def tests(self):
|
||||||
|
return self.test_map
|
|
@ -0,0 +1,110 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2021 Red Hat
|
||||||
|
# GNU General Public License v3.0+
|
||||||
|
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Test plugin file for netaddr tests: ipv6_teredo
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
from ansible_collections.ansible.utils.plugins.plugin_utils.base.ipaddress_utils import (
|
||||||
|
ip_address,
|
||||||
|
_need_ipaddress,
|
||||||
|
_validate_args,
|
||||||
|
)
|
||||||
|
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
DOCUMENTATION = """
|
||||||
|
name: ipv6_teredo
|
||||||
|
author: Priyam Sahoo (@priyamsahoo)
|
||||||
|
version_added: "2.2.0"
|
||||||
|
short_description: Test if something appears to be an IPv6 teredo address
|
||||||
|
description:
|
||||||
|
- This plugin checks if the provided value is a valid IPv6 teredo address
|
||||||
|
options:
|
||||||
|
ip:
|
||||||
|
description:
|
||||||
|
- A string that represents the value against which the test is going to be performed
|
||||||
|
- For example:
|
||||||
|
- "2001::c0a8:6301:1"
|
||||||
|
- "2002::c0a8:6301:1"
|
||||||
|
- "hello_world"
|
||||||
|
type: str
|
||||||
|
required: True
|
||||||
|
notes:
|
||||||
|
"""
|
||||||
|
|
||||||
|
EXAMPLES = r"""
|
||||||
|
|
||||||
|
#### Simple examples
|
||||||
|
|
||||||
|
- name: Check if 2001::c0a8:6301:1 is a valid IPv6 teredo address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '2001::c0a8:6301:1' is ansible.utils.ipv6_teredo }}"
|
||||||
|
|
||||||
|
# TASK [Check if 2001::c0a8:6301:1 is a valid IPv6 teredo address] ********************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if 2002::c0a8:6301:1 is not a valid IPv6 teredo address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ '2002::c0a8:6301:1' is not ansible.utils.ipv6_teredo }}"
|
||||||
|
|
||||||
|
# TASK [Check if 2002::c0a8:6301:1 is not a valid IPv6 teredo address] ****************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
- name: Check if hello_world is not a valid IPv6 teredo address
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
data: "{{ 'hello_world' is not ansible.utils.ipv6_teredo }}"
|
||||||
|
|
||||||
|
# TASK [Check if hello_world is not a valid IPv6 teredo address] **********************
|
||||||
|
# ok: [localhost] => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "data": true
|
||||||
|
# },
|
||||||
|
# "changed": false
|
||||||
|
# }
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
RETURN = """
|
||||||
|
data:
|
||||||
|
description:
|
||||||
|
- If jinja test satisfies plugin expression C(true)
|
||||||
|
- If jinja test does not satisfy plugin expression C(false)
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@_need_ipaddress
|
||||||
|
def _ipv6_teredo(ip):
|
||||||
|
""" Test if something is an IPv6 teredo address """
|
||||||
|
|
||||||
|
params = {"ip": ip}
|
||||||
|
_validate_args("ipv6_teredo", DOCUMENTATION, params)
|
||||||
|
|
||||||
|
try:
|
||||||
|
if ip_address(ip).teredo is None:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
class TestModule(object):
|
||||||
|
""" network jinja test"""
|
||||||
|
|
||||||
|
test_map = {"ipv6_teredo": _ipv6_teredo}
|
||||||
|
|
||||||
|
def tests(self):
|
||||||
|
return self.test_map
|
|
@ -0,0 +1,24 @@
|
||||||
|
---
|
||||||
|
- name: "ipv6: Check if fe80::216:3eff:fee4:16f3 is a valid IPV6 address"
|
||||||
|
assert:
|
||||||
|
that: "{{ 'fe80::216:3eff:fee4:16f3' is ansible.utils.ipv6 }}"
|
||||||
|
|
||||||
|
- name: "ipv6: Check if 2001:db8:a::/64 is a valid IPV6 address"
|
||||||
|
assert:
|
||||||
|
that: "{{ '2001:db8:a::/64' is ansible.utils.ipv6 }}"
|
||||||
|
|
||||||
|
- name: "ipv6: Test invalidness"
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
criteria_check1: "{{ '10.1.1.1' is ansible.utils.ipv6 }}"
|
||||||
|
|
||||||
|
- name: "ipv6: Assert invalidness"
|
||||||
|
assert:
|
||||||
|
that: "{{ criteria_check1 == false }}"
|
||||||
|
|
||||||
|
- name: "ipv6: Test invalidness"
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
criteria_check2: "{{ 'string' is ansible.utils.ipv6 }}"
|
||||||
|
|
||||||
|
- name: "ipv6: Assert invalidness"
|
||||||
|
assert:
|
||||||
|
that: "{{ criteria_check2 == false }}"
|
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
- name: "ipv6_address: Check if fe80::216:3eff:fee4:16f3 is a valid IPV6 address"
|
||||||
|
assert:
|
||||||
|
that: "{{ 'fe80::216:3eff:fee4:16f3' is ansible.utils.ipv6_address }}"
|
||||||
|
|
||||||
|
- name: "ipv6_address: Test invalidness"
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
criteria_check1: "{{ '2001:db8:a::123/64' is ansible.utils.ipv6_address }}"
|
||||||
|
|
||||||
|
- name: "ipv6_address: Assert invalidness"
|
||||||
|
assert:
|
||||||
|
that: "{{ criteria_check1 == false }}"
|
||||||
|
|
||||||
|
- name: "ipv6_address: Test invalidness"
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
criteria_check2: "{{ '192.168.1.250' is ansible.utils.ipv6_address }}"
|
||||||
|
|
||||||
|
- name: "ipv6_address: Assert invalidness"
|
||||||
|
assert:
|
||||||
|
that: "{{ criteria_check2 == false }}"
|
||||||
|
|
||||||
|
- name: "ipv6_address: Test invalidness"
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
criteria_check3: "{{ 'string' is ansible.utils.ipv6_address }}"
|
||||||
|
|
||||||
|
- name: "ipv6_address: Assert invalidness"
|
||||||
|
assert:
|
||||||
|
that: "{{ criteria_check3 == false }}"
|
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
- name: "ipv6_ipv4_mapped: Check if ::FFFF:10.1.1.1 is a valid IPv4-mapped IPv6 address"
|
||||||
|
assert:
|
||||||
|
that: "{{ '::FFFF:10.1.1.1' is ansible.utils.ipv6_ipv4_mapped }}"
|
||||||
|
|
||||||
|
- name: "ipv6_ipv4_mapped: Test invalidness"
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
criteria_check1: "{{ '::AAAA:10.1.1.1' is ansible.utils.ipv6_ipv4_mapped }}"
|
||||||
|
|
||||||
|
- name: "ipv6_ipv4_mapped: Assert invalidness"
|
||||||
|
assert:
|
||||||
|
that: "{{ criteria_check1 == false }}"
|
||||||
|
|
||||||
|
- name: "ipv6_ipv4_mapped: Test invalidness"
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
criteria_check2: "{{ 'hello-world' is ansible.utils.ipv6_ipv4_mapped }}"
|
||||||
|
|
||||||
|
- name: "ipv6_ipv4_mapped: Assert invalidness"
|
||||||
|
assert:
|
||||||
|
that: "{{ criteria_check2 == false }}"
|
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
- name: "ipv6_sixtofour: Check if 2002:c0a8:6301:1::1 is a valid 6to4 address"
|
||||||
|
assert:
|
||||||
|
that: "{{ '2002:c0a8:6301:1::1' is ansible.utils.ipv6_sixtofour }}"
|
||||||
|
|
||||||
|
- name: "ipv6_sixtofour: Test invalidness"
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
criteria_check1: "{{ '2001:c0a8:6301:1::1' is ansible.utils.ipv6_sixtofour }}"
|
||||||
|
|
||||||
|
- name: "ipv6_sixtofour: Assert invalidness"
|
||||||
|
assert:
|
||||||
|
that: "{{ criteria_check1 == false }}"
|
||||||
|
|
||||||
|
- name: "ipv6_sixtofour: Test invalidness"
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
criteria_check2: "{{ 'helloworld' is ansible.utils.ipv6_sixtofour }}"
|
||||||
|
|
||||||
|
- name: "ipv6_sixtofour: Assert invalidness"
|
||||||
|
assert:
|
||||||
|
that: "{{ criteria_check2 == false }}"
|
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
- name: "ipv6_teredo: Check if 2001::c0a8:6301:1 is a valid 6to4 address"
|
||||||
|
assert:
|
||||||
|
that: "{{ '2001::c0a8:6301:1' is ansible.utils.ipv6_teredo }}"
|
||||||
|
|
||||||
|
- name: "ipv6_teredo: Test invalidness"
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
criteria_check1: "{{ '2002::c0a8:6301:1' is ansible.utils.ipv6_teredo }}"
|
||||||
|
|
||||||
|
- name: "ipv6_teredo: Assert invalidness"
|
||||||
|
assert:
|
||||||
|
that: "{{ criteria_check1 == false }}"
|
||||||
|
|
||||||
|
- name: "ipv6_teredo: Test invalidness"
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
criteria_check2: "{{ 'helloworld' is ansible.utils.ipv6_teredo }}"
|
||||||
|
|
||||||
|
- name: "ipv6_teredo: Assert invalidness"
|
||||||
|
assert:
|
||||||
|
that: "{{ criteria_check2 == false }}"
|
|
@ -0,0 +1,43 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2021 Red Hat
|
||||||
|
# GNU General Public License v3.0+
|
||||||
|
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Unit test file for netaddr test plugin: ipv6
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
from ansible_collections.ansible.utils.plugins.test.ipv6 import _ipv6
|
||||||
|
|
||||||
|
|
||||||
|
class TestIpV6(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_invalid_data(self):
|
||||||
|
"""Check passing invalid argspec"""
|
||||||
|
|
||||||
|
# missing argument
|
||||||
|
with self.assertRaises(TypeError) as error:
|
||||||
|
_ipv6()
|
||||||
|
self.assertIn("argument", str(error.exception))
|
||||||
|
|
||||||
|
def test_valid_data(self):
|
||||||
|
"""Check passing valid data as per criteria"""
|
||||||
|
|
||||||
|
result = _ipv6(ip="fe80::216:3eff:fee4:16f3")
|
||||||
|
self.assertEqual(result, True)
|
||||||
|
|
||||||
|
result = _ipv6(ip="2001:db8:a::/64")
|
||||||
|
self.assertEqual(result, True)
|
||||||
|
|
||||||
|
result = _ipv6(ip="10.1.1.1")
|
||||||
|
self.assertEqual(result, False)
|
||||||
|
|
||||||
|
result = _ipv6(ip="string")
|
||||||
|
self.assertEqual(result, False)
|
|
@ -0,0 +1,45 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2021 Red Hat
|
||||||
|
# GNU General Public License v3.0+
|
||||||
|
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Unit test file for netaddr test plugin: ipv6_address
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
from ansible_collections.ansible.utils.plugins.test.ipv6_address import (
|
||||||
|
_ipv6_address,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestIpV6Address(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_invalid_data(self):
|
||||||
|
"""Check passing invalid argspec"""
|
||||||
|
|
||||||
|
# missing argument
|
||||||
|
with self.assertRaises(TypeError) as error:
|
||||||
|
_ipv6_address()
|
||||||
|
self.assertIn("argument", str(error.exception))
|
||||||
|
|
||||||
|
def test_valid_data(self):
|
||||||
|
"""Check passing valid data as per criteria"""
|
||||||
|
|
||||||
|
result = _ipv6_address(ip="fe80::216:3eff:fee4:16f3")
|
||||||
|
self.assertEqual(result, True)
|
||||||
|
|
||||||
|
result = _ipv6_address(ip="2001:db8:a::/64")
|
||||||
|
self.assertEqual(result, False)
|
||||||
|
|
||||||
|
result = _ipv6_address(ip="10.1.1.1")
|
||||||
|
self.assertEqual(result, False)
|
||||||
|
|
||||||
|
result = _ipv6_address(ip="string")
|
||||||
|
self.assertEqual(result, False)
|
|
@ -0,0 +1,42 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2021 Red Hat
|
||||||
|
# GNU General Public License v3.0+
|
||||||
|
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Unit test file for netaddr test plugin: ipv6_ipv4_mapped
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
from ansible_collections.ansible.utils.plugins.test.ipv6_ipv4_mapped import (
|
||||||
|
_ipv6_ipv4_mapped,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestIpV6IpV4Mapped(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_invalid_data(self):
|
||||||
|
"""Check passing invalid argspec"""
|
||||||
|
|
||||||
|
# missing argument
|
||||||
|
with self.assertRaises(TypeError) as error:
|
||||||
|
_ipv6_ipv4_mapped()
|
||||||
|
self.assertIn("argument", str(error.exception))
|
||||||
|
|
||||||
|
def test_valid_data(self):
|
||||||
|
"""Check passing valid data as per criteria"""
|
||||||
|
|
||||||
|
result = _ipv6_ipv4_mapped(ip="::FFFF:10.1.1.1")
|
||||||
|
self.assertEqual(result, True)
|
||||||
|
|
||||||
|
result = _ipv6_ipv4_mapped(ip="::AAAA:10.1.1.1")
|
||||||
|
self.assertEqual(result, False)
|
||||||
|
|
||||||
|
result = _ipv6_ipv4_mapped(ip="string")
|
||||||
|
self.assertEqual(result, False)
|
|
@ -0,0 +1,42 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2021 Red Hat
|
||||||
|
# GNU General Public License v3.0+
|
||||||
|
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Unit test file for netaddr test plugin: ipv6_sixtofour
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
from ansible_collections.ansible.utils.plugins.test.ipv6_sixtofour import (
|
||||||
|
_ipv6_sixtofour,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestIpV6SixToFour(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_invalid_data(self):
|
||||||
|
"""Check passing invalid argspec"""
|
||||||
|
|
||||||
|
# missing argument
|
||||||
|
with self.assertRaises(TypeError) as error:
|
||||||
|
_ipv6_sixtofour()
|
||||||
|
self.assertIn("argument", str(error.exception))
|
||||||
|
|
||||||
|
def test_valid_data(self):
|
||||||
|
"""Check passing valid data as per criteria"""
|
||||||
|
|
||||||
|
result = _ipv6_sixtofour(ip="2002:c0a8:6301:1::1")
|
||||||
|
self.assertEqual(result, True)
|
||||||
|
|
||||||
|
result = _ipv6_sixtofour(ip="2001:c0a8:6301:1::1")
|
||||||
|
self.assertEqual(result, False)
|
||||||
|
|
||||||
|
result = _ipv6_sixtofour(ip="string")
|
||||||
|
self.assertEqual(result, False)
|
|
@ -0,0 +1,42 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2021 Red Hat
|
||||||
|
# GNU General Public License v3.0+
|
||||||
|
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Unit test file for netaddr test plugin: ipv6_teredo
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
from ansible_collections.ansible.utils.plugins.test.ipv6_teredo import (
|
||||||
|
_ipv6_teredo,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestIpV6Teredo(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_invalid_data(self):
|
||||||
|
"""Check passing invalid argspec"""
|
||||||
|
|
||||||
|
# missing argument
|
||||||
|
with self.assertRaises(TypeError) as error:
|
||||||
|
_ipv6_teredo()
|
||||||
|
self.assertIn("argument", str(error.exception))
|
||||||
|
|
||||||
|
def test_valid_data(self):
|
||||||
|
"""Check passing valid data as per criteria"""
|
||||||
|
|
||||||
|
result = _ipv6_teredo(ip="2001::c0a8:6301:1")
|
||||||
|
self.assertEqual(result, True)
|
||||||
|
|
||||||
|
result = _ipv6_teredo(ip="2002::c0a8:6301:1")
|
||||||
|
self.assertEqual(result, False)
|
||||||
|
|
||||||
|
result = _ipv6_teredo(ip="string")
|
||||||
|
self.assertEqual(result, False)
|
Loading…
Reference in New Issue