09-01-2023 04:04 PM
Is it possible to create an NSO action to check sync status, similar with the example below, but with RESTCONF while using Ansible
nso_action:
url: "{{ nso.url }}"
username: "{{ nso.username }}"
password: "{{ nso.password }}"
path: "/ncs:devices/device{ {{ item.device }} }/check-sync"
input: {}
register: result
09-02-2023 04:23 AM - edited 09-02-2023 04:24 AM
The configuration that I have tried in ansible:
---
- name: Check-sync
hosts: localhost
connection: httpapi
gather_facts: no
vars:
ansible_connection: "httpapi"
ansible_network_os: "restconf"
ansible_httpapi_use_ssl: false
ansible_httpapi_validate_certs: false
ansible_httpapi_port: 8080
ansible_httpapi_restconf_root: "/restconf/operations/" # default
ansible_user: "admin"
ansible_password: "admin"
check_sync: "ncs:check-sync"
tasks:
- name: "config"
ansible.netcommon.restconf_config:
path: "tailf-ncs:devices/device=R11"
content: "{{ check_sync|to_nice_json}}"
register: restconf_result
Result: fatal: [localhost]: FAILED! => {"changed": false, "code": 405, "msg": "HTTP Error 405: Method Not Allowed"}
I'm able to run it manually:
$ curl -u admin:admin http://localhost:8080/restconf/operations/tailf-ncs:devices/device=R11/check-sync -X POST -H 'Accept: application/yang-data+json' -H 'Content-Type: application/yang-data+json'
{
"tailf-ncs:output": {
"result": "out-of-sync",
"info": "got: 2023-09-02 10:11:14 CEST expected: 2023-09-01 13:52:38 CEST\n"
}
}
Any suggestion?
09-03-2023 01:48 AM - edited 09-03-2023 01:50 AM
Alternative found:
tasks:
- name: "check sync status"
uri:
url: http://localhost:8080/restconf/operations/tailf-ncs:devices/device=R11/check-sync
url_username: admin
url_password: admin
method: POST
headers:
Content-Type: application/yang-data+json
register: result
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