Skip to content

Instantly share code, notes, and snippets.

View trishnaguha's full-sized avatar
🎯

Trishna Guha trishnaguha

🎯
View GitHub Profile
@trishnaguha
trishnaguha / basic.aiml
Last active September 13, 2015 14:44 — forked from fvnilo/basic.aiml
PyAIML basis
<?xml version="1.0" encoding="utf-8"?>
<aiml version="1.0.1">
<category>
<pattern>HELLO</pattern>
<template>
<random>
<li>Hi, human !</li>
<li>Hello to you, good person</li>
<li>Hello there !</li>
<li>Ah finally a friend to talk to ! Hello !</li>
@trishnaguha
trishnaguha / python-101-problems
Last active December 3, 2016 16:57
PyLadies Python 101 Problems
Python 101 Problems:
1. Take a LIST of integers and find SUM of the numbers of the list.
Suggestion: pass the list as argument to the function you will define to solve the problem
2. Take a LIST of integers and characters (Alphanumeric) and Find SUM of the numbers of the list.
Suggestion: Create two functions: One function will return number from the list. Another function will find out the sum of the numbers.
3. Find out number of characters in a word without using len method.
Suggestion: Pass the string/word as argument to the function.
[tguha@localhost docker-remote-access]$ ls
ansible.cfg inventory remote-access.yml role-secure-docker-daemon
[tguha@dhcp193-190 docker-remote-access]$ cat ansible.cfg
[defaults]
inventory=inventory
[tguha@dhcp193-190 docker-remote-access]$ cat inventory
[daemonhost]
'IP_OF_DAEMON_HOST' ansible_ssh_private_key_file='PRIVATE_KEY_FILE'
[tguha@dhcp193-190 docker-remote-access]$ cat remote-access.yml
---
@trishnaguha
trishnaguha / create-vm.yml
Created February 14, 2017 11:06
Create VM Playbook
---
# This playbook creates VM from the QCOW2 Image
- name: Create VM Playbook
hosts: localhost
become: yes
become_method: sudo
vars_files:
- vars/guests.yml
#!/usr/bin/python
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
cli:
transport: cli
nxapi:
transport: nxapi
use_ssl: no
port: 8080
ansible_ssh_user: admin
ansible_ssh_pass: admin
@trishnaguha
trishnaguha / vyos_l3_interface WIP
Created February 16, 2018 15:52
vyos_l3_interface WIP
- set interfaces ethernet eth0 address '192.168.0.1/24'
"""
+import socket
+import q
from copy import deepcopy
from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.network.common.utils import remove_default_spec
+from ansible.module_utils.network.common.utils import validate_ip_address, remove_default_spec
from ansible.module_utils.network.vyos.vyos import load_config, run_commands
@trishnaguha
trishnaguha / gist:4461615d562e10e4bd72a6df5f45ae9e
Last active February 26, 2018 16:22
Playbook for accessing docker daemon remotely
[tguha@localhost docker-remote-access]$ ls
ansible.cfg inventory remote-access.yml role-secure-docker-daemon
[tguha@dhcp193-190 docker-remote-access]$ cat ansible.cfg
[defaults]
inventory=inventory
[tguha@dhcp193-190 docker-remote-access]$ cat inventory
[daemonhost]
'IP_OF_DAEMON_HOST' ansible_ssh_private_key_file='PRIVATE_KEY_FILE'
[tguha@dhcp193-190 docker-remote-access]$ cat remote-access.yml
---
+def get_vlan_int(interfaces):
+ vlan_int = []
+ for i in interfaces.split(','):
+ if 'eth' in i.lower() and '-' in i:
+ int_range = i.split('-')
+ stop = int((int_range)[1])
+ start = int(int_range[0].split('/')[1])
+ eth = int_range[0].split('/')[0]
+ for r in range(start, stop + 1):
+ vlan_int.append(eth + '/' + str(r))
@trishnaguha
trishnaguha / nxos_install_os with connection local
Created May 17, 2018 16:00
nxos_install_os with connection local
TASK [nxos_install_os] ******************************************************************************************************************************************************
task path: /home/tguha/RHWork/ansible/hacking/example/nxosinstall.yml:8
<nxos3k> connection transport is cli
<nxos3k> using connection plugin network_cli (was local)
<nxos3k> starting connection from persistent connection plugin
<nxos3k> local domain socket does not exist, starting it
<nxos3k> control socket path is /home/tguha/.ansible/pc/f9eaf71d8e
<nxos3k> <nxos3k> ESTABLISH CONNECTION FOR USER: admin on PORT 22 TO nxos3k
<nxos3k> <nxos3k> ssh connection done, setting terminal
<nxos3k> <nxos3k> loaded terminal plugin for network_os nxos