ansible-collections / ansible.network

Ansible Network Collection for network and IP utilities that are not specific to any platform or OS.
GNU General Public License v3.0
18 stars 18 forks source link

[Proposal] GRPC connection plugin to interact with network devices that support gRPC #9

Closed GomathiselviS closed 5 months ago

GomathiselviS commented 3 years ago

Proposal:

GRPC connection plugin to interact with network devices that support gRPC Author: Gomathi Selvi Srinivasan (@GomathiselviS)

Date: 2021/05/20

Motivation

Describe the reasons for this proposal. Provide GRPC modules to interact with devices that have gRPC services enabled.

Problems

Solution proposal

- name: run cli command
  grpc_get:
    command: 'show version'
    display: text

- name: Get bgp configuration data
  grpc_get:
    section:  '{"Cisco-IOS-XR-ipv4-bgp-cfg:bgp": [null]}'

- name: Get configuration JSON format over secure TLS channel
  grpc_get:
    display: json
    data: config
  vars:
    ansible_root_certificates_file: /home/username/ems.pem
    ansible_grpc_channel_options:
      'grpc.ssl_target_name_override': 'ems.cisco.com'

 - name: Merge static route config
    ansible.netcommon.grpc_config:
      config:
        Cisco-IOS-XR-ip-static-cfg:router-static:
          default-vrf:
            address-family:
              vrfipv4:
                vrf-unicast:
                  vrf-prefixes:
                    vrf-prefix:
                      - prefix: "1.2.3.6"
                        prefix-length: 32
                        vrf-route:
                          vrf-next-hop-table:
                            vrf-next-hop-next-hop-address:
                              - next-hop-address: "10.0.2.2"

      state: merged

- name: Find diff
    diff: True
    ansible.netcommon.grpc_config:
      config: "{{ lookup('file', 'bgp_start.yml')  }}"
      state: merged

  - name: Backup running config
    ansible.netcommon.grpc_config:
       backup: yes

- name: Replace bgp config
    ansible.netcommon.grpc_config:
      config: "{{ lookup('file', 'bgp.yml')  }}"
      state: replaced

- name: Delete bgp config
    ansible.netcommon.grpc_config:
      config: "{{ lookup('file', 'bgp.yml')  }}"
      state: deleted

Testing (optional)

Documentation (optional)

ganeshrn commented 3 years ago

As a user, I want to connect to any gRPC enabled remote device and stream the data constantly in various streaming options provided by HTTP 2, bidirectionally.

This might not be possible and ansible work with request and response model

ganeshrn commented 3 years ago

grpc_nw_get module can be renamed to grpc_get since the module will be in netcommon collection nw is not required in the name. Applicable for other modules as well.

ganeshrn commented 3 years ago

section option can be replace with filter to be in sync with other network modules (eg. netconf_get)

ganeshrn commented 3 years ago

default_operation option is applicable for netconf modules. If in case the grpc server doesn't support these options we might able to add that functionality within the module. Can mention this in the module docs