Skip to content

Instantly share code, notes, and snippets.

@thijsc
Created March 31, 2023 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thijsc/2a2131d8b106bdb0c2d78b1880d375b3 to your computer and use it in GitHub Desktop.
Save thijsc/2a2131d8b106bdb0c2d78b1880d375b3 to your computer and use it in GitHub Desktop.
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
ethernets:
ens1f0:
match:
macaddress: {{ hostvars[inventory_hostname]['interfaces']['ens1f0'] }}
ens1f1:
match:
macaddress: {{ hostvars[inventory_hostname]['interfaces']['ens1f1'] }}
bonds:
bond0:
interfaces: [ens1f0, ens1f1]
gateway4: {{ hostvars[inventory_hostname]['ansible_default_ipv4']['gateway'] }}
parameters:
mode: 802.3ad
transmit-hash-policy: layer3+4
nameservers:
addresses: [93.190.136.10,217.23.0.121]
addresses:
- {{ hostvars[inventory_hostname]['ip'] }}/27
{% if loadbalancer_configs is defined -%}
# Additional ips for loadbalancer below
{% for loadbalancer_config in loadbalancer_configs -%}
- {{ loadbalancer_config['frontend_ip'] }}/27
{% endfor -%}
{% endif -%}
---
- name: Apply netplan
command: netplan apply
---
- name: Install ifenslave-2.6
apt:
state: present
pkg:
- ifenslave-2.6
- net-tools
- name: Add bonding kernel module
modprobe:
name: bonding
state: present
- name: Ensure bonding is loaded after boot
lineinfile:
path: /etc/modules
line: "bonding"
state: present
- name: Set netplan config
template:
dest: /etc/netplan/01-netcfg.yaml
src: etc/netplan/01-netcfg.yaml.j2
owner: root
group: root
mode: 0644
notify: Apply netplan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment