-
Couldn't load subscription status.
- Fork 167
Description
I encountered an issue where it is not possible to use a delete statement in a set/delete based config file using the junos_install_config module.
This issue occurs when the the delete statement in the file does not exist in the active configuration of the switch.
I am using an QFX5100-48S-6Q switch.
For instance, as an example, I have a simple playbook which installs a file of set/delete statements using junos_install_config:
- name: LAB Juniper switch provisioning
hosts: j1
connection: local
tasks:
- name: Pushing config ... please wait
junos_install_config:
host=j1
port=22
file=/var/tmp/ansible/j1.set
diffs_file=/var/tmp/ansible/j1.diffthe j1.set contains a single statement:
delete firewall
The ansible playbook fails with the following output:
TASK [Gathering Facts] *************************************************************************************************
ok: [j1]
TASK [Pushing config ... please wait] **********************************************************************************
fatal: [j1]: FAILED! => {"changed": false, "failed": true, "msg": "Unable to load config: ConfigLoadError(severity: warning, bad_element: None, message: warning: statement not found)"}
msg: Unable to load config: ConfigLoadError(severity: warning, bad_element: None, message: warning: statement not found)
PLAY RECAP *************************************************************************************************************
j1 : ok=1 changed=0 unreachable=0 failed=1
Ansible fails because it cannot find an existing firewall config section on the switch.
I used firewall as an example, but any delete statement for a section or statement within a section, which does not exist on the switch will give the same error.
As a work around I could do:
set firewall family inet filter dummy term dummy then discard
delete firewall
But this does not look very nice, and it took some time to figure out (especially in larger config files).
I use the delete statement often to remove complete sections, and build them from scratch.
Would it be possible to have the module ignore the warning?, or have Ansible treat is a warning, ins tead of a fatal?
Or at least have an error message which gives more info about which element the warning concerns?
Thanks in advance.