Skip to content

Instantly share code, notes, and snippets.

View ganeshrn's full-sized avatar

Ganesh Nalawade ganeshrn

View GitHub Profile

Installing Fedora on MacOS

This article demonstrates how to install Fedora Linux on MacOS.

Specifically we will use

  • a macbook with m1 (arm/apple silicon) processor & 32GB ram
  • macOS Sonoma 14.0
  • Fedora Linux beta
  • UTM as the virtualization tool
@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 / 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 / validate_task_run_output.txt
Last active December 14, 2020 08:07
validate task run output
TASK [validate interface for admin state] ***********************************************************************************************************
Monday 14 December 2020 11:05:37 +0530 (0:00:01.886) 0:00:27.014 *******
fatal: [nxos]: FAILED! => {"changed": false, "errors": [{"data_path": "Ethernet2/1.admin_state", "expected": "up", "found": "down", "json_path": "$.Ethernet2/1.admin_state", "message": "'down' does not match 'up'", "relative_schema": {"pattern": "up", "type": "string"}, "schema_path": "patternProperties.^.*.properties.admin_state.pattern", "validator": "pattern"}, {"data_path": "Ethernet2/10.admin_state", "expected": "up", "found": "down", "json_path": "$.Ethernet2/10.admin_state", "message": "'down' does not match 'up'", "relative_schema": {"pattern": "up", "type": "string"}, "schema_path": "patternProperties.^.*.properties.admin_state.pattern", "validator": "pattern"}], "msg": "Validation errors were found.\nAt 'patternProperties.^.*.properties.admin_state.pattern' 'down' does not