]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
Move secondary-nic tag to common role
authorDavid Galloway <dgallowa@redhat.com>
Thu, 24 Mar 2022 19:00:47 +0000 (15:00 -0400)
committerDavid Galloway <dgallowa@redhat.com>
Thu, 24 Mar 2022 19:01:12 +0000 (15:01 -0400)
So I can use it for LRC hosts

Signed-off-by: David Galloway <dgallowa@redhat.com>
roles/common/README.rst
roles/common/tasks/main.yml
roles/common/tasks/secondary_nic.yml [new file with mode: 0644]
roles/testnode/README.rst
roles/testnode/tasks/main.yml
roles/testnode/tasks/secondary_nic.yml [deleted file]

index d6b80bc62784ea3ced0a684724089df101c853c4..5659116f6de8078d5d31a9eac521f535e2735045 100644 (file)
@@ -79,6 +79,11 @@ tasks OS-agnostic.  They variables are mostly self-explanatory and defined in
       - nagios-nrpe-server
       - nagios-plugins-basic
 
+Definining ``secondary_nic_mac`` as a hostvar will configure the corresponding NIC to use DHCP.  This 
+assumes you've configured a static IP definition on your DHCP server and only supports one additional NIC at this time::
+
+    secondary_nic_mac: ''
+
 Tags
 ++++
 
@@ -101,6 +106,9 @@ nagios
     applicable).  ``monitoring-scripts`` is also always run with this tag since
     NRPE isn't very useful without them.
 
+secondary-nic
+    Configure secondary NIC if ``secondary_nic_mac`` is defined.
+
 To Do
 +++++
 
index 9c4200f63b3c1afbd4593f6f65b058df31576751..8d25598051db2935eb9d533ac73278500e0e6e19 100644 (file)
@@ -60,3 +60,9 @@
         (selinux_status is defined and selinux_status.stdout != "Disabled")
   tags:
     - nagios
+
+- name: include secondary NIC config tasks
+  import_tasks: secondary_nic.yml
+  when: secondary_nic_mac is defined
+  tags:
+    - secondary-nic
diff --git a/roles/common/tasks/secondary_nic.yml b/roles/common/tasks/secondary_nic.yml
new file mode 100644 (file)
index 0000000..8eb2ef6
--- /dev/null
@@ -0,0 +1,80 @@
+---
+- name: Make sure ethtool is installed
+  package:
+    name: ethtool
+    state: latest
+
+- name: grep ethtool for secondary NIC MAC address
+  shell: "ethtool -P {{ item }} | awk '{ print $3 }' | grep -q -i '{{ secondary_nic_mac }}'"
+  register: ethtool_grep_output
+  with_items: "{{ ansible_interfaces }}"
+  failed_when: false
+  changed_when: false
+
+- name: Define net_to_configure var
+  set_fact:
+    nic_to_configure: "{{ item.item }}"
+  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
+  changed_when: false
+
+# Assume jumbo frames if 10Gb
+- name: Set MTU to 9000 if 10Gb
+  set_fact: mtu=9000
+  when:
+    - nic_to_configure_speed is defined
+    - (nic_to_configure_speed.stdout == '10000Mb/s' or nic_to_configure_speed.stdout == '25000Mb/s')
+
+- name: "Write Ubuntu network config for {{ nic_to_configure }}"
+  blockinfile:
+    path: /etc/network/interfaces
+    block: |
+      auto {{ nic_to_configure }}
+      iface {{ nic_to_configure }} inet dhcp
+  register: wrote_network_config
+  when:
+    - nic_to_configure is defined
+    - ansible_os_family == 'Debian'
+
+# 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 }}"
+  when: ansible_os_family == 'Debian'
+
+- name: "Bounce {{ nic_to_configure }}"
+  shell: "ifdown {{ nic_to_configure }} && ifup {{ nic_to_configure }}"
+  when:
+    - wrote_network_config is changed
+    - ansible_os_family == 'Debian'
+
+- name: "Write RHEL/CentOS network config for {{ nic_to_configure }}"
+  lineinfile:
+    path: "/etc/sysconfig/network-scripts/ifcfg-{{ nic_to_configure }}"
+    create: yes
+    owner: root
+    group: root
+    mode: 0644
+    regexp: "{{ item.regexp }}"
+    line: "{{ item.line }}"
+  register: wrote_network_config
+  with_items:
+    - { regexp: '^DEVICE=', line: 'DEVICE={{ nic_to_configure }}' }
+    - { regexp: '^BOOTPROTO=', line: 'BOOTPROTO=dhcp' }
+    - { regexp: '^ONBOOT=', line: 'ONBOOT=yes' }
+    - { regexp: '^MTU=', line: 'MTU={{ mtu }}' }
+  when:
+    - nic_to_configure is defined
+    - ansible_os_family == 'RedHat'
+
+- name: "Bounce {{ nic_to_configure }}"
+  shell: "ifdown {{ nic_to_configure }}; ifup {{ nic_to_configure }}"
+  when:
+    - wrote_network_config is changed
+    - ansible_os_family == 'RedHat'
index 857bf96a488b5f7f093c9430b5e1d509f0a9abe2..81faaff2e0c48dcc62214354b5fe5d599805e934 100644 (file)
@@ -207,11 +207,6 @@ The latter is only done if ``lab_domain`` is defined::
 
     lab_domain: ''
 
-Up until recently, testnodes only had one uplink.  Definining ``secondary_nic_mac`` as a hostvar will configure the corresponding NIC to use DHCP.  This 
-assumes you've configured a static IP definition on your DHCP server and only supports one additional NIC at this time::
-
-    secondary_nic_mac: ''
-
 A dictionary of drives/devices you want to partition.  ``scratch_devs`` is not required.  All other values are self-explanatory given this example::
 
     # Example:
@@ -355,9 +350,6 @@ remove-ceph
 repos
     Perform all repo related tasks. Creates and manages our custom repo files.     
 
-secondary-nic
-    Configure secondary NIC if ``secondary_nic_mac`` is defined.
-
 selinux
     Configure selinux on yum systems.    
 
index 2cc28887cd7dc359c6568287b102564d334afea3..fb625144b856773caf7329a4c0b6a1664eb5eacc 100644 (file)
   tags:
     - resolvconf
 
-- name: include secondary NIC config tasks
-  import_tasks: secondary_nic.yml
-  when: secondary_nic_mac is defined
-  tags:
-    - secondary-nic
-
 # http://tracker.ceph.com/issues/20623
 - name: List any leftover Ceph artifacts from previous jobs
   shell: 'find {{ item }} -name "*ceph*"'
diff --git a/roles/testnode/tasks/secondary_nic.yml b/roles/testnode/tasks/secondary_nic.yml
deleted file mode 100644 (file)
index 8eb2ef6..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
----
-- name: Make sure ethtool is installed
-  package:
-    name: ethtool
-    state: latest
-
-- name: grep ethtool for secondary NIC MAC address
-  shell: "ethtool -P {{ item }} | awk '{ print $3 }' | grep -q -i '{{ secondary_nic_mac }}'"
-  register: ethtool_grep_output
-  with_items: "{{ ansible_interfaces }}"
-  failed_when: false
-  changed_when: false
-
-- name: Define net_to_configure var
-  set_fact:
-    nic_to_configure: "{{ item.item }}"
-  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
-  changed_when: false
-
-# Assume jumbo frames if 10Gb
-- name: Set MTU to 9000 if 10Gb
-  set_fact: mtu=9000
-  when:
-    - nic_to_configure_speed is defined
-    - (nic_to_configure_speed.stdout == '10000Mb/s' or nic_to_configure_speed.stdout == '25000Mb/s')
-
-- name: "Write Ubuntu network config for {{ nic_to_configure }}"
-  blockinfile:
-    path: /etc/network/interfaces
-    block: |
-      auto {{ nic_to_configure }}
-      iface {{ nic_to_configure }} inet dhcp
-  register: wrote_network_config
-  when:
-    - nic_to_configure is defined
-    - ansible_os_family == 'Debian'
-
-# 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 }}"
-  when: ansible_os_family == 'Debian'
-
-- name: "Bounce {{ nic_to_configure }}"
-  shell: "ifdown {{ nic_to_configure }} && ifup {{ nic_to_configure }}"
-  when:
-    - wrote_network_config is changed
-    - ansible_os_family == 'Debian'
-
-- name: "Write RHEL/CentOS network config for {{ nic_to_configure }}"
-  lineinfile:
-    path: "/etc/sysconfig/network-scripts/ifcfg-{{ nic_to_configure }}"
-    create: yes
-    owner: root
-    group: root
-    mode: 0644
-    regexp: "{{ item.regexp }}"
-    line: "{{ item.line }}"
-  register: wrote_network_config
-  with_items:
-    - { regexp: '^DEVICE=', line: 'DEVICE={{ nic_to_configure }}' }
-    - { regexp: '^BOOTPROTO=', line: 'BOOTPROTO=dhcp' }
-    - { regexp: '^ONBOOT=', line: 'ONBOOT=yes' }
-    - { regexp: '^MTU=', line: 'MTU={{ mtu }}' }
-  when:
-    - nic_to_configure is defined
-    - ansible_os_family == 'RedHat'
-
-- name: "Bounce {{ nic_to_configure }}"
-  shell: "ifdown {{ nic_to_configure }}; ifup {{ nic_to_configure }}"
-  when:
-    - wrote_network_config is changed
-    - ansible_os_family == 'RedHat'