-
Notifications
You must be signed in to change notification settings - Fork 19
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
Generic Netconf modules for managing Netconf enabled network devices #104
Comments
Updating here as well. Mentioned in IRC meeting that, imho, the following changes should be made:
in both cases, this better aligns the module arguments with names across they ansible ecosystem |
Maybe we could also have a command for every standard netconf rpc besides the generic one. For instance, in addition to
have something like:
There might even be additional value, as they can be smarter with regards to idempotency. In this case, the specific command can avoid locking |
@lpenz That's a good idea. There can be
All the other standard Netconf operations can be executed using Thoughts/suggestions? |
@privateip Update proposal incorporating your review comments. |
@lpenz @ganeshrn I worry we are exposing way to much of the netconf api here. The playbook writer would need intimate knowledge of netconf if we externalize the locking mechanism into a separate module as opposed to building it into the module on an as needed basis. That is a bit of an anti-pattern for Ansible modules |
@privateip That makes sense, netconf_config have the lock/unlock mechanism build into the module. |
Moving to agreed as discussed in irc meeting https://meetbot.fedoraproject.org/ansible-network/2018-04-25/network_working_group.2018-04-25-16.00.log.html |
General remark: Example Scenario Current implementation: Desired implementation: While it was impossible to do this using the original approach connection=local, with connection=NETCONF the connection is now persisted over multiple NETCONF related tasks and so can the lock. Conclusion would be, that the playbook author might decide either to use explicit lock using a new netconf_lock module or implicit lock embedded in the (existing) netconf_get and netconf_config modules. For those netconf related modules (get/config) it would basically mean, that we either need to expose an explicit "lock" attribute (default: True) - to prevent the module to take/release the lock (by setting lock: False). The other option would be, to check at the beginning of the playbook if the datastore is already locked by this netconf client - and to not do it again. Most flexible solution is likely a mix of both approaches, having an option lock with values True, False and Auto (default: auto). |
Comments on proposed changes on netconf_config
Also, as discussed in my previous comment, it might be beneficial to provide more control over |
Request to add a new "netconf_audit" module Functionality should be in-line with the "nso_verify" module. Technically, there is no need to have Cisco NSO for this. Question is, if the module needs to be YANG aware. Likely the advantage of being YANG-aware would be, that we could properly render data-types integer/string and we could distinguish better between list-keys and regular leaf attributes. |
Implements part-1 of proposal ansible#104 ansible/proposals#104 * Add netconf_get module * Refactor `get`, `get_config`, `lock`, `unlock` and `discard_changes` netconf plugin api's * Add netconf module_utils file which netconf module related common functions * Refactor junos and iosxr netconf plugins
We do have this tension between ansible's idempotency principle and exposing more of netconf's functionality. It might be worth making a distinction between "porcelain" modules that are more aligned with ansible and modules that allow access to lower level functionality. Maybe just adding a note that |
Please have a check on #40198 as this also includes now support for In my view, we don't need any other specific modules for tasks like So the main remaining tasks are:
Also per my comment from May 9th, we should work on a validation/audit function (similar to the Cisco NSO modules). The main idea is, to check config/state attributes for existence and values. This could be used for tasks like security audits, configuration resync audits and pre/post upgrade/migration validation. |
* Add netconf_get module Implements part-1 of proposal #104 ansible/proposals#104 * Add netconf_get module * Refactor `get`, `get_config`, `lock`, `unlock` and `discard_changes` netconf plugin api's * Add netconf module_utils file which netconf module related common functions * Refactor junos and iosxr netconf plugins * Fix source option handling * Fix review comments * Update botmeta file * Update review comments and add support for lock * Lock update fix * Fix CI issue * Add integration test and minor fixes * Fix review comments * Fix CI failure * Fix CI issues * Fix CI issues * Fix review comments and update integration test * Fix review comments * Fix review comments * Fix review comments Fix reveiw comments
* Add netconf_get module Implements part-1 of proposal ansible#104 ansible/proposals#104 * Add netconf_get module * Refactor `get`, `get_config`, `lock`, `unlock` and `discard_changes` netconf plugin api's * Add netconf module_utils file which netconf module related common functions * Refactor junos and iosxr netconf plugins * Fix source option handling * Fix review comments * Update botmeta file * Update review comments and add support for lock * Lock update fix * Fix CI issue * Add integration test and minor fixes * Fix review comments * Fix CI failure * Fix CI issues * Fix CI issues * Fix review comments and update integration test * Fix review comments * Fix review comments * Fix review comments Fix reveiw comments
* Add netconf_get module Implements part-1 of proposal ansible#104 ansible/proposals#104 * Add netconf_get module * Refactor `get`, `get_config`, `lock`, `unlock` and `discard_changes` netconf plugin api's * Add netconf module_utils file which netconf module related common functions * Refactor junos and iosxr netconf plugins * Fix source option handling * Fix review comments * Update botmeta file * Update review comments and add support for lock * Lock update fix * Fix CI issue * Add integration test and minor fixes * Fix review comments * Fix CI failure * Fix CI issues * Fix CI issues * Fix review comments and update integration test * Fix review comments * Fix review comments * Fix review comments Fix reveiw comments
Implemented by: |
@ganeshrn, I've just done a quick review on PR44379 which contains the new implementation for If the target of Ansible modules is to provide access in an abstracted way, making smart decisions and combining multiple API calls with reason - I don't see this to be happen with the new version of the Having this said, combining some NETCONF RPCs makes sense: In those scenarios I am not convinced that such advanced use-cases exist for At least as playbook author I would be confused about all the options provided in the new netconf_config module. So they must understand rfc6241 as a foundation and than our take on this. This is not an easy ask - so I would consider the changes made as not enough. |
This 3 opertaion are mutually exclusive in modules as well and handled it using
Which option are you referring to?
All these scenarios can be achieved using the existing module. |
Currently in Ansible 2.7, There is no retry logic for datastore lock. In case of Cisco IOS-XE, There is a local synchronization process in the router which locks the datastore temporarily and we get an error message saying unable to lock the data store and the playbook fails. Adding a retry logic eliminates these exception scenarios. In case of nso they have implemented 6 retries with a delay of 3. |
* Add netconf_get module Implements part-1 of proposal ansible#104 ansible/proposals#104 * Add netconf_get module * Refactor `get`, `get_config`, `lock`, `unlock` and `discard_changes` netconf plugin api's * Add netconf module_utils file which netconf module related common functions * Refactor junos and iosxr netconf plugins * Fix source option handling * Fix review comments * Update botmeta file * Update review comments and add support for lock * Lock update fix * Fix CI issue * Add integration test and minor fixes * Fix review comments * Fix CI failure * Fix CI issues * Fix CI issues * Fix review comments and update integration test * Fix review comments * Fix review comments * Fix review comments Fix reveiw comments
Proposal:
Generic Netconf modules to support network platforms that are Netconf enabled
Author: Ganesh B. Nalawade @ganeshrn
Date: 2018/04/11
Motivation
Describe the reasons for this proposal.
Provide generic Netconf modules that can communicate with the network device that supports Netconf
Problems
What problems exist that this proposal will solve?
connection: local
andconnection:netconf
that uses underlying persistent connection framework.netconf_config
module.Solution proposal
netconf_get
module:The module fetch configuration and state data from remote Netconf enabled host.
Options:
1.data_type
: Identity which data needs to be fetched ie. configuration or state data. Valid values areconfig
andstate
and default toconfig
filter
: This argument specifies the XML string which acts as a filter to restrict the portions ofthe data to be are retrieved from remote device. If this option is not specified entire
configuration or state data is returned in result depending on the value of
source
option. The
filter
value can be either xml string or xpath, if the filter is inxpath format the Netconf server running on remote host should support xpath capabiltiy
else it will result in error.
source
: This argument specifies the datastore from which configuration data should be fetched. Valid values are running, candidate and auto. If the value is auto it fetched configuration data from I(candidate) datastore and if candidate datastore is not supported it fallback to running datastore. If the source value is not mentioned in that case both configuration and state information in returned in response from running datastorechoices: ['running', 'candidate', 'auto', 'startup'].
3.filter_type
: This argument specifies the type of filter, valid values are subtree and xpath. If value is subtree the value of option filter should be a xml string, if the value is xpath the value of option filter should be a xml xpath. The value xpath is supported only if Netconf server running on remote host supports xpath capability.choices: ['subtree', 'xpath']
default:
subtree
display
: Encoding scheme to use when serializing output from the device. Currently supported option value isjson
only. If the option value is I(json) it requires jxmlease to be installed on control node.choices: ['json']
netconf_config
module:The module will be used to edit the configuration, copy the configuration from one datastore to another or delete a complete configuration datastore on remote Netconf enabled host.
Options:
content
: It is XML string with a hierarchy of configuration data as defined by the device's data models. aliases:xml
. The xml string must be rooted in theconfig
element. Use lookup plugins for loading content from disk file.target
: Name of the configuration datastore to be edited. Valid values areauto
,candidate
,running
,startup
or remote URL.auto
, uses candidate and fallback to running.default_operation
: The default operation that needs to be performed on candidate datastore. Valid values aremerge
,replace
andnone
. The default value ismerge
. merge: If the value ismerge
the configuration data in theconfig
option is merged with the configuration at the corresponding level in the target datastore. If the value isreplace
the configuration data in theconfig
option completely replaces the configuration in the target datastore. If the value isnone
the target datastore is unaffected by the configuration in theconfig
option, unless and until the incoming configuration data uses the "operation" attribute to request a different operation.source
: It is the name of the configuration datastore to use as the source to copy the configuration whencopy
option is set toTrue
. The values can be eitherrunning
,candidate
,startup
or a remote URL.confirm
: This argument will configure a timeout value for the commit to be confirmed before it is automatically rolled back. If theconfirm_commit
argument is set to False, this argument is silently ignored. If the value of this argument is set to 0, the commit is confirmed immediately. The remote host should support :candidate and :confirmed-commit capability for this option to work properly.confirm_commit
: This argument will execute commit operation on the remote device. It can be used to confirm a previous commit. This is a boolean value.backup
: This argument will cause the module to create a full backup of the current datastore value intarget
from the remote device before any changes are made. The backup file is written to thebackup
folder in the playbook root directory. If the directory does not exist, it is created.copy
: It instructs the module to copy the configuration from datastore value mentioned insource
option to datastore value mentioned intarget
. It is a boolean valuesave
: It instructs the module to save the running-config to the startup-config if changed.delete
: It instructs the module to delete the configuration from value mentioned intarget
datastore.netconf_rpc
module:This module will execute generic Netconf RPC that is defined by Netconf standard as well as propriety RPC based on the Netconf capabilities supported by the remote host.
Options:
rpc
: This is the name of netconf RPC that should be executed of remote Netconf enabled device. The Netconf RPC defined by protocol can belock
,unlock
,delete-config
,copy-config
,get
,get-config
,close-session
,kill-session
,get-config
,edit-config
along with bunch of propriety RPC supported by remote host that are specific to vendors.content
: This is an XML string that identifies the payload for therpc
and is specific to the givenrpc
value defined in netconf standard or can be specific to the vendor supported rpc's.Testing (optional)
netconf_config
module.netconf_get
module.netconf_rpc
module.Documentation (optional)
netconf_config
.netconf_get
andnetconf_rpc
.The text was updated successfully, but these errors were encountered: