Unverified Commit 932b3516 by Matjaz Gregoric Committed by Tobias Macey

Find name of default network interface to set MTU.

On Ubuntu 16.04, the default networks interface is not always called
eth0, depending on the hardware. The name of the default network
interface on some VM types on AWS is ens3, for example.

Determine the interface name using ip route command instead of
hardcoding to eth0.

Also, /etc/network/interfaces.d/<interface-name>.cfg files no longer
exist in Ubuntu 16.04. Use a script in /etc/network/if-up.d to
adjust the MTU value at startup instead.
parent 2fa76a2f
......@@ -30,24 +30,23 @@
tags:
- deploy
- name: Set the MTU to 1500 temporarily
shell: /sbin/ifconfig eth0 mtu 1500 up
- name: Get name of default network interface
shell: "ip route show 0/0 | awk '{print $NF}'"
register: get_interface_name
when: ansible_distribution in common_debian_variants
- name: Check for eth0.cfg
stat:
path: /etc/network/interfaces.d/eth0.cfg
register: eth0_cfg
- name: Set the MTU to 1500 temporarily
shell: "/sbin/ifconfig {{ get_interface_name.stdout }} mtu 1500 up"
when: ansible_distribution in common_debian_variants
- name: Set the MTU to 1500 inside eth0.cfg file
lineinfile:
dest: /etc/network/interfaces.d/eth0.cfg
regexp: "^post-up /sbin/ifconfig eth0 mtu 1500"
line: "post-up /sbin/ifconfig eth0 mtu 1500"
insertafter: "^iface"
when: ansible_distribution in common_debian_variants and eth0_cfg.stat.exists
- name: Set the MTU to 1500 permanently
template:
dest: /etc/network/if-up.d/mtu
src: mtu.j2
mode: 0755
owner: root
group: root
when: ansible_distribution in common_debian_variants
#
# End dealing with Jumbo frames issue in mixed MTU deployements in AWS
#
......
#!/bin/sh
ifconfig {{ get_interface_name.stdout }} mtu 1500
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment