grpc_config¶
Collection Note
This module is part of the ansible.netcommon collection. To install the collection, use:
Added in version3.1.0.
You need further requirements to be able to use this module, see the Requirements section for details.
Synopsis¶
- 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¶
The following Python packages are needed on the host that executes this module:
Parameters¶
| Parameter | Defaults / Choices | Comments |
|---|---|---|
| backup bool |
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. | |
| backup_options dict |
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. | |
| backup_options.dir_path | 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. | |
| backup_options.filename | 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 |
|
| config str |
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. | |
| state str |
action to be performed |
Notes¶
Note
- This module requires the gRPC system service be enabled on the target host being managed.
- This module supports the use of connection=connection=ansible.netcommon.grpc
- This module requires the value of 'ansible_network_os' or 'grpc_type' configuration option (refer ansible.netcommon.grpc connection plugin documentation) be defined as an inventory variable.
- Tested against iosxrv 9k version 6.1.2.
Examples¶
- 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: Merge bgp config
ansible.netcommon.grpc_config:
config: "{{ lookup('file', 'bgp.json') }}"
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: true
Return Values¶
| Key | Data Type | Description | Returned |
|---|---|---|---|
| backup_path | str | The full path to the backup file | when backup is yes |
| diff | dict | If --diff option in enabled while running, the before and after configuration change are returned as part of before and after key. | when diff is enabled |
| stdout | str | The raw string containing response object received from the gRPC server. | error mesage, when failure happens. empty , when the operation is successful |
| stdout_lines | list | The value of stdout split into a list | always apart from low-level errors (such as action plugin) |
Authors¶
- Gomathi Selvi S (@gomathiselvis)