aruba/aos-switch-ansible-collection

Issue with arubaoss_config diff_against

Opened this issue · 0 comments

Hi,

I've been using this module but noticed that the diff_against startup config doesn't work correctly:

Playbook

---
- hosts: test
  collections:
    - arubanetworks.aos_switch
  tasks:
    - name: >
        Check running config matches startup. Returns OK if matching.
        Changed if not, which will then be saved.
      arubaoss_config:
        diff_against: startup
        save_when: modified


      vars:
        ansible_connection: network_cli

Output:

"before": "show config configInvalid input: config\r\nSWITCH-NAME# "

Digging into the module used, it appears there is issue with the command. as the command is not valid. "show config config"

#aos-switch-ansible-collection/plugins/modules/arubaoss_config.py
    elif module.params['save_when'] == 'modified':
        output = run_commands(module,
                              ['show running-config', 'show config config'])

        running_config = NetworkConfig(
            contents=output[0], ignore_lines=diff_ignore_lines)
        startup_config = NetworkConfig(
            contents=output[1], ignore_lines=diff_ignore_lines)

        if running_config.sha1 != startup_config.sha1:
            save_config(module, result)
    elif module.params['save_when'] == 'changed':
        if result['changed']:
            save_config(module, result)

    if module._diff:
        if not running_config:
            output = run_commands(module, 'show running-config')
            contents = output[0]
        else:
            contents = running_config.config_text

        # recreate the object in order to process diff_ignore_lines
        running_config = NetworkConfig(
            contents=contents, ignore_lines=diff_ignore_lines)

        if module.params['diff_against'] == 'running':
            if module.check_mode:
                module.warn("unable to perform diff against "
                            "running-config due to check mode")
                contents = None
            else:
                contents = config.config_text

        elif module.params['diff_against'] == 'startup':
            if not startup_config:
                output = run_commands(module, 'show config config')
                contents = output[0]
            else:
                contents = startup_config.config_text

Switch model: 2930m
version: 16.10.0020

Alternate way could be using the following command:

show config status

The running configuration matches the saved configuration.

Or changing it to show config.