As well as static files, you may create templated ZTP configuration or script files. This is useful if your file needs to reference site-specific values such as an assigned IP addresses.
Any file uploaded via the web UI, or into the downloads directly with a file suffix of .j2 (Jinja2) are automatically templated.
For example, a basic Cumulus templated provisioning script may look like:
cumulus_setup.sh.j2
#!/bin/bash curl tftp://{{ nom_remote_server }}/cumulus_interfaces > /etc/network/interfaces
Note that the .j2 suffix is stripped when serving templated files to devices.
Template variables
{{ nom_remote_server }}
- Address of provisioning interface on Operations Manager
- Example: 10.0.0.1
{{ nom_remote_interface }}
- Name of provisioning interface on Operations Manager
- Example: net2
{{ nom_remote_netmask }}
- Netmask of provisioning interface on Operations Manager (and netmask assigned in DHCP offers)
- Example: 255.255.255.0
{{ nom_remote_netmask_cidr }}
- CIDR format netmask (prefix length) of provisioning interface on Operations Manager
- Example: 24
{{ nom_remote_ntp_server }}
- Address of NTP server assigned in DHCP offers (same as nom_remote_server)
- Example: 10.0.0.1
{{ nom_remote_dns_server }}
- Address of DNS server assigned in DHCP offers (same as nom_remote_server)
- Example: 10.0.0.1
{{ nom_device_ipv4_address }}
- DHCP address assigned to target device
- Example: 10.0.0.13
{{ nom_remote_ssh_pub_key }}
- Public part of an auto-generated SSH keypair on the remote node, which may be injected into device config to pre-authenticate the node for any post-provisioning activities
- Example: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDHO50MVT4A9Nl7vjDlS+76LgDBtEDm+J1gaQPNiIV62CGA6cm5wASDiddY/KZkHAKOtH8Oxyv6o1dLqi0ztYI2xAjp0fEDFoo5m0ESJISfXaEIGXzebuNvijcW3cpfbd0oYO0SfRu/mRN5Ob5W2YOCzypzO+HpD9y3f0JNff6BGXGL3EfcPAKeuDoVRatXiuuyYfm6pq7Zli5NsNXjaF+9ncoYo2atLCY0YtO/E1uiDFQnkR0WDe6rfugh7ZGiyRxuOEOdxI6m1hZwcR6HwcchQf0VZwYNZlOtDGi5rm22528vFQPLDMLUDjkCji953sD+bFsikuDLCF0SoiEU4PAT root@platypus.robertw.bne.opengear.com
{{ nom_device_hostname }}
- Hostname advertised by target device
- Example: router
{{ nom_device_mac_address }}
- MAC Address of target device
- Example: 00:12:34:56:78:9A
Comments
0 comments
Article is closed for comments.