-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Replace Ubuntu initialization with Debian logic
* Use the Vagrant generated private key to access boxes (update Ansible inventory)
- Loading branch information
Showing
6 changed files
with
152 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
echo -n 'Starting initial config ' && date | ||
|
||
# (Overwrite resolved config to remove DNS stuff) | ||
# cat <<SCRIPT > /etc/systemd/resolved.conf | ||
# [Resolve] | ||
# DNS= | ||
# FallbackDNS= | ||
# Domains= | ||
# DNSOverTLS=no | ||
# Cache=yes | ||
# DNSStubListener=yes | ||
# SCRIPT | ||
# systemctl restart systemd-resolved | ||
# Set persistent hostname | ||
hostnamectl set-hostname {{ inventory_hostname }} | ||
# Update APT and install netplan | ||
apt-get update -qq | ||
apt-get install -qq nplan | ||
{% if netlab_net_tools|default(False) %} | ||
# | ||
# Install net-tools (arp, route...) | ||
# | ||
if which arp; then | ||
echo "net-tools already installed" | ||
else | ||
apt-get install -qq net-tools | ||
fi | ||
if which traceroute; then | ||
echo "traceroute already installed" | ||
else | ||
apt-get install -qq traceroute | ||
fi | ||
{% endif %} | ||
{% if netlab_lldp_enable|default(False) %} | ||
# | ||
# Enable LLDP | ||
# | ||
if systemctl is-active --quiet lldpd.service; then | ||
echo "LLDP already installed" | ||
else | ||
apt-get install -qq lldpd | ||
fi | ||
cat <<CONFIG >/etc/lldpd.d/system.conf | ||
configure lldp tx-interval 30 | ||
configure lldp tx-hold 3 | ||
configure system interface pattern *,!eth0,eth* | ||
CONFIG | ||
systemctl enable lldpd | ||
systemctl restart lldpd | ||
{% endif %} | ||
# Sysctl settings: IPv4/IPv6 forwarding, IPv6 LLA | ||
# | ||
{% set pkt_fwd = "1" if role|default("host") == "router" else "0" %} | ||
cat <<SCRIPT > /etc/sysctl.d/10-netsim.conf | ||
net.ipv4.ip_forward={{ pkt_fwd }} | ||
net.ipv6.conf.all.forwarding={{ pkt_fwd }} | ||
{% if loopback.ipv6 is defined %} | ||
net.ipv6.conf.lo.disable_ipv6=0 | ||
{% endif %} | ||
{% for l in interfaces|default([]) %} | ||
{% if l.ipv6 is defined %} | ||
net.ipv6.conf.{{ l.ifname }}.disable_ipv6=0 | ||
{% endif %} | ||
{% endfor %} | ||
SCRIPT | ||
sysctl -p /etc/sysctl.d/10-netsim.conf | ||
# Loopback addressing, JvB commented out | ||
{% if loopback.ipv4 is defined or loopback.ipv6 is defined %} | ||
cat <<SCRIPT > /etc/netplan/02-loopback.yaml | ||
network: | ||
version: 2 | ||
renderer: networkd | ||
ethernets: | ||
lo: | ||
addresses: | ||
{% if 'ipv4' in loopback %} | ||
- {{ loopback.ipv4 }} | ||
{% endif %} | ||
{% if 'ipv6' in loopback %} | ||
- {{ loopback.ipv6 }} | ||
{% endif %} | ||
SCRIPT | ||
{% endif %} | ||
# Interface addressing | ||
{% for l in interfaces|default([]) if (l.ipv4 is defined or l.ipv6 is defined or l.dhcp is defined)%} | ||
cat <<SCRIPT > /etc/netplan/03-eth-{{ l.ifname }}.yaml | ||
network: | ||
version: 2 | ||
renderer: networkd | ||
ethernets: | ||
{{ l.ifname }}: | ||
{% if l.dhcp.client.ipv4|default(False) %} | ||
dhcp4: true | ||
{% endif %} | ||
{% if l.dhcp.client.ipv6|default(False) %} | ||
dhcp6: true | ||
{% endif %} | ||
{% for af in ('ipv4','ipv6') if af in l %} | ||
{% if loop.first %} | ||
addresses: | ||
{% endif %} | ||
- {{ l[af] }} | ||
{% endfor %} | ||
{% if l.mtu is defined %} | ||
mtu: {{ l.mtu }} | ||
{% endif %} | ||
SCRIPT | ||
{% endfor %} | ||
# Add routes to IPv4 address pools pointing to the first neighbor on the first link | ||
{% for ifdata in interfaces|default([]) if ifdata.gateway is defined %} | ||
cat <<SCRIPT > /etc/netplan/04-routes-{{ ifdata.ifname }}.yaml | ||
network: | ||
version: 2 | ||
renderer: networkd | ||
ethernets: | ||
{{ ifdata.ifname }}: | ||
routes: | ||
{% for name,pool in pools.items()|default({}) %} | ||
{% for af,pfx in pool.items() if af == 'ipv4' and name != 'mgmt' and name != 'router_id' %} | ||
- to: {{ pfx }} | ||
via: {{ ifdata.gateway.ipv4|ipaddr('address') }} | ||
{% endfor %} | ||
{% endfor %} | ||
SCRIPT | ||
{% endfor %} | ||
echo -n 'Starting netplan generate ' && date | ||
netplan generate | ||
echo -n 'Starting netplan apply ' && date | ||
nohup netplan apply & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters