Skip to content

Instantly share code, notes, and snippets.

View ganeshrn's full-sized avatar

Ganesh Nalawade ganeshrn

View GitHub Profile
@ganeshrn
ganeshrn / network_cli_enable_prompt_issue.diff
Created January 29, 2018 08:04
network_cli_enable_prompt_issue.diff
$ git diff lib/ansible/plugins/connection/network_cli.py
diff --git a/lib/ansible/plugins/connection/network_cli.py b/lib/ansible/plugins/connection/network_cli.py
index c07e6f7..66411d0 100644
--- a/lib/ansible/plugins/connection/network_cli.py
+++ b/lib/ansible/plugins/connection/network_cli.py
@@ -266,7 +266,10 @@ class Connection(ConnectionBase):
messages = ['updating play_context for connection']
if self._play_context.become is False and play_context.become is True:
auth_pass = play_context.become_pass
+ display.display("-- update_play_context -> auth_pass: %s" % auth_pass, log_only=True)
@ganeshrn
ganeshrn / openconfig_interfaces.py
Last active March 7, 2018 19:33
openconfig_interfaces module
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2018, Ansible by Red Hat, inc
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
@ganeshrn
ganeshrn / interfaces.yml
Last active March 7, 2018 19:36
interfaces task
---
- debug:
msg: "{{ config }}"
- name: validate the variant variable
fail:
msg: "missing required fact: variant"
when: variant is undefined
- name: Validate interfaces config in openconfig format
@ganeshrn
ganeshrn / interfaces_config.yml
Created March 7, 2018 19:27
interfaces config
---
config:
interfaces:
- interface:
config:
name: GigabitEthernet0/1
description: configured interface-1 by opnconfig_interfaces
enabled: True
- interface:
config:
@ganeshrn
ganeshrn / aruba_terminal.py
Created April 23, 2018 18:42
Aruba terminal regex fix
import re
ansi_re = [
# see ECMA-48 Section 5.4 (Control Sequences)
re.compile(br'((?:\x9b|\x1b\x5b)[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e])'),
re.compile(br'\x08.')
]
terminal_stdout_re = [
re.compile(br"[\r\n]?[\w]*\(.+\) ?#(?:\s*)(.*)$"),
$ git diff
diff --git a/bin/ansible-connection b/bin/ansible-connection
index ed6070b..57fd128 100755
--- a/bin/ansible-connection
+++ b/bin/ansible-connection
@@ -161,7 +161,7 @@ def main():
result = {}
messages = list()
socket_path = None
-
@ganeshrn
ganeshrn / yang2spec.json
Created June 5, 2018 11:20
openconfig-interfaces
{
"msg": {
"config_schema": {
"interfaces": {
"interface": {
"config": [
{
"description": null,
"enabled": true,
"loopback_mode": false,
@ganeshrn
ganeshrn / networl_cli.txt
Created June 5, 2018 16:47
network_cli code flow
There are multiple moving parts in this code flow.
To start with network_cli connection plugin is applicable for network platforms that support persistent
connection with the remote host across task.
The method called on connection object (connection.edit_config) is serialised in json string as per jsonrpc 2.0 spec [0]
and is send over to socket [1]. The receiving end of the socket is a daemon process called "ansible-connection"
which is spawned from task_executor [2] at the time of connection creation to the remote host.
"ansible-connection" receives the json string and calls handle_request method [3] on the object of JsonRpcServer class
module openconfig-interfaces {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/interfaces";
prefix "ocif";
// import some basic types
$ ansible-test network-integration --inventory ~/targets/inventory.network eos_config -vvvvve
>>> Environment Description
{}
Running eos_config integration test role
>>> Playbook: eos_config-l5XX7M.yml
- hosts: eos
gather_facts: False
roles:
- { role: eos_config }
Run command: ansible-playbook eos_config-l5XX7M.yml -i /Users/gnalawad/targets/inventory.network -e @integration_config.yml -vvvvv