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

cisco.ios.ios_config save_when: modified always saves #1107

Open
MVlaar-GH opened this issue Aug 14, 2024 · 0 comments
Open

cisco.ios.ios_config save_when: modified always saves #1107

MVlaar-GH opened this issue Aug 14, 2024 · 0 comments

Comments

@MVlaar-GH
Copy link

MVlaar-GH commented Aug 14, 2024

SUMMARY

When using the module cisco.ios.ios_config with only 1 parameter, that parameter being save_when: modified, the configuration always gets saved. When running the module twice in a row with this configuration, it saves twice.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

cisco.ios.ios_config

ANSIBLE VERSION
2.14.3
COLLECTION VERSION
# /usr/lib/python3/dist-packages/ansible_collections
Collection Version
---------- -------
cisco.ios  4.3.1  
CONFIGURATION
CONFIG_FILE() = None
OS / ENVIRONMENT

ok: [192.168.26.2] => {
"ansible_facts": {
"net_api": "cliconf",
"net_gather_network_resources": [],
"net_gather_subset": [
"default"
],
"net_hostname": "MV-GW-02",
"net_image": "bootflash:packages.conf",
"net_iostype": "IOS-XE",
"net_model": "ISR4321/K9",
"net_operatingmode": "autonomous",
"net_python_version": "3.11.2",
"net_serialnum": "",
"net_system": "ios",
"net_version": "17.12.03a",
"network_resources": {}
}
}

STEPS TO REPRODUCE

Invoke the cisco.ios.ios_config module and supply only the save_when: modified parameter.

---
- name: Testing unexpected save behaviour
  hosts: all
  vars_prompt:
  - name: ansible_user
    prompt: ADM-gebruiker
    private: false
  - name: ansible_password
    prompt: ADM-wachtwoord
    unsafe: true
    private: true
  tasks:
    - name: Test Save 1
      cisco.ios.ios_config:
        save_when: modified
    - name: Test Save 2
      cisco.ios.ios_config:
        save_when: modified
EXPECTED RESULTS

Task "Test Save 1" to save the config if I made any changes previously
Task "Test Save 2" to never save, as it has just been saved

ACTUAL RESULTS

The playbook saves twice. When logging into the router and running show version, the first 2 lines are very clear:
! Last configuration change at 14:24:31 CEST Wed Aug 14 2024
! NVRAM config last updated at 15:49:47 CEST Wed Aug 14 2024 by cisco
Even though the NVRAM update time is later than the last config change time, it saves anway.

ansible-playbook [core 2.14.3]
  config file = None
  configured module search path = ['/home/mathijs/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/mathijs/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-playbook
  python version = 3.11.2 (main, May  2 2024, 11:59:08) [GCC 12.2.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True
No config file found; using defaults
Parsed 192.168.26.2, inventory source with host_list plugin
redirecting (type: action) cisco.ios.ios_config to cisco.ios.ios
redirecting (type: action) cisco.ios.ios_config to cisco.ios.ios
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: test_save.yml ***********************************************************************************************************************************************************
1 plays in test_save.yml
ADM-gebruiker: cisco
ADM-wachtwoord: 

PLAY [Testing unexpected save behaviour] ******************************************************************************************************************************************

TASK [Gathering Facts] ************************************************************************************************************************************************************
task path: /home/mathijs/Ansible/CiscoRoles/test_save.yml:2
[WARNING]: ansible-pylibssh not installed, falling back to paramiko
<192.168.26.2> ESTABLISH LOCAL CONNECTION FOR USER: mathijs
<192.168.26.2> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/mathijs/.ansible/tmp/ansible-local-27668h2tf6klw `"&& mkdir "` echo /home/mathijs/.ansible/tmp/ansible-local-27668h2tf6klw/ansible-tmp-1723646050.1342814-27723-114774899477572 `" && echo ansible-tmp-1723646050.1342814-27723-114774899477572="` echo /home/mathijs/.ansible/tmp/ansible-local-27668h2tf6klw/ansible-tmp-1723646050.1342814-27723-114774899477572 `" ) && sleep 0'
Using module file /usr/lib/python3/dist-packages/ansible_collections/cisco/ios/plugins/modules/ios_facts.py
<192.168.26.2> PUT /home/mathijs/.ansible/tmp/ansible-local-27668h2tf6klw/tmpaq4m7aq2 TO /home/mathijs/.ansible/tmp/ansible-local-27668h2tf6klw/ansible-tmp-1723646050.1342814-27723-114774899477572/AnsiballZ_ios_facts.py
<192.168.26.2> EXEC /bin/sh -c 'chmod u+x /home/mathijs/.ansible/tmp/ansible-local-27668h2tf6klw/ansible-tmp-1723646050.1342814-27723-114774899477572/ /home/mathijs/.ansible/tmp/ansible-local-27668h2tf6klw/ansible-tmp-1723646050.1342814-27723-114774899477572/AnsiballZ_ios_facts.py && sleep 0'
<192.168.26.2> EXEC /bin/sh -c '/usr/bin/python3 /home/mathijs/.ansible/tmp/ansible-local-27668h2tf6klw/ansible-tmp-1723646050.1342814-27723-114774899477572/AnsiballZ_ios_facts.py && sleep 0'
<192.168.26.2> EXEC /bin/sh -c 'rm -f -r /home/mathijs/.ansible/tmp/ansible-local-27668h2tf6klw/ansible-tmp-1723646050.1342814-27723-114774899477572/ > /dev/null 2>&1 && sleep 0'
ok: [192.168.26.2]
redirecting (type: action) cisco.ios.ios_config to cisco.ios.ios

TASK [Test Save 1] ****************************************************************************************************************************************************************
task path: /home/mathijs/Ansible/CiscoRoles/test_save.yml:13
redirecting (type: action) cisco.ios.ios_config to cisco.ios.ios
redirecting (type: action) cisco.ios.ios_config to cisco.ios.ios
changed: [192.168.26.2] => {
    "changed": true,
    "invocation": {
        "module_args": {
            "after": null,
            "backup": false,
            "backup_options": null,
            "before": null,
            "defaults": false,
            "diff_against": null,
            "diff_ignore_lines": null,
            "intended_config": null,
            "lines": null,
            "match": "line",
            "multiline_delimiter": "@",
            "parents": null,
            "replace": "line",
            "running_config": null,
            "save_when": "modified",
            "src": null
        }
    }
}
redirecting (type: action) cisco.ios.ios_config to cisco.ios.ios

TASK [Test Save 2] ****************************************************************************************************************************************************************
task path: /home/mathijs/Ansible/CiscoRoles/test_save.yml:16
redirecting (type: action) cisco.ios.ios_config to cisco.ios.ios
redirecting (type: action) cisco.ios.ios_config to cisco.ios.ios
changed: [192.168.26.2] => {
    "changed": true,
    "invocation": {
        "module_args": {
            "after": null,
            "backup": false,
            "backup_options": null,
            "before": null,
            "defaults": false,
            "diff_against": null,
            "diff_ignore_lines": null,
            "intended_config": null,
            "lines": null,
            "match": "line",
            "multiline_delimiter": "@",
            "parents": null,
            "replace": "line",
            "running_config": null,
            "save_when": "modified",
            "src": null
        }
    }
}

PLAY RECAP ************************************************************************************************************************************************************************
192.168.26.2               : ok=3    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
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

No branches or pull requests

1 participant