Skip to content

Commit 8b141d3

Browse files
committed
Manifest documentation
1 parent 93c7d00 commit 8b141d3

File tree

7 files changed

+91
-13
lines changed

7 files changed

+91
-13
lines changed

README.md

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,85 @@ downloading (typically) kernel and initrd over HTTP instead of TFTP.
4747

4848
## Manifests
4949

50-
A manifest represents a machine to be provisioned/served. The behavior of built-in
51-
DHCP, TFTP and HTTP server is specific to a manifest, meaning that it varies based
52-
on source MAC/IP. Each host may see different content at `/something` path.
50+
A manifest represents a machine to be provisioned/served. The behavior of built-in DHCP, TFTP and HTTP server is
51+
specific to a manifest, meaning that it varies based on source MAC/IP. Each host may see different content
52+
at `/something` path.
5353

54-
Note that this is not a security feature and you should not host any sensitive content. MAC and IPs can be easily
54+
Note that this is not a security feature, and you should not host any sensitive content. MAC and IPs can be easily
5555
spoofed. In fact, netbootd includes a convenience feature to spoof source IP for troubleshooting purposes.
5656
Append `?spoof=<ip-address>` to HTTP request to see the response for a particular host. There is no TFTP counterpart of
5757
this feature.
5858

5959
Example manifests are included in the `examples/` directory.
6060

61+
### Anatomy of a manifest
62+
63+
```yaml
64+
---
65+
# ID can be anything unique, URL-safe, used to identify it for HTTP API
66+
id: ubuntu-1804
67+
68+
### DHCP options - used for DHCP responses from netbootd
69+
# IP address with subnet (CIDR) to give out
70+
ipv4: 192.168.17.101/24
71+
# Hostname (without domain part) (Option 12)
72+
hostname: ubuntu-machine-1804
73+
# Domain part (used for hostname) (Option 15)
74+
domain: test.local
75+
# Lease duration is used as Option 51
76+
# Note that netbootd is a static-assignment server, which does not prevent IP conflicts.
77+
leaseDuration: 1h
78+
# The MAC addresses which map to this manifest
79+
# List multiple for machine with multiple NICs, if not sure which one boots first
80+
mac:
81+
- 00:15:5d:bd:be:15
82+
- aa:bb:cc:dd:ee:fc
83+
# Domain name servers (DNS) in the order of preference (Option 6)
84+
dns:
85+
- 1.2.3.4
86+
- 3.4.5.6
87+
# Routers in the order of preference (Option 3), more than one is rare
88+
router:
89+
- 192.168.17.1
90+
# NTP servers in the order of preference (Option 42), IP address required
91+
ntp:
92+
- 192.168.17.1
93+
# Whether a bundled iPXE bootloader should be served first (before bootFilename).
94+
# When iPXE is loaded, it does DHCP again and netbootd detects its client string
95+
# to break the boot loop and serve bootFilename instead.
96+
ipxe: true
97+
# The name of NBP file name, server over TFTP from "next server",
98+
# which netbootd automatically points to be itself.
99+
# This should map to a "mount" below.
100+
bootFilename: install.ipxe
101+
102+
# Mounts define virtual per-host (per-manifest) paths that are acessible
103+
# over both TFTP and HTTP but only from the IP address of in this manifest.
104+
# Each mount can be either a proxy mount (HTTP/HTTPS proxy) or a content mount (static).
105+
mounts:
106+
- path: /netboot
107+
# When true, all paths starting with this prefix use this mount.
108+
pathIsPrefix: true
109+
# When proxy is defined, these requests are proxied to a HTTP/HTTPS address.
110+
proxy: http://archive.ubuntu.com/ubuntu/dists/bionic-updates/main/installer-amd64/current/images/hwe-netboot/ubuntu-installer/amd64/
111+
# When true, the proxy path defined above gets a suffix to the Path prefix appended to it.
112+
proxyAppendSuffix: true
113+
114+
- path: /install.ipxe
115+
# The templating context provides access to: .LocalIP, .RemoteIP, .HttpBaseUrl and .Manifest.
116+
# Sprig functions are available: masterminds.github.io/sprig
117+
content: |
118+
#!ipxe
119+
# See https://ipxe.org/scripting for iPXE commands/scripting documentation
120+
121+
set base {{ .HttpBaseUrl }}/netboot
122+
123+
{{ $hostnameParts := splitList "." .Manifest.Hostname }}
124+
kernel ${base}/linux gfxpayload=800x600x16,800x600 initrd=initrd.gz auto=true url={{ .HttpBaseUrl.String }}/preseed.txt netcfg/get_ipaddress={{ .Manifest.IPv4.IP }} netcfg/get_netmask={{ .Manifest.IPv4.Netmask }} netcfg/get_gateway={{ first .Manifest.Router }} netcfg/get_nameservers="{{ .Manifest.DNS | join " " }}" netcfg/disable_autoconfig=true hostname={{ first $hostnameParts }} domain={{ rest $hostnameParts | join "." }} DEBCONF_DEBUG=developer
125+
initrd ${base}/initrd.gz
126+
boot
127+
```
128+
61129
## HTTP API
62130
63131
In this preview/development version, this HTTP API does not support authentication.

dhcpd/handler.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ func (server *Server) HandleMsg4(buf []byte, oob *ipv4.ControlMessage, peer net.
118118
resp.Options.Update(dhcpv4.OptRouter(manifest.Router...))
119119
}
120120

121+
// NTP
122+
if req.IsOptionRequested(dhcpv4.OptionNTPServers) {
123+
resp.Options.Update(dhcpv4.OptNTPServers(manifest.NTP...))
124+
}
125+
121126
// NBP
122127
if req.IsOptionRequested(dhcpv4.OptionTFTPServerName) && !manifest.Suspended {
123128
resp.Options.Update(dhcpv4.OptTFTPServerName(localIp.String()))

examples/ubuntu-1804.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ router:
2727

2828
# in the "order of preference"
2929
ntp:
30-
- pool.ntp.org
30+
- 192.168.17.1
3131

3232
ipxe: true
3333
bootFilename: install.ipxe

examples/ubuntu-2004-ram.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ router:
2424

2525
# in the "order of preference"
2626
ntp:
27-
- pool.ntp.org
27+
- 192.168.17.1
2828

2929
ipxe: true
3030
bootFilename: install.ipxe

examples/ubuntu-2004.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ router:
2323

2424
# in the "order of preference"
2525
ntp:
26-
- pool.ntp.org
26+
- 192.168.17.1
2727

2828
ipxe: true
2929
bootFilename: install.ipxe

manifest/ipnet.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"net"
55
)
66

7-
// An IPNet represents an IP network.
87
type IPWithNet struct {
98
IP net.IP
109
Net net.IPNet

manifest/schema.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"time"
1010
)
1111

12+
// Manifest represents user-supplied per-host manifest information.
1213
// go-yaml accepts completely lowercase version of keys but is not case-insensitive
1314
// https://github.com/go-yaml/yaml/issues/123
1415
// some fields are forcefully mapped to camelCase instead of CamelCase and camelcase
@@ -21,13 +22,14 @@ type Manifest struct {
2122
MAC []HardwareAddr
2223
DNS []net.IP
2324
Router []net.IP
24-
NTP []string
25+
NTP []net.IP
2526
Ipxe bool
2627
BootFilename string `yaml:"bootFilename"`
2728
Mounts []Mount
2829
Suspended bool
2930
}
3031

32+
// Mount represents a path exposed via TFTP and HTTP.
3133
type Mount struct {
3234
// Path at which to select this mount.
3335
Path string
@@ -88,12 +90,16 @@ func (m Mount) ProxyDirector() (func(req *http.Request), error) {
8890
return director, nil
8991
}
9092

91-
// Content template is evaluated with ContentContext
93+
// ContentContext is the template context available for static Content embedded in Manifests.
9294
type ContentContext struct {
93-
LocalIP net.IP
94-
RemoteIP net.IP
95+
// Address of netbootd server
96+
LocalIP net.IP
97+
// Address of client
98+
RemoteIP net.IP
99+
// Base URL to the HTTP service (IP and port) - not API
95100
HttpBaseUrl *url.URL
96-
Manifest *Manifest
101+
// Copy of Manifest
102+
Manifest *Manifest
97103
}
98104

99105
// Return best matching Mount, respecting exact and prefix-based mount paths.

0 commit comments

Comments
 (0)