Documentation
¶
Overview ¶
Package inventory reads hosts from a Markdown file, for running roles without a manager:
# Databases - db1 ubuntu@10.0.0.5 env=prod - db2 ubuntu@10.0.0.6:2222 env=prod # Web - web1 deploy@web1.internal env=staging - web2.internal
Headings are groups, nested by level. Each bullet is a host: an optional name, the SSH address as [user@]host[:port], and KEY=VALUE labels. A bullet with only an address, or an alias from ~/.ssh/config, uses it as the name.
A "user:" or "identity:" line sets the SSH user or private key file for the hosts that follow in its group and subgroups, or for every host when it comes before the first heading:
# Production identity: ~/.ssh/prod_ed25519 user: ubuntu - db1 10.0.0.5 - db2 10.0.0.6 identity=~/.ssh/db2_key
A host's own user@ or identity= wins over its group's.
Labels are also the variables roles use as {{ name }}. A "vars:" line sets them for a group, and a host's own KEY=VALUE wins:
# Shop vars: domain=shop.example.com app_port=3000 - web1 deploy@10.0.0.5 - web2 deploy@10.0.0.6 app_port=4000 title="Shop two"
Quote values that contain spaces or commas. Other text is notes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Host ¶
type Host struct {
Name string `json:"name"`
User string `json:"user,omitempty"` // empty: ~/.ssh/config or the local user
Address string `json:"address"`
Port int `json:"port,omitempty"` // 0: ~/.ssh/config or 22
Labels map[string]string `json:"labels,omitempty"`
Groups []string `json:"groups,omitempty"`
// Identity is the private key file as written, before ~ and ${VAR}
// are expanded on the machine that runs korta.
Identity string `json:"identity,omitempty"`
Line int `json:"line"`
}
Host is one inventory entry.