Does Ansible support actions for NETCONF devices?

24 views
Skip to first unread message

steve...@gmail.com

unread,
Jan 2, 2019, 2:23:47 PM1/2/19
to Ansible Project
Hi
Ansible supports netconf-rpc module allowing RPC operations to NETCONF devices
Does Ansible also support actions to NETCONF devices?

From RFC 7950:

   The difference between an action and an rpc is that an action is tied
   to a node in the datastore, whereas an rpc is not.  When an action is
   invoked, the node in the datastore is specified along with the name
   of the action and the input parameters.

Thank you
Regards
Steve

Ganesh Nalawade

unread,
Jan 4, 2019, 2:48:13 AM1/4/19
to Ansible Project

Since action is a netconf RPC defined in RFC 7950 it can be executed using Ansible netconf_rpc module.

- name: execute action rpc
netconf_rpc:
rpc: action
xmlns: "urn:ietf:params:xml:ns:yang:1"
content: |
<server xmlns="urn:example:server-farm">
<name>apache-1</name>
<reset>
<reset-at>2014-07-29T13:42:00Z</reset-at>
</reset>
</server>


This task will send below XML RPC to remote Netconf server which is similar to that mentioned in RFC 7950

<?xml version="1.0" encoding="UTF-8"?>
<nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:4c1aba18-f7dc-4937-a2b9-019cbea5cc4d">
<action xmlns="urn:ietf:params:xml:ns:yang:1">
    <server xmlns="urn:example:server-farm">
        <name>apache-1</name>
            <reset>
                <reset-at>2014-07-29T13:42:00Z</reset-at>
                </reset>
        </server>
    </action>
</nc:rpc>

Hope this helps!

Regards,
Ganesh

steve...@gmail.com

unread,
Jan 10, 2019, 5:22:26 PM1/10/19
to Ansible Project
Thank you Ganesh
Let me be more specific with my question/use case.

I want to perform actions on specific nodes but the node names may vary from one server to the other.

Can a playbook achieve the following tasks?


1) query the node and get all of the node names or a subset of the node names

2) for each target node name that is returned, "execute" an action on it 

3) if result is fail, quit (fail); otherwise go to the next action for the next node


I guess the sequence of node names that is returned in step 1 will need to be meaningful in order to ensure the right action is applied to the right node.

Alternatively, step 2 can look for a match on the first part of the node name (a string), and then execute the appropriate action for the matching prefix.

Is this feasible?


Thanks again


-Steve B

Reply all
Reply to author
Forward
0 new messages