Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segregate filter plugins #578

Merged
merged 38 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4015773
vlan expander saved
KB-perByte Aug 4, 2023
b1b06a0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 4, 2023
cf19cd0
add a trivial changelog
KB-perByte Aug 4, 2023
72fcf27
add a test considering it breaks others
KB-perByte Aug 4, 2023
33e6562
some more test fixes
KB-perByte Aug 4, 2023
f9abf6d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 4, 2023
0f4e1ca
vlan_parser fix
KB-perByte Aug 4, 2023
37024d2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 4, 2023
b38af8c
add parse_xml
KB-perByte Aug 8, 2023
25b20d6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 8, 2023
80a2662
Merge branch 'main' into vlan_expander
KB-perByte Aug 8, 2023
bfd6442
add type5_pw
KB-perByte Aug 8, 2023
4c837ca
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 8, 2023
f4be1d2
thy formalities
KB-perByte Aug 8, 2023
6d7ce91
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 8, 2023
be69a3e
add parse_cli_textfsm
KB-perByte Aug 8, 2023
515d687
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 8, 2023
f37409e
update parse_xml
KB-perByte Aug 9, 2023
b546f32
fix parse_xml
KB-perByte Aug 9, 2023
84f4b98
add parse_cli
KB-perByte Aug 9, 2023
b2c33b2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 9, 2023
7ebf840
fix doc and sanity
KB-perByte Aug 9, 2023
198aa4f
add hash_salt
KB-perByte Aug 9, 2023
d7e00e6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 9, 2023
3f47b4e
add test hash_salt
KB-perByte Aug 9, 2023
4a44981
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 9, 2023
2cb0638
add comp_type5
KB-perByte Aug 9, 2023
81d4b15
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 9, 2023
81151e4
fix Unit test
KB-perByte Aug 9, 2023
5cb3a7b
fix sanity
KB-perByte Aug 9, 2023
dcbca0b
update test to assert on skip
KB-perByte Aug 9, 2023
29d4d02
workflow fix
KB-perByte Aug 10, 2023
4f85f3d
add original authors
KB-perByte Aug 10, 2023
32d6784
update all docs
KB-perByte Aug 10, 2023
fd11a76
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 10, 2023
d5d40fd
Fix Filter errors
KB-perByte Aug 10, 2023
7dd52dc
generate docs
KB-perByte Aug 10, 2023
bcb2b74
update security issues
KB-perByte Aug 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- run: >-
python -c "assert set([
python -c "assert 'failure' not in
set([
'${{ needs.ansible-lint.result }}',
'${{ needs.changelog.result }}',
'${{ needs.sanity.result }}',
'${{ needs.unit-galaxy.result }}',
'${{ needs.unit-source.result }}'
]) == {'success'}"
])"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,6 @@ venv.bak/

# mypy
.mypy_cache/

# vs code configuration
.vscode/
22 changes: 8 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,15 @@ Name | Description
### Filter plugins
Name | Description
--- | ---
[ansible.netcommon.comp_type5](https://github.com/ansible-collections/ansible.netcommon/blob/main/docs/ansible.netcommon.comp_type5_filter.rst)|The comp_type5 filter plugin.
[ansible.netcommon.hash_salt](https://github.com/ansible-collections/ansible.netcommon/blob/main/docs/ansible.netcommon.hash_salt_filter.rst)|The hash_salt filter plugin.
[ansible.netcommon.parse_cli](https://github.com/ansible-collections/ansible.netcommon/blob/main/docs/ansible.netcommon.parse_cli_filter.rst)|parse_cli filter plugin.
[ansible.netcommon.parse_cli_textfsm](https://github.com/ansible-collections/ansible.netcommon/blob/main/docs/ansible.netcommon.parse_cli_textfsm_filter.rst)|parse_cli_textfsm filter plugin.
[ansible.netcommon.parse_xml](https://github.com/ansible-collections/ansible.netcommon/blob/main/docs/ansible.netcommon.parse_xml_filter.rst)|The parse_xml filter plugin.
[ansible.netcommon.pop_ace](https://github.com/ansible-collections/ansible.netcommon/blob/main/docs/ansible.netcommon.pop_ace_filter.rst)|Remove ace entries from a acl source of truth.

### Network filter plugins
Filters for working with output from network devices

Name | Description
--- | ---
ansible.netcommon.comp_type5|ansible.netcommon comp_type5 filter plugin
ansible.netcommon.hash_salt|ansible.netcommon hash_salt filter plugin
ansible.netcommon.parse_cli|ansible.netcommon parse_cli filter plugin
ansible.netcommon.parse_cli_textfsm|ansible.netcommon parse_cli_textfsm filter plugin
ansible.netcommon.parse_xml|ansible.netcommon parse_xml filter plugin
ansible.netcommon.type5_pw|ansible.netcommon type5_pw filter plugin
ansible.netcommon.vlan_expander|ansible.netcommon vlan_expander filter plugin
ansible.netcommon.vlan_parser|Input: Unsorted list of vlan integers
[ansible.netcommon.type5_pw](https://github.com/ansible-collections/ansible.netcommon/blob/main/docs/ansible.netcommon.type5_pw_filter.rst)|The type5_pw filter plugin.
[ansible.netcommon.vlan_expander](https://github.com/ansible-collections/ansible.netcommon/blob/main/docs/ansible.netcommon.vlan_expander_filter.rst)|The vlan_expander filter plugin.
[ansible.netcommon.vlan_parser](https://github.com/ansible-collections/ansible.netcommon/blob/main/docs/ansible.netcommon.vlan_parser_filter.rst)|The vlan_parser filter plugin.

### Httpapi plugins
Name | Description
Expand Down
10 changes: 10 additions & 0 deletions changelogs/fragments/vlan_extender.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
trivial:
- vlan_expander - Filter plugin updated as individual plugin.
- vlan_parser - Filter plugin updated as individual plugin.
- type5_pw - Filter plugin updated as individual plugin.
- parse_xml - Filter plugin updated as individual plugin.
- comp_type5 - Filter plugin updated as individual plugin.
- hash_salt - Filter plugin updated as individual plugin.
- parse_cli - Filter plugin updated as individual plugin.
- parse_cli_textfsm - Filter plugin updated as individual plugin.
152 changes: 152 additions & 0 deletions docs/ansible.netcommon.comp_type5_filter.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
.. _ansible.netcommon.comp_type5_filter:


****************************
ansible.netcommon.comp_type5
****************************

**The comp_type5 filter plugin.**


Version added: 1.0.0

.. contents::
:local:
:depth: 1


Synopsis
--------
- The filter confirms configuration idempotency on use of type5_pw.




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>encrypted_password</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>The encrypted text.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>return_original</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>no</li>
<li>yes</li>
</ul>
</td>
<td>
</td>
<td>
<div>Return the original text.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>unencrypted_password</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>The unencrypted text.</div>
</td>
</tr>
</table>
<br/>


Notes
-----

.. note::
- The filter confirms configuration idempotency on use of type5_pw.
- Can be used to validate password post hashing username cisco secret 5 {{ ansible_ssh_pass | ansible.netcommon.comp_type5(encrypted, True) }}



Examples
--------

.. code-block:: yaml

# Using comp_type5

# playbook

- name: Set the facts
ansible.builtin.set_fact:
unencrypted_password: "cisco@123"
encrypted_password: "$1$avs$uSTOEMh65qzvpb9yBMpzd/"

- name: Invoke comp_type5
ansible.builtin.debug:
msg: "{{ unencrypted_password | ansible.netcommon.comp_type5(encrypted_password, False) }}"

# Task Output
# -----------
#
# TASK [Set the facts]
# ok: [35.155.113.92] => changed=false
# ansible_facts:
# encrypted_password: $1$avs$uSTOEMh65qzvpb9yBMpzd/
# unencrypted_password: cisco@123

# TASK [Invoke comp_type5]
# ok: [35.155.113.92] =>
# msg: true




Status
------


Authors
~~~~~~~

- Ken Celenza (@itdependsnetworks)


.. 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.
113 changes: 113 additions & 0 deletions docs/ansible.netcommon.hash_salt_filter.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
.. _ansible.netcommon.hash_salt_filter:


***************************
ansible.netcommon.hash_salt
***************************

**The hash_salt filter plugin.**


Version added: 1.0.0

.. contents::
:local:
:depth: 1


Synopsis
--------
- The filter plugin produces the salt from a hashed password.
- Using the parameters below - ``password | ansible.netcommon.hash_salt(template.yml``)




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>password</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>This source data on which hash_salt invokes.</div>
<div>For example <code>password | ansible.netcommon.hash_salt</code>, in this case <code>password</code> represents the hashed password.</div>
</td>
</tr>
</table>
<br/>


Notes
-----

.. note::
- The filter plugin produces the salt from a hashed password.



Examples
--------

.. code-block:: yaml

# Using hash_salt

# playbook

- name: Set the facts
ansible.builtin.set_fact:
password: "$1$avs$uSTOEMh65qzvpb9yBMpzd/"

- name: Invoke hash_salt
ansible.builtin.debug:
msg: "{{ password | ansible.netcommon.hash_salt() }}"


# Task Output
# -----------
#
# TASK [Set the facts]
# ok: [host] => changed=false
# ansible_facts:
# password: $1$avs$uSTOEMh65qzvpb9yBMpzd/

# TASK [Invoke hash_salt]
# ok: [host] =>
# msg: avs




Status
------


Authors
~~~~~~~

- Ken Celenza (@itdependsnetworks)


.. 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.
Loading
Loading