ansible.netcommon.grpc_config (3.1.3) — module

Fetch configuration/state data from gRPC enabled target hosts.

| "added in version" 3.1.0 of ansible.netcommon"

Authors: Gomathi Selvi S (@GomathiselviS)

This plugin has a corresponding action plugin.

Install collection

Install with ansible-galaxy collection install ansible.netcommon:==3.1.3


Add to requirements.yml

  collections:
    - name: ansible.netcommon
      version: 3.1.3

Description

gRPC is a high performance, open-source universal RPC framework.

This module allows the user to append configs to an existing configuration in a gRPC enabled devices.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - name: Merge bgp config
    ansible.netcommon.grpc_config:
      config: "{{ lookup('file', 'bgp.json')  }}"
      state: merged
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - name: Find diff
    diff: True
    ansible.netcommon.grpc_config:
      config: "{{ lookup('file', 'bgp_start.yml')  }}"
      state: merged
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - name: Backup running config
    ansible.netcommon.grpc_config:
       backup: yes

Inputs

    
state:
    description: action to be performed
    type: str

backup:
    default: false
    description:
    - This argument will cause the module to create a full backup of the current C(running-config)
      from the remote device before any changes are made. If the C(backup_options) value
      is not given, the backup file is written to the C(backup) folder in the playbook
      root directory or role root directory, if playbook is part of an ansible role. If
      the directory does not exist, it is created.
    type: bool

config:
    description:
    - This option specifies the string which acts as a filter to restrict the portions
      of the data to be retrieved from the target host device. If this option is not specified
      the entire configuration or state data is returned in response provided it is supported
      by target host.
    type: str

backup_options:
    description:
    - This is a dict object containing configurable options related to backup file path.
      The value of this option is read only when C(backup) is set to I(yes), if C(backup)
      is set to I(no) this option will be silently ignored.
    suboptions:
      dir_path:
        description:
        - This option provides the path ending with directory name in which the backup
          configuration file will be stored. If the directory does not exist it will be
          first created and the filename is either the value of C(filename) or default
          filename as described in C(filename) options description. If the path value
          is not given in that case a I(backup) directory will be created in the current
          working directory and backup configuration will be copied in C(filename) within
          I(backup) directory.
        type: path
      filename:
        description:
        - The filename to be used to store the backup configuration. If the filename is
          not given it will be generated based on the hostname, current time and date
          in format defined by <hostname>_config.<current-date>@<current-time>
        type: str
    type: dict

Outputs

backup_path:
  description: The full path to the backup file
  returned: when backup is yes
  sample: /playbooks/ansible/backup/config.2022-07-16@22:28:34
  type: str
diff:
  description: If --diff option in enabled while running, the before and after configuration
    change are returned as part of before and after key.
  returned: when diff is enabled
  type: dict
stdout:
  description: The raw string containing response object received from the gRPC server.
  returned: error mesage, when failure happens. empty , when the operation is successful
  sample: '...'
  type: str
stdout_lines:
  description: The value of stdout split into a list
  returned: always apart from low-level errors (such as action plugin)
  sample:
  - '...'
  - '...'
  type: list