4.3. 언더클라우드 노드에 예측 가능한 NIC 이름 사용
언더클라우드 노드에서 Leapp 업그레이드를 실행하기 전에 일반적으로 eth
접두사가 포함된 커널 기반 NIC 이름을 확인해야 합니다. 일반적으로 이러한 NIC 이름은 NIC 할당 측면에서 예측할 수 없습니다.
playbook -nics.yaml 플레이북을
실행하여 em
NIC 접두사를 사용하도록 NIC 이름 이름을 변경할 수 있습니다. 플레이북을 실행할 때 접두사 변수를 수정하여 다른 NIC 접두사를
설정할 수도 있습니다. 그러나 NIC 변경은 Leapp 업그레이드 프로세스가 완료되고 노드가 재부팅된 후에만 적용됩니다.
절차
-
stack
사용자로 언더클라우드에 로그인합니다. playbook-nics.yaml
이라는 Ansible 플레이북을 생성하고 다음 콘텐츠를 플레이북에 복사합니다.--- - 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 }}"
참고이 플레이북을 사용하여 업그레이드 프로세스의 이후 단계에서 오버클라우드 NIC의 이름을 변경합니다.
언더클라우드에서
playbook-nics.yaml
플레이북을 실행합니다.$ ansible-playbook -c local -i localhost, playbook-nics.yaml
플레이북은 새 NIC 접두사를
em
로 설정합니다. 다른 NIC 접두사를 설정하려면 플레이북을 실행할 때접두사
변수를 설정합니다.$ ansible-playbook -c local -i localhost, -e prefix="mynic" ~/playbook-nics.yaml
NIC 변경 사항은 Leapp 업그레이드 프로세스가 완료되고 노드가 재부팅된 후에만 적용됩니다.