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

nclu: fix 'net pending' delimiter string, and exec commit only if changed #219

Merged
merged 8 commits into from
Mar 9, 2021

Conversation

kakkotetsu
Copy link
Contributor

SUMMARY
  • mod nclu module
    • fixed net pending 's delimiter string
      • checked version : 3.7.3, 4.0.0, 4.2.1, 4.3.0
    • execute net commit description <description> only if changed net pending's diff field.
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

nclu

ADDITIONAL INFORMATION

@felixfontein
Copy link
Collaborator

Could you please add a changelog fragment?

@felixfontein
Copy link
Collaborator

Closing and reopening to restart tests (no idea why that one was cancelled, this should fix it :) ).

@dericcrago
Copy link
Contributor

Hi @kakkotetsu, thank you for the fix! What do you think about handling both cases of quotes? Maybe something like this dericcrago@259159d ?

@kakkotetsu
Copy link
Contributor Author

kakkotetsu commented Mar 9, 2021

Thanks for review it. It looks good to me!
I don't know of any version that uses single cotation, but it would be better to match both.

switched to 're' to handle both cases of quotes
Copy link
Contributor

@dericcrago dericcrago left a comment

Choose a reason for hiding this comment

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

thanks @kakkotetsu!

@dericcrago dericcrago merged commit 5e2cd88 into ansible-collections:main Mar 9, 2021
@kakkotetsu kakkotetsu deleted the fix-nclu-pending branch March 9, 2021 04:18
@felixfontein
Copy link
Collaborator

@dericcrago btw, you need to add the backport-2 label so this gets backported to stable-2, otherwise it won't be included in any 2.x.y release. (In case this should also go into the stable-1 branch, it also needs the backport-1 label.)

patchback bot pushed a commit that referenced this pull request Mar 9, 2021
…nged (#219)

* fix 'net pendig''s delimiter string

* test for #219

* test for #219

* add changelog fragment for #219

* Update changelogs/fragments/219-nclu-fix-pending.yaml

Co-authored-by: Felix Fontein <[email protected]>

* Update changelogs/fragments/219-nclu-fix-pending.yaml

Co-authored-by: Felix Fontein <[email protected]>

* switched to 're' to handle both cases of quotes

Co-authored-by: Felix Fontein <[email protected]>
Co-authored-by: Deric Crago <[email protected]>
(cherry picked from commit 5e2cd88)
dericcrago pushed a commit that referenced this pull request Mar 10, 2021
…nged (#219) (#220)

* fix 'net pendig''s delimiter string

* test for #219

* test for #219

* add changelog fragment for #219

* Update changelogs/fragments/219-nclu-fix-pending.yaml

Co-authored-by: Felix Fontein <[email protected]>

* Update changelogs/fragments/219-nclu-fix-pending.yaml

Co-authored-by: Felix Fontein <[email protected]>

* switched to 're' to handle both cases of quotes

Co-authored-by: Felix Fontein <[email protected]>
Co-authored-by: Deric Crago <[email protected]>
(cherry picked from commit 5e2cd88)

Co-authored-by: kakkotetsu <[email protected]>
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Apr 2, 2021
v3.2.0

community.crypto
- acme module_utils - the ``acme`` module_utils has been split up into several Python modules (ansible-collections/community.crypto#184).
- acme_* modules - codebase refactor which should not be visible to end-users (ansible-collections/community.crypto#184).
- acme_* modules - support account key passphrases for ``cryptography`` backend (ansible-collections/community.crypto#197, ansible-collections/community.crypto#207).
- acme_certificate_revoke - support revoking by private keys that are passphrase protected for ``cryptography`` backend (ansible-collections/community.crypto#207).
- acme_challenge_cert_helper - add ``private_key_passphrase`` parameter (ansible-collections/community.crypto#207).

community.docker
- docker_swarm_service - change ``publish.published_port`` option from mandatory to optional. Docker will assign random high port if not specified (ansible-collections/community.docker#99).

community.general
- archive - refactored some reused code out into a couple of functions (ansible-collections/community.general#2061).
- csv module utils - new module_utils for shared functions between ``from_csv`` filter and ``read_csv`` module (ansible-collections/community.general#2037).
- ipa_sudorule - add support for setting sudo runasuser (ansible-collections/community.general#2031).
- jenkins_job - add a ``validate_certs`` parameter that allows disabling TLS/SSL certificate validation (ansible-collections/community.general#255).
- kibana_plugin - add parameter for passing ``--allow-root`` flag to kibana and kibana-plugin commands (ansible-collections/community.general#2014).
- proxmox - added ``purge`` module parameter for use when deleting lxc's with HA options (ansible-collections/community.general#2013).
- proxmox inventory plugin - added ``tags_parsed`` fact containing tags parsed as a list (ansible-collections/community.general#1949).
- proxmox_kvm - added new module parameter ``tags`` for use with PVE 6+ (ansible-collections/community.general#2000).
- rax - elements of list parameters are now validated (ansible-collections/community.general#2006).
- rax_cdb_user - elements of list parameters are now validated (ansible-collections/community.general#2006).
- rax_scaling_group - elements of list parameters are now validated (ansible-collections/community.general#2006).
- read_csv - refactored read_csv module to use shared csv functions from csv module_utils (ansible-collections/community.general#2037).
- redfish_* modules, redfish_utils module utils - add support for Redfish session create, delete, and authenticate (ansible-collections/community.general#1975).
- snmp_facts - added parameters ``timeout`` and ``retries`` to module (ansible-collections/community.general#980).
- vdo - add ``force`` option (ansible-collections/community.general#2101).

community.network
- edgeos_config - match the space after ``set`` and ``delete`` commands (ansible-collections/community.network#199).
- nclu - execute ``net commit description <description>`` only if changed ``net pending``'s diff field (ansible-collections/community.network#219).

community.postgresql
- postgresql_info - add the ``patch``, ``full``, and ``raw`` values of the ``version`` return value (ansible-collections/community.postgresql#68).
- postgresql_ping - add the ``patch``, ``full``, and ``raw`` values of the ``server_version`` return value (ansible-collections/community.postgresql#70).

community.zabbix
- zabbix_agent - added support for installations on arm64 systems (ansible-collections/community.zabbix#320).
- zabbix_proxy - now supports configuring StatsAllowedIP (ansible-collections/community.zabbix#337).
- zabbix_server - added support for installtions on arm64 systems (ansible-collections/community.zabbix#320).
- zabbix_web - added support for installtions on arm64 systems (ansible-collections/community.zabbix#320).

dellemc.openmanage
- ome_template - Allows to deploy a template on device groups.

hetzner.hcloud
- Add firewalls to hcloud_server module

ovirt.ovirt
- cluster_upgrade - Add correlation-id header (oVirt/ovirt-ansible-collection#222).
- engine_setup - Add skip renew pki confirm (oVirt/ovirt-ansible-collection#228).
- examples - Add recipe for removing DM device (oVirt/ovirt-ansible-collection#233).
- hosted_engine_setup - Filter devices with unsupported bond mode (oVirt/ovirt-ansible-collection#226).
- infra - Add reboot host parameters (oVirt/ovirt-ansible-collection#231).
- ovirt_disk - Add SATA support (oVirt/ovirt-ansible-collection#225).
- ovirt_user - Add ssh_public_key (oVirt/ovirt-ansible-collection#232)

purestorage.flasharray
- purefa_maintenance - New module to set maintenance windows
- purefa_pg - Add support to rename protection groups
- purefa_syslog - Add support for naming SYSLOG servers for Purity//FA 6.1 or higher

purestorage.flashblade
- purefb_certs - Add update functionality for array cert
- purefb_fs - Add multiprotocol ACL support
- purefb_info - Add information regarding filesystem multiprotocol (where available)
- purefb_info - Add new parameter to provide details on admin users
- purefb_info - Add replication performace statistics
- purefb_s3user - Add ability to remove an S3 users existing access key
@Andersson007
Copy link
Contributor

@kakkotetsu hi, would you like to have your GH login added to .github/BOTMETA.yml as a maintainer of the module?
You'll be notified about Issues/PRs related to the module and your shipit will be counted by bot for automerge (needs two for bugfixes and minor changes).
what do you think?

@eikef
Copy link

eikef commented Mar 25, 2022

Is there reasoning behind the "exec commit only if changed"?

This broke functionality and multi-stage commits:

- name: Configure xyz
  nclu:
    commands:
      [...]

- name: Configure abc
  nclu:
    commands:
      [...]

- name: Commit changes
  nclu:
    commit: True

Specifically, this change makes it impossible to commit staged commands if you do not also have a command in the final task which also specifically changes the configuration. As such, the value of the (default) non-commit, non-atomic tasks is questionable.

@Andersson007
Copy link
Contributor

@eikef thanks for the feedback!
@kakkotetsu what do you think?

@kakkotetsu
Copy link
Contributor Author

I think the and _changed condition can be eliminated, since the usage you indicated should also be possible.

The reasons for this change("exec commit only if changed") are:

  • I didn't consider your use case. I thought the "commit" option was always used with "commands".
- name: Configure
  nclu:
    commands:
      [configure xyz...]
      [configure abc...]
    commit: True
    description: 'commit via Ansible'
  • I didn't want the "net show commit history" command to show a list of commits that never actually changed.(likes below)
    This problem can occur when the same playbook is run multiple times.
$ net show commit history
 #  Date                 Description
--  -------------------  --------------------------------
...
28  2022-03-30 17:11:28  nclu commit via Ansible
30  2022-03-30 17:12:29  nclu commit via Ansible
...

While investigating this matter, I noticed that "changed" does not seem to be true when "commit" is executed due to the following bug in Cumulus Linux.
CM-26860

@eikef
Copy link

eikef commented Mar 30, 2022

One could alter the logic to skip committing if there are no changes effected by the queued commands (i.e. check_pending() returns an empty string, presumably) to avoid those empty commit history entries. That way commits should still happen if the staged commands have changed any actual configuration (since that will yield a non-empty diff), but not when no actual change has taken place.

(I've noticed the same problem of empty commits but solved it differently for my playbook -- before committing I actually check whether there are pending changes and register the output to test for an empty diff and basing the decision to run the commit task on the outcome.)

@kakkotetsu
Copy link
Contributor Author

Thanks for explaining. Please Pull Request to fix #399 if possible.

I think it would be improved by modifying the code as follows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants