napalm_install_config error code 500 NXOS
nazarko-es opened this issue · 5 comments
Hello, I encountered an error when i tried to use the module napalm_install_config for replace config on Cisco Nexus 9000, switch soft version is nxos-9.2.3. My playbook:
- name: DEPLOY CONFIGURATIONS WITH NAPALM
napalm_install_config:
hostname: "{{ ansible_host }}"
username: 'username'
password: 'password'
dev_os: 'nxos'
config_file: "{{ role_path }}/files/{{ device_item.name }}.conf"
commit_changes: True
replace_config: True
Error after start playbook:
The full traceback is:
File "/tmp/ansible_napalm_install_config_payload_3ri_0y45/ansible_napalm_install_config_payload.zip/ansible/modules/napalm_install_config.py", line 298, in main
File "/usr/local/lib/python3.6/site-packages/napalm/nxos/nxos.py", line 209, in compare_config
diff = self._get_diff()
File "/usr/local/lib/python3.6/site-packages/napalm/nxos/nxos.py", line 187, in _get_diff
raw_text=True,
File "/usr/local/lib/python3.6/site-packages/napalm/nxos/nxos.py", line 689, in _send_command
return self.device.show(command, raw_text=raw_text)
File "/usr/local/lib/python3.6/site-packages/nxapi_plumbing/device.py", line 61, in show
result = self.show_list(commands, raw_text)
File "/usr/local/lib/python3.6/site-packages/nxapi_plumbing/device.py", line 89, in show_list
return self.api._nxapi_command(commands, method=cmd_method)
File "/usr/local/lib/python3.6/site-packages/nxapi_plumbing/api_client.py", line 105, in _nxapi_command
response = self._send_request(commands, method=method)
File "/usr/local/lib/python3.6/site-packages/nxapi_plumbing/api_client.py", line 82, in _send_request
raise NXAPIPostError(msg)
"msg": "cannot diff config: Invalid status code returned on NX-API POST\ncommands: ['show diff rollback-patch file sot_file file candidate_config.txt']\nstatus_code: 500"
I did python script with napalm module to install config:
Traceback (most recent call last):
File "test.py", line 6, in <module>
print(device.compare_config())
File "/home/esnazarko/napalm/nxos/nxos.py", line 209, in compare_config
diff = self._get_diff()
File "/home/esnazarko/napalm/nxos/nxos.py", line 187, in _get_diff
raw_text=True,
File "/home/esnazarko/napalm/nxos/nxos.py", line 689, in _send_command
return self.device.show(command, raw_text=raw_text)
File "/usr/local/lib/python3.6/site-packages/nxapi_plumbing/device.py", line 61, in show
result = self.show_list(commands, raw_text)
File "/usr/local/lib/python3.6/site-packages/nxapi_plumbing/device.py", line 89, in show_list
return self.api._nxapi_command(commands, method=cmd_method)
File "/usr/local/lib/python3.6/site-packages/nxapi_plumbing/api_client.py", line 105, in _nxapi_command
response = self._send_request(commands, method=method)
File "/usr/local/lib/python3.6/site-packages/nxapi_plumbing/api_client.py", line 82, in _send_request
raise NXAPIPostError(msg)
nxapi_plumbing.errors.NXAPIPostError: Invalid status code returned on NX-API POST
commands: ['show diff rollback-patch file sot_file file candidate_config.txt']
status_code: 500
Also i tried to do checkpoint operation on cisco switch and extract "show diff rollback-patch file sot_file file candidate_config.txt", but occured same error. The Cisco switch reads the file with the command 'show file %filename%" - config is ok
Is your file here:
config_file: "{{ role_path }}/files/{{ device_item.name }}.conf"
An NX-OS checkpoint file?
Being able to do this:
The Cisco switch reads the file with the command 'show file %filename%" - config is ok
Does not actually indicate your file is a proper, full checkpoint file.
I would say the most likely cause is you don't have a valid checkpoint file.
File on the path:
config_file: "{{ role_path }}/files/{{ device_item.name }}.conf"
Not NX-OS checkpoint. I generate this file with jinja template and asnible playbook. Can only use NX-OS checkpoint file? I want use NAPALM for zero-day provisioning, so I generated the configuration from jinja template
Hello, do you have information about this situation?
Yes, it must be a NX-OS checkpoint file. You can generate from a Jinja2 template, but it must be 100% consistent with the requirements of a checkpoint file.
I would start with a valid checkpoint file and then reverse engineer the Jinja2 to make it consistent with that.
Regards, Kirk
Hello, you can close this issue - after 100% consistent as checkpoin file plugin is work