You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When ansible.netcommon.restconf_get is used to retrieve not existing data, the RESTCONF server sends an HTTP 404 error and the corresponding Ansible task fails. As a consequence processing of subsequent task for the given host stops.
Especially when performing queries (GET requests), it may be sane that a resource does not exists. Imagine there is a playbook with multiple tasks querying different RESTCONF resources, to report the precense (or absence) or certain configuration.
ISSUE TYPE
Feature Idea
COMPONENT NAME
ansible.netcommon.restconf_get
ADDITIONAL INFORMATION
The RESTCONF RFC states the following regarding not-existing resources:
If a retrieval request for a data resource represents an instance
that does not exist, then an error response containing a "404 Not
Found" status-line MUST be returned by the server. The error-tag
value "invalid-value" is used in this case.
It is proposed, that a new attribute is added to ansible.netcommon.restconf_get:
The task for device2 succeeds, although the resource has not been found.
I simulated this with the following failed_when statement:
tasks:
- name: "RESTCONF: Get interface (1)"ansible.netcommon.restconf_get:
path: "/Cisco-IOS-XE-native:native/interface/Loopback=900"register: restconf_resultfailed_when:
- restconf_result.response is not defined
- restconf_result.code != 404
The text was updated successfully, but these errors were encountered:
SUMMARY
When
ansible.netcommon.restconf_get
is used to retrieve not existing data, the RESTCONF server sends an HTTP 404 error and the corresponding Ansible task fails. As a consequence processing of subsequent task for the given host stops.Especially when performing queries (GET requests), it may be sane that a resource does not exists. Imagine there is a playbook with multiple tasks querying different RESTCONF resources, to report the precense (or absence) or certain configuration.
ISSUE TYPE
COMPONENT NAME
ansible.netcommon.restconf_get
ADDITIONAL INFORMATION
The RESTCONF RFC states the following regarding not-existing resources:
It is proposed, that a new attribute is added to
ansible.netcommon.restconf_get
:ignore_not_exist_resource
(boolean
) / Default:false
When the parameter is set to
true
, Ansible does not consider the task failed, when:code==404
anderror-tag == 'invalid-value'
This is an example for a verbose task output:
The task for
device2
succeeds, although the resource has not been found.I simulated this with the following
failed_when
statement:The text was updated successfully, but these errors were encountered: