05-30-2022 04:01 AM
Hi, we have been using iosxr_config - module (https://docs.ansible.com/ansible/latest/collections/cisco/iosxr/iosxr_config_module.html) to configure IOS XR routers using Ansible. We need to be able to use also "commit confirmed" feature to make sure routers roll back configuration if Ansible cuts it's own connection to routers for any reason. In this module we don't have that confirmed option.
In the iosxr cliconf - plugin documentation we have that option: https://docs.ansible.com/ansible/latest/collections/cisco/iosxr/iosxr_cliconf.html
However, I couldn't find way to use it. This is what I have tried:
tasks: - name: Commit confirmed cisco.iosxr.iosxr: commit_confirmed: yes commit_confirmed_timeout: 30
This raises and error:
The full traceback is: Traceback (most recent call last): File "/home/user1/.ansible/collections/ansible_collections/ansible/netcommon/plugins/action/network.py", line 297, in _find_load_module module = importlib.import_module(context.plugin_resolved_name) File "/usr/lib/python3.8/importlib/__init__.py", line 118, in import_module if name.startswith('.'): AttributeError: 'NoneType' object has no attribute 'startswith' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/user1/.local/lib/python3.8/site-packages/ansible/executor/task_executor.py", line 158, in run res = self._execute() File "/home/user1/.local/lib/python3.8/site-packages/ansible/executor/task_executor.py", line 600, in _execute result = self._handler.run(task_vars=variables) File "/home/user1/.ansible/collections/ansible_collections/cisco/iosxr/plugins/action/iosxr.py", line 156, in run result = super(ActionModule, self).run(task_vars=task_vars) File "/home/user1/.ansible/collections/ansible_collections/ansible/netcommon/plugins/action/network.py", line 55, in run filename, module = self._find_load_module() File "/home/user1/.ansible/collections/ansible_collections/ansible/netcommon/plugins/action/network.py", line 300, in _find_load_module fullname, filename = mloadr.find_plugin_with_name( AttributeError: 'PluginLoader' object has no attribute 'find_plugin_with_name' fatal: [hkipas01-bbrtr1]: FAILED! => { "msg": "Unexpected failure during module execution.", "stdout": "" }
Can anybody help me into the correct direction? What might be the problem here?
Solved! Go to Solution.
05-31-2022 04:50 AM
I found out by reading tests (documentation is not quite helpful at the moment) in the code it should be used like this:
---
- name: load a config from disk and replace the current config
hosts: xr-routers
gather_facts: no
vars:
- path_configs: "configs"
tasks:
- name: First commit with confirmed
vars:
ansible_iosxr_commit_confirmed: true
ansible_iosxr_commit_confirmed_timeout: 30
cisco.iosxr.iosxr_config:
src: "{{path_configs}}/{{inventory_hostname}}-config.cfg"
backup: yes
- name: Final commit
vars:
ansible_iosxr_commit_confirmed: false
cisco.iosxr.iosxr_config:
src: "{{path_configs}}/{{inventory_hostname}}-config.cfg"
However, if you wanted to use "replace: config" which I do it doesn't work. I raised an issue about that https://github.com/ansible-collections/cisco.iosxr/issues/249
Also for some reason you need to also specify ansible_iosxr_commit_confirmed: false for second task.
05-31-2022 04:50 AM
I found out by reading tests (documentation is not quite helpful at the moment) in the code it should be used like this:
---
- name: load a config from disk and replace the current config
hosts: xr-routers
gather_facts: no
vars:
- path_configs: "configs"
tasks:
- name: First commit with confirmed
vars:
ansible_iosxr_commit_confirmed: true
ansible_iosxr_commit_confirmed_timeout: 30
cisco.iosxr.iosxr_config:
src: "{{path_configs}}/{{inventory_hostname}}-config.cfg"
backup: yes
- name: Final commit
vars:
ansible_iosxr_commit_confirmed: false
cisco.iosxr.iosxr_config:
src: "{{path_configs}}/{{inventory_hostname}}-config.cfg"
However, if you wanted to use "replace: config" which I do it doesn't work. I raised an issue about that https://github.com/ansible-collections/cisco.iosxr/issues/249
Also for some reason you need to also specify ansible_iosxr_commit_confirmed: false for second task.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide