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

Refactor: Deprecate hash_passphrase filter in favor of snmp_hash #3470

Merged
merged 4 commits into from
Jan 8, 2024

Conversation

gmuloc
Copy link
Contributor

@gmuloc gmuloc commented Jan 4, 2024

Change Summary

  • Redirect to and deprecate the arista.avd.hash_passphrase in favor of arista.avd.snmp_hash. Both will still work until AVD 5.0.0
  • Fix space display issue for plugin documentaiton

Related Issue(s)

Fixes #3468

Component(s) name

plugins

Proposed changes

Following the documentation here: https://docs.ansible.com/ansible/latest/dev_guide/module_lifecycle.html#renaming-a-module-or-plugin-in-a-collection-or-redirecting-a-module-or-plugin-to-another-collection

How to test

You can run ansible-doc -t filter arista.avd.hash_passphrase to see the deprecation warning lke:

user@server $ ANSIBLE_COLLECTIONS_PATH=~/Github/ansible-avd ansible-doc -t filter arista.avd.hash_passphrase 
[DEPRECATION WARNING]: arista.avd.hash_passphrase has been deprecated. Use arista.avd.snmp_hash instead. This feature will be removed from arista.avd in version 5.0.0. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
> ARISTA.AVD.SNMP_HASH    (/Users/ninja/Github/ansible-avd/ansible_collections/arista/avd/plugins/filter/snmp_hash.py)
[...]

Checklist

User Checklist

  • N/A

Repository Checklist

  • My code has been rebased from devel before I start
  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation and documentation have been updated accordingly.
  • I have updated molecule CI testing accordingly. (check the box if not applicable)

@gmuloc gmuloc requested review from a team as code owners January 4, 2024 14:28
@github-actions github-actions bot added the type: documentation Improvements or additions to documentation label Jan 4, 2024
@ClausHolbechArista ClausHolbechArista requested a review from a team January 5, 2024 13:00
@ClausHolbechArista ClausHolbechArista added the one approval This PR has one approval and is only missing one more. label Jan 5, 2024
@noredistribution
Copy link
Contributor

tested now, the documentation looks better now!
but the playbook is now failing for both the old and the new filter name

for arista.avd.snmp_hash I'm getting:

  msg: 'template error while templating string: Could not load "arista.avd.snmp_hash": ''arista.avd.snmp_hash''. 
  String: {{ _input | arista.avd.snmp_hash }}. Could not load "arista.avd.snmp_hash": ''arista.avd.snmp_hash''

for arista.avd.hash_passphrase I'm getting:

[DEPRECATION WARNING]: Use arista.avd.snmp_hash instead. This feature will be
removed from arista.avd in version 5.0.0. Deprecation warnings can be disabled
by setting deprecation_warnings=False in ansible.cfg.
fatal: [tp-avd-leaf2]: FAILED! =>
 msg: 'template error while templating string: Could not load "arista.avd.hash_passphrase": ''arista.avd.hash_passphrase''. String: {{ _input | arista.avd.hash_passphrase }}. Could not load "arista.avd.hash_passphrase": ''arista.avd.hash_passphrase'''

don't we need to update https://github.com/aristanetworks/ansible-avd/blob/devel/ansible_collections/arista/avd/plugins/filter/snmp_hash.py#L153-L172 as well?

@gmuloc
Copy link
Contributor Author

gmuloc commented Jan 5, 2024

Thanks @noredistribution - somehow one file did not make it. It is a wonder it was working ..
d62103f

@gmuloc
Copy link
Contributor Author

gmuloc commented Jan 5, 2024

Tested with

- name: calculate snmp passphrase
  hosts: localhost
  connection: local
  gather_facts: no
  vars:
    _input:
      passphrase: arista
      auth: sha256
      engine_id: "424242424242424242"

  tasks:
    - name: "compute passphrase1"
      tags: [snmp]
      debug:
        msg: "{{ _input }}"
    - name: "compute passphrase"
      tags: [snmp]
      debug:
        msg: "{{ _input | arista.avd.hash_passphrase }}"
    - name: "compute passphrase"
      tags: [snmp]
      debug:
        msg: "{{ _input | arista.avd.snmp_hash }}"

output:

ANSIBLE_COLLECTIONS_PATH=~/Github/gmuloc/ansible-avd ansible-playbook /tmp/test.yml
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [calculate snmp passphrase] *************************************************************************************************************************************************************************************

TASK [compute passphrase1] *******************************************************************************************************************************************************************************************

ok: [localhost] => {
    "msg": {
        "auth": "sha256",
        "engine_id": "424242424242424242",
        "passphrase": "arista"
    }
}

TASK [compute passphrase] ********************************************************************************************************************************************************************************************
[DEPRECATION WARNING]: Use arista.avd.snmp_hash instead. This feature will be removed from arista.avd in version 5.0.0. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
ok: [localhost] => {
    "msg": "00ab677fe6ac4f664fdb6098ca4b915b7de215487cb7d50e2491131a10dbb415"
}

TASK [compute passphrase] ********************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "00ab677fe6ac4f664fdb6098ca4b915b7de215487cb7d50e2491131a10dbb415"
}

PLAY RECAP ***********************************************************************************************************************************************************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Copy link
Contributor

@noredistribution noredistribution left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@ankudinov ankudinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ClausHolbechArista ClausHolbechArista merged commit 98749b6 into aristanetworks:devel Jan 8, 2024
40 checks passed
@gmuloc gmuloc deleted the issue/3468 branch January 17, 2025 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
one approval This PR has one approval and is only missing one more. rn: Refactor type: documentation Improvements or additions to documentation type: Python filters
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug(eos_designs): name discrepancy for the snmp hash calculation filter
4 participants