NAME

create_cloginrc - create cloginrc files for RANCID

VERSION

Version v0.3.0

SYNOPSIS

create_loginrc -h
create_loginrc [options] credentials.csv > .cloginrc
create_loginrc [options] < credentials.csv > .cloginrc

OPTIONS

--help

Print a brief help message and exit.

--manual

Print the manual page and exit.

--columns col1[,col2[,...]]

If the CSV file does not contain the column names in the first line, you can provide them with this option, separated with comma and in the same order as the columns in the CSV file.

--templatefile filename

Use file filename to specify the templates to use instead of the builtin templates.

DESCRIPTION

This program takes a CSV (comma separated value) file and turns it into something that is suitable to use as credentials file (.cloginrc) for RANCID.

CSV Input

The CSV file may have arbitrary columns as long as there is a column named type, which is used to switch between different templates, and a column for every variable used in the templates.

The column names should either be given in the first line of the CSV file or with the command line options --columns separated by comma and in the same order as the columns of the CSV file.

If the output of some template variables needs escape sequences as for instances the .cloginrc file for RANCID for left and right braces, space, ampersand and backslash the escape sequence should be given in the CSV file.

Templates

The templates are a list of text lines that start with a typename followed by a colon and some text which is expanded with the Template Toolkit.

For each input line of the CSV file template lines corresponding to the value of the type column are expanded by the Template Toolkit using the other columns of the CSV line to fill in the variables.

Take a look at the following template:

cisco:### [% name %] (cisco) ###
cisco:add method [% name %] {ssh}
cisco:add user [% name %] {[% user %]}
cisco:add password [% name %] {[% password %]} {[% enablepw %]}
*:%%% [% name %] uses type [% type %] for which no template is defined.

This template would be selected if the type column had the value "cisco". The CSV file would need to contain at least the columns type, name, user, password and enablepw to expand the template properly.

The special type * in the last line of the example is a catch all that matches any type without an explicit definition in the templates.