ansible / proposals

Repository for sharing and tracking progress on enhancement proposals for Ansible.
Creative Commons Zero v1.0 Universal
93 stars 19 forks source link

Module Behavior Modification: IOSXR_CONFIG Currently Commits After Every Command Sent, Even When In a Hierarchical Command Structure Which Causes the Module to Fail #118

Closed mfisher30 closed 6 years ago

mfisher30 commented 6 years ago

Proposal: Module Behavior Modification: IOSXR_CONFIG Commits After Every Command Sent, Even When In a Hierarchical Command Structure.

Author: Michael Fisher <@mfisher30> Date: 2017/xx/xx

Motivation

In the current design, looping through a YAML variable list while trying to configure an item using the IOSXR_CONFIG module, ANSIBLE tries to send a commit after every item sent, causing the module to error out. You are unable to commit while up in a Cisco IOS-XR hierarchical command, EX: prefix-set, access-list, etc...

Problems

Currently, if you try to use a with_items parameter while using a parent, the module will error out after the first item. The error that pops is indicative of the module trying to send a commit to the router, but cannot while in a hierarchical configuration. Some IOS-XR configurations require the complete rewrite of an 'object list' like prefix-sets, ACLs, prefix-lists, etc... when working with them via configuration terminal. With the way the module is currently designed, you have to send a configuration item as one long string. In the tested example of modifying a 'prefix-set', you are limited to only 49 prefixes as the input buffer doesn't allow for any more.

Example of message from the router when trying to 'modify' a prefix-set which is a hierarchical item

ASR9K Router(config)#prefix-set test_set 
Tue May 22 16:03:39.225 UTC
% WARNING: Policy object prefix-set test_set' exists! Reconfiguring it via CLI will replace current definition. Use 'abort to cancel.

Example of how current module functionality allows you to work within a hierarchical item

  vars:
   prefixes: 1.1.1.1/24, 2.2.2.2/24, 3.3.3.3/24, 4.4.4.4/24, 5.5.5.5/24, 7.0.0.0/8

  - name: Configure Prefix-Set
    iosxr_config:
      lines:
        - "{{ prefixes }}"
        - exit
      parents: prefix-set {{ prefix_set }}

Example of Ansible commands that fail due to module commit functionality:

  vars:
      prefixes:
        - 1.1.1.1/24
        - 2.2.2.2/24
        - 3.3.3.3/24
        - 4.4.4.4/24
        - 6.6.6.6/24
        - 7.0.0.0/8

  - name: Configure Prefix-Set "{{ prefix_set }}"
    iosxr_config:
      lines:
        - "{{ items }}"
      parents: prefix-set {{ prefix_set }}
    with_items:
        - "{{ prefixes }}"

Solution proposal

Ideas for potential solutions:

1) Remove the auto commit and make the commit a parameter within the module that can only execute when exited out of a hierarchical command and is defined by the user.

2) Modify the module to only commit when exiting out of a hierarchical command structure allowing for the use of loops/YAML list items

3) Implement a separate module for commits. This could allow additional commit options.

This will allow you to loop through a list of configuration items prior to the commit. Commit should be pushed to the device as per designated by the user writing the script or after you instruct the module to exit out of the hierarchy via 'exit' command.

Dependencies (optional)

-iosxr_config

Testing (optional)

A successful test would allow the use of a list of items to be sent to the router while configuring an item like a prefix-set, prefix-list, or ACL, and not have the router try to commit it until it exits out of the hierarchy or until the user defines the commit

Documentation (optional)

This would require modification to the current iosxr_config documentation or possibly the addition of module documentation if a new iosxr_commit module was implemented.

mfisher30 commented 6 years ago

closing issue. After deliberation, moving to bug report due to module not functioning as expected

marouim commented 5 years ago

+1 Need a way to show commit diffs in check mode