4.3. 予測可能なアンダークラウドノード NIC 名の使用
アンダークラウドノードで Leapp によるアップグレードを実施する前に、カーネルベースの NIC 名が使用されているかどうかを確認する必要があります。この NIC 名には、通常 eth
の接頭辞が含まれます。NIC の割り当てに関して、通常これらの NIC 名は予測可能ではありません。
playbook-nics.yaml
Playbook を実行して NIC の名前を変更し、インターフェイスの NIC
接頭辞を使用することができます。また、Playbook の実行時に prefix
変数を変更することで、別の NIC 接頭辞を設定することもできます。ただし、NIC の変更は、Leapp によるアップグレードプロセスが完了し、ノードがリブートされた後にのみ適用されます。
手順
-
アンダークラウドに
stack
ユーザーとしてログインします。 playbook-nics.yaml
という名前の Ansible Playbook を作成し、以下のコンテンツを Playbook にコピーします。--- - name: Rename eth devices hosts: all become: yes vars: prefix: "em" undercloud_conf: "/home/stack/undercloud.conf" osnet_conf: "/etc/os-net-config/config.json" tasks: - set_fact: eth_interfaces: "{{ ansible_interfaces | select('match','eth.*') | list }}" - debug: msg: "{{ eth_interfaces }}" - name: Update udev rules lineinfile: line: "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"{{ ansible_facts[item]['perm_macaddress'] | default(ansible_facts[item]['macaddress']) }}\", NAME=\"{{ item|replace('eth',prefix) }}\"" path: /etc/udev/rules.d/70-rhosp-persistent-net.rules create: True with_items: "{{ eth_interfaces }}" - name: Rename eth files block: - name: Check that eth files exists stat: path: /etc/sysconfig/network-scripts/ifcfg-{{ item }} register: nic_result with_items: "{{ eth_interfaces }}" - name: Copy nic files using the new prefix copy: remote_src: True src: "{{ item.stat.path }}" dest: "{{ item.stat.path|replace('eth',prefix) }}" with_items: "{{ nic_result.results }}" when: item.stat.exists - name: Edit NAME in new network-script files lineinfile: regexp: "^NAME=.*" line: "NAME={{ item.item|replace('eth',prefix) }}" path: "{{ item.stat.path|replace('eth',prefix) }}" with_items: "{{ nic_result.results }}" when: item.stat.exists - name: Edit DEVICE in new network-script files lineinfile: regexp: "^DEVICE=.*" line: "DEVICE={{ item.item|replace('eth',prefix) }}" path: "{{ item.stat.path|replace('eth',prefix) }}" with_items: "{{ nic_result.results }}" when: item.stat.exists - name: Backup old eth network-script files copy: remote_src: True src: "{{ item.stat.path }}" dest: "{{ item.stat.path }}.bak" with_items: "{{ nic_result.results }}" when: item.stat.exists - name: Remove old eth network-script files file: path: "{{ item.stat.path }}" state: absent with_items: "{{ nic_result.results }}" when: item.stat.exists - name: Rename route files block: - name: Check that route files exists stat: path: /etc/sysconfig/network-scripts/route-{{ item }} register: route_result with_items: "{{ eth_interfaces }}" - name: Copy route files using the new prefix copy: remote_src: True src: "{{ item.stat.path }}" dest: "{{ item.stat.path|replace('eth',prefix) }}" with_items: "{{ route_result.results }}" when: item.stat.exists - name: Update prefix in route files that use IP command arguments format replace: regexp: "eth" replace: "{{ prefix }}" path: "{{ item.stat.path|replace('eth',prefix) }}" with_items: "{{ route_result.results }}" when: item.stat.exists - name: Backup old route files copy: remote_src: True src: "{{ item.stat.path }}" dest: "{{ item.stat.path }}.bak" with_items: "{{ route_result.results }}" when: item.stat.exists - name: Remove old route files file: path: "{{ item.stat.path }}" state: absent with_items: "{{ route_result.results }}" when: item.stat.exists - name: Perform a final regex for any remaining eth prefixes in ifcfg files block: - name: Get a list of all ifcfg files find: paths: /etc/sysconfig/network-scripts/ patterns: 'ifcfg-*' excludes: '*.bak' register: ifcfg_files - name: Perform final regex on ifcfg files replace: path: "{{ item[0].path }}" regexp: "{{ item[1] }}" replace: "{{ item[1]|replace('eth',prefix) }}" with_nested: - "{{ ifcfg_files.files }}" - "{{ eth_interfaces }}" - name: Replace interface name in files referencing old eth interface block: - name: Check if undercloud.conf exists stat: path: "{{ undercloud_conf }}" register: undercloud_conf_stat - name: Replace interface name in undercloud.conf replace: path: "{{ undercloud_conf }}" regexp: 'eth(\d+)' replace: "{{ prefix }}\\1" when: undercloud_conf_stat.stat.exists - name: Check if os-net-config's config.json exists stat: path: "{{ osnet_conf }}" register: osnet_conf_stat - name: Replace interface name in config.json replace: path: "{{ osnet_conf }}" regexp: 'eth(\d+)' replace: "{{ prefix }}\\1" when: osnet_conf_stat.stat.exists - name: Patch vlan devices block: - name: Check that vlan files exists stat: path: /etc/sysconfig/network-scripts/ifcfg-{{ item }} register: nic_result when: item.startswith("vlan") with_items: "{{ ansible_interfaces }}" - name: Backup old vlan network-script files copy: remote_src: True src: "{{ item.stat.path }}" dest: "{{ item.stat.path }}.bak" when: item.item.startswith("vlan") and item.stat.exists with_items: "{{ nic_result.results }}" - name: Edit PHYSDEV in new network-script files replace: path: "{{ item.stat.path }}" regexp: "^PHYSDEV=eth" replace: "PHYSDEV={{ prefix }}" when: item.item.startswith("vlan") and item.stat.exists with_items: "{{ nic_result.results }}"
注記この Playbook を使用して、アップグレードプロセスの後半でオーバークラウドの NIC の名前を変更します。
アンダークラウドで
playbook-nics.yaml
Playbook を実行します。$ ansible-playbook -c local -i localhost, playbook-nics.yaml
この Playbook により、新しい NIC の接頭辞が
em
に設定されます。別の NIC 接頭辞を設定するには、Playbook の実行時にprefix
変数を設定します。$ ansible-playbook -c local -i localhost, -e prefix="mynic" ~/playbook-nics.yaml
NIC の変更は、Leapp によるアップグレードプロセスが完了し、ノードがリブートされた後にのみ適用されます。