[194881] in North American Network Operators' Group
Re: Templating/automating configuration
daemon@ATHENA.MIT.EDU (Alexis Letessier)
Tue Jun 6 19:20:43 2017
X-Original-To: nanog@nanog.org
From: Alexis Letessier <alexis.letessier@gmail.com>
Date: Tue, 6 Jun 2017 23:03:14 +0200
In-Reply-To: <82C0CE81789FE64D8F4D15263191829715CDE7BB@MSG6.westman.int>
To: Graham Johnston <johnstong@westmancom.com>
Cc: "nanog@nanog.org" <nanog@nanog.org>
Errors-To: nanog-bounces@nanog.org
Go templates: http://golang.org <http://golang.org/> Fast and simple =
with gRPC and other good stuff like kelsey=E2=80=99s confd (a daemon =
that watches for changes and update templates)
% go doc text/template
package template // import "text/template"
Package template implements data-driven templates for generating textual
output.
To generate HTML output, see package html/template, which has the same
interface as this package but automatically secures HTML output against
certain attacks.
Templates are executed by applying them to a data structure. Annotations =
in
the template refer to elements of the data structure (typically a field =
of a
struct or a key in a map) to control execution and derive values to be
displayed. Execution of the template walks the structure and sets the
cursor, represented by a period '.' and called "dot", to the value at =
the
current location in the structure as execution proceeds.
The input text for a template is UTF-8-encoded text in any format.
"Actions"--data evaluations or control structures--are delimited by "{{" =
and
"}}"; all text outside actions is copied to the output unchanged. Except =
for
raw strings, actions may not span newlines, although comments can.
Once parsed, a template may be executed safely in parallel.
Here is a trivial example that prints "17 items are made of wool".
type Inventory struct {
Material string
Count uint
}
sweaters :=3D Inventory{"wool", 17}
tmpl, err :=3D template.New("test").Parse("{{.Count}} items are made =
of {{.Material}}")
if err !=3D nil { panic(err) }
err =3D tmpl.Execute(os.Stdout, sweaters)
if err !=3D nil { panic(err) }
Alexis
> On 6 Jun 2017, at 15:22, Graham Johnston <johnstong@westmancom.com> =
wrote:
>=20
> Short of complete SDN, for those of you that have some degree of =
configuration templating and/or automation tools what is it that you =
run? I'm envisioning some sort of tool that let's me define template =
snippets of configuration and aids in their deployment to devices. I'm =
okay doing the heaving lifting in defining everything, I'm just looking =
for the tool that stitches it together and hopefully makes things a =
little less error prone for those who aren't as adept.
>=20
> Graham Johnston
> Network Planner
> Westman Communications Group
> 204.717.2829
> johnstong@westmancom.com<mailto:johnstong@westmancom.com>
>=20