]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
common: Refactor MTU setting
authorDavid Galloway <dgallowa@redhat.com>
Thu, 24 Mar 2022 19:14:26 +0000 (15:14 -0400)
committerDavid Galloway <dgallowa@redhat.com>
Thu, 24 Mar 2022 20:23:20 +0000 (16:23 -0400)
This allows us to define an 'mtu' per machine type in group_vars.

Signed-off-by: David Galloway <dgallowa@redhat.com>
roles/common/tasks/secondary_nic.yml

index 557201b5f100c5e396f07dac4b5cd03bada2a736..afd1cbb02a7812389626be55cc65ca61bc4d2016 100644 (file)
@@ -27,9 +27,6 @@
   with_items: "{{ ethtool_grep_output.results }}"
   when: item.rc == 0
 
-# Default to 1500
-- set_fact: mtu=1500
-
 - name: "Check if {{ nic_to_configure }} is 10Gb"
   shell: "ethtool {{ nic_to_configure }} | grep Speed | awk '{ print $2 }'"
   register: nic_to_configure_speed
@@ -39,6 +36,7 @@
 - name: Set MTU to 9000 if 10Gb
   set_fact: mtu=9000
   when:
+    - mtu is not defined
     - nic_to_configure_speed is defined
     - (nic_to_configure_speed.stdout == '10000Mb/s' or nic_to_configure_speed.stdout == '25000Mb/s')
 
@@ -55,7 +53,7 @@
 
 # Can't set MTU for DHCP interfaces on Ubuntu in /etc/network/interfaces
 - name: Set MTU on Ubuntu
-  shell: "ifconfig {{ nic_to_configure }} mtu {{ mtu }}"
+  shell: "ifconfig {{ nic_to_configure }} mtu {{ mtu|default('1500') }}"
   when: ansible_os_family == 'Debian'
 
 - name: "Bounce {{ nic_to_configure }}"
@@ -78,7 +76,7 @@
     - { regexp: '^DEVICE=', line: 'DEVICE={{ nic_to_configure }}' }
     - { regexp: '^BOOTPROTO=', line: 'BOOTPROTO=dhcp' }
     - { regexp: '^ONBOOT=', line: 'ONBOOT=yes' }
-    - { regexp: '^MTU=', line: 'MTU={{ mtu }}' }
+    - { regexp: '^MTU=', line: 'MTU={{ mtu|default("1500") }}' }
   when:
     - nic_to_configure is defined
     - ansible_os_family == 'RedHat'