Skip to content

Instantly share code, notes, and snippets.

View ganeshrn's full-sized avatar

Ganesh Nalawade ganeshrn

View GitHub Profile
@ganeshrn
ganeshrn / meta_runtime.yml
Created August 1, 2022 14:22
Add file in meta/runtime.yml under the root folder of where the nokia.sros collection is installed with below content
---
plugin_routing:
cliconf:
classic:
redirect: nokia.sros.classic
light:
redirect: nokia.sros.light
md:
redirect: nokia.sros.md
terminal:
@ganeshrn
ganeshrn / navigator logs
Created March 21, 2022 18:23
navigator logs
python -m ansible_navigator collections -m stdout
The requested content could not be converted to JSON.
The content was {'$schema': 'http://json-schema.org/draft-07/schema', 'additionalProperties': False, 'properties': {'ansible-navigator': {'properties': {'ansible': {'additionalProperties': False, 'properties': {'cmdline': {'type': 'string', 'description': 'Extra parameters passed to the corresponding command'}, 'config': {'additionalProperties': False, 'properties': {'help': {'type': 'boolean', 'description': 'Help options for ansible-config command in stdout mode', 'enum': [True, False], 'default': False}, 'path': {'type': 'string', 'description': 'Specify the path to the ansible configuration file'}}}, 'doc': {'additionalProperties': False, 'properties': {'help': {'type': 'boolean', 'description': 'Help options for ansible-doc command in stdout mode', 'enum': [True, False], 'default': False}, 'plugin': {'additionalProperties': False, 'properties': {'name': {'type': 'string', 'description': 'Specify the pl
@ganeshrn
ganeshrn / sample_choices.py
Created March 15, 2022 07:30
Case insenstive choice example
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = """
module: sample_choices
short_description: Demo case insensitive choices.
description:
- Demo case insensitive choices.
% git diff package.json
diff --git a/package.json b/package.json
index 1b192b2..428b13b 100644
--- a/package.json
+++ b/package.json
@@ -191,6 +191,10 @@
"test": "mocha --require ts-node/register './server/src/test/**/*.ts'",
"deploy": "vsce publish"
},
+ "dependencies": {
---
- hosts: junos
gather_facts: no
connection: ansible.netcommon.netconf
tasks:
- name: run show command rpc
junipernetworks.junos.junos_command:
rpcs: get-l2ckt-connection-information
register: result
@ganeshrn
ganeshrn / netconf___init__.py
Last active March 22, 2021 12:45
netconf __init__.py diff
$git diff lib/ansible/plugins/netconf/__init__.py
diff --git a/lib/ansible/plugins/netconf/__init__.py b/lib/ansible/plugins/netconf/__init__.py
index 95442e60e9..24d04c6b82 100644
--- a/lib/ansible/plugins/netconf/__init__.py
+++ b/lib/ansible/plugins/netconf/__init__.py
@@ -32,8 +32,11 @@ try:
from ncclient.xml_ import to_xml, to_ele, NCElement
HAS_NCCLIENT = True
NCCLIENT_IMP_ERR = None
-except (ImportError, AttributeError) as err: # paramiko and gssapi are incompatible and raise AttributeError not ImportError
@ganeshrn
ganeshrn / xml_to_json.yaml
Created February 15, 2021 16:36
xml to json using xmltodict
---
- hosts: localhost
connection: local
gather_facts: false
tasks:
- name: set sample xml string
set_fact:
xml_var: |
<a>
<foo>test</foo>
@ganeshrn
ganeshrn / bgp_data_model_criteria.json
Created December 14, 2020 08:03
bgp_data_model_criteria
{
"patternProperties": {
".*" : { "$ref" : "#/definitions/router" }
},
"minProperties": 1,
"definitions": {
"router" : {
"type" : "object",
"properties": {
"bgp_as": {
@ganeshrn
ganeshrn / data_validation.yaml
Created December 14, 2020 07:58
Ansible JSON data validation
- name: validate bgp data data with jsonschema bgp model criteria
ansible.utils.validate:
data: "{{ hostvars }}"
criteria:
- "{{ lookup('file', './criterias/bgp_data_model_criteria.json') | from_json }}"
engine: ansible.utils.jsonschema
register: result
@ganeshrn
ganeshrn / nxos_interfaces_resource_module.yaml
Created December 14, 2020 06:59
nxos_interfaces_resource_module
- name: Configure interface with drift in admin up state
cisco.nxos.nxos_interfaces:
config:
- name: "{{ item['data_path'].split('.')[0] }}"
enabled: true
loop: "{{ result['errors'] }}"
when: "'errors' in result"