Improved network setup during optimized restore

An issue noted during a previous review mentioned that "gethostip"
is not guaranteed on all systems.  It has been replaced by
grepping /etc/hosts for relevant IPs.

Ignore errors has also been removed because the issue that was
causing it to be required is not longer present on current builds.
It is unknown what was causing it.

A change also had to be made for restoring systems
that used registry.central.  Since dnsmasq is not restored
until after unlock, registry.central was unreachable.
Solution chosen is to use the platform hosts file during image
downloading sequence because it contains a
host entry for registry.central.

TEST PLAN
PASS: Optimized restore is successful (SX)
PASS: Optimized restore is successful (SX) on a subcloud

Story: 2010117
Task: 46749
Change-Id: I783fd88c6f19709c11af16013e62892502701a88
This commit is contained in:
Joshua Kraitberg
2022-11-07 10:32:23 -05:00
parent e19feddc3e
commit 6979f37318
3 changed files with 46 additions and 40 deletions

View File

@@ -46,5 +46,9 @@ pxelinux_config_permdir: "/opt/platform/config/{{ software_version }}/pxelinux.c
# Used to restore networking configuration
network_scripts_location:
"{{ '/etc/sysconfig/network-scripts' if os_release == 'centos' else '/etc/network/interfaces.d' }}"
network_scripts_location_bkp:
"{{ 'etc/sysconfig/network-scripts' if os_release == 'centos' else 'etc/network/interfaces.d' }}"
# When restoring networking, addresses for these hosts are added temporarily
temporary_address_names:
- oamcontroller
- pxecontroller
- registry.local

View File

@@ -13,50 +13,26 @@
# Bring up networking, meant to replicate state during boostrapping
- name: Restore networking
block:
- name: Determine network configuration files
find:
paths: "{{ network_scripts_location }}"
patterns: "ifcfg-*"
register: network_files_to_delete
- name: Remove network configuration files
file:
path: "{{ item.path }}"
path: "{{ network_scripts_location }}"
state: absent
loop: "{{ network_files_to_delete.files }}"
- name: Restore network configuration files
command: "tar -C / -xpf {{ platform_backup_fqpn }} --overwrite --wildcards {{ network_scripts_location_bkp }}/*"
command: "tar -C / -xpf {{ platform_backup_fqpn }} --overwrite {{ network_scripts_location.lstrip('/') }}"
# fails due to enp0s9 not having the ip set on ifcfg-enp0s9
# - name: Restart networking daemon
# systemd:
# name: networking
# state: restarted
- name: Shutdown all network interfaces excluding loopback
command: ifdown -a --exclude=lo
- name: Bring lo up
command: ifup lo lo:1 lo:5
- name: Bring up original networking
shell: ifup -a --exclude="$(ip route show 0.0.0.0/0 | awk '{print $NF}')"
- name: Lookup controller host address
command: "gethostip -d controller"
register: host_lookup
- name: Bring up temporary addresses
block:
- name: Lookup controller host addresses
shell: "grep -E '{{ '|'.join(temporary_address_names) }}' /etc/hosts | awk '{print $1}'"
register: host_addresses
- name: Define controller host address
set_fact:
controller_address: "{{ host_lookup.stdout_lines[0] }}"
- name: Configure controller host address
command: "ip addr add {{ controller_address }} dev lo scope host"
- name: Lookup controller host address
command: "gethostip -d pxecontroller"
register: pxe_host_lookup
- name: Define controller host address
set_fact:
pxecontroller_address: "{{ pxe_host_lookup.stdout_lines[0] }}"
- name: Configure controller host address
command: "ip addr add {{ pxecontroller_address }} dev lo scope host"
ignore_errors: true
- name: Configure controller host address
command: "ip addr add {{ item }} dev lo scope host"
loop: "{{ host_addresses.stdout_lines }}"