Found this script to replace whitespace with underscore:
#!/bin/sh
find . -type f -name "* *" -maxdepth 1| while read src; do mv "$src" `echo $src | tr " " "_"`; done
While using the geany editor I have been struggling on how to append a LF at the end of a search pattern. Finding the LF was not difficult just use \R at the position where a LF has been expected.
\R stands in this case either for LF or CR or LF and CR it matches any unicode character that stands for a newline Geany documentation
However I tried to append the same character for LF as replace hoping it would make a new line. I have been thought that it does not work this way.
One needs to be careful if dealing with regular expression, the correct syntax for an new line is
\n newline
\r carriage return
\t tab
Exploring ViM step by step. While saving files it is good if the path would be auto-completed. This can be accomplished with CTRL D or using CTRL E keyboard shortcut.
:w/CTRL+D/
If one is dealing with a large amount of physical interfaces on a NX-OS device, it might be a useful to create logical groups to configure several interfaces at one time. There is a useful command in the NX-OS software where a configuration could be inherited from a template. Imagine there are 500 interfaces that need a one additional line of configuration. Traditionally one would prepare a text file with the change and copy paste it into the configuration of each physical/logical interface on the switch.
The NX-OS software has a useful tool where it is possible to create a port configuration template and inherit this configuration on desired port.
The definition of a port profile looks like below:
configure
!
port-profile type ethernet SERVERS
switchport
no shut
spanning-tree port type edge
switchport mode access
description IS-MISSING
state enabled
!
Inheriting the port profile on a port is done following way:
configure
!
int e1/1-2
interit port-profile SERVERS
Any individual configuration made on the port overwrites the configuration of the port-profile, f.e. the description IS-MISSING can be overwritten in the port configuration with f.e. description auth1.example.net. Individual port configuration wins over port-profile configuration.
The inherited port-profile configuration is like a symlink to the port-profile and will not show up in the running configuration. To show the whole port configuration for f.e. port e1/1 following command needs to be used:
sh run int e1/1 expand-port-profile
Port profiles can be nested. However to keep things simply stupid I would rather not use nested port profiles, because while troubleshooting it adds a new level of complexity which is always bad when time is crucial.
Port profiles can be changed at all times, inherited profiles are changed at the same time on all included ports. For example if a NX-OS device had f.e. 2000 physical ports with one profile inherited, adding shutdown to the port profile would shut down all 2000 affected physical port where this profile has been applied. Port profiles are like a living piece configuration.
Ansible is a python framework for provisioning, deploying and change management, and overall configuration management. A major difference between Ansible and other similar tools f.e.: (chef, puppet, cfengine etc.) is, ansible is agentless. Agentless tool in this particular context means it is a too that has no requirement for a client counterpart on the target platform/appliance/hardware. Ansible uses the standard tools available on target platforms like f.e. SSH, Telnet, SNMP, API, to manage its configuration. This difference makes ansilbe the ideal tool for configuration management of networking equipment.
Here is a ansible network modules list for network device configuration.
A personal note I must admit I have just started using ansible for network equipment configuration. Ansible has been on my personal agenda for some months already. After some hours of reading the manual additional hours of testing it, it has not been straight forward for me to understand ansible concepts and usage techniques. I have began the evaluation of ansible for 2 times and have put it aside. All scripts for managing network equipment that I have written in the past have been written in expect. Expect has been doing good work for my networks over the last 10 years. These scripts are good enough for the things I deal with.
Using internal help
ansible-doc ios_config
ansible-doc ios_facts
Configuration files syntax
If writing configuration files, there are different 2 ways of defining variables and names. The INI way of defining variables, which looks like the example below:
R1.example.com
[backbonerouter]
R2.example.com
R4.example.com
[edgerouter]
R10.example.com
R20.example.com
R30.example.com
The headings in brackets are group names, which are used in classifying systems and decisions which systems are controlled at which time, and for what purpose.
YAML way of defining variables:
all:
router:
R1.example.com
children:
backbonerouter:
router:
R2.example.com:
R4.example.com:
edgerouter:
router:
R10.example.com:
R20.example.com:
R30.example.com:
Both syntax files are valid and you will see both used in different playbooks.
Default groups
There are two default groups: all and ungrouped. all contains every host. ungrouped contains all hosts that don’t have another group aside from all. Every host will always belong to at least 2 groups. Though all and ungrouped are always present, they can be implicit and not appear in group listings like group_names.
Ad hoc commands
An interesting command line feature is the ad-hoc commands where it is possible to send a command to a bunch of clients defined f.e. in a list. It works similar to a distributed shell.
Global configuration file
Starting f.e. ansible-playbook will search for a global configuration file in following directories:
~/ansible.cfg ~/.ansible.cfg /etc/ansible/ansible.cfg
The global configuration file will have configured entries like f.e.:
- inventory file (hosts)
- library path
- connection specific configuration (SSH, telnet, keys etc.)
All possible configuration options have been described at the ansible.cfg documentation page. These configurations can used used for the global ansible.cfg file.
Here some syntax related articles I found helpful while still working with TCL/expect scripts in networking environments.
The 1-st method to debug a expect scripts is done by setting exp_internal 1 in the script itself
exp_internal 1
The 2-nd debug method is adding -d command line option for executing the script
expect -d script.exp
Commenting out a passage in a expect script works like that:
set COMMENTED_OUT {
commented out stuff
}
or
proc COMMENTED_OUT {} {
commented out stuff...
}
tag