mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-09-14 10:13:48 +00:00
4844528860
Treating an empty noderes.installnic as "mac" skipped noderes.primarynic: a node that configures only primarynic was installed with a netplan matching on mac.mac that never renamed the interface, and a primarynic holding a MAC address was ignored. The order xCAT uses everywhere else is installnic -> primarynic -> mac.mac, with either attribute allowed to hold an interface name or a MAC address, and xCAT::NetworkUtils::gen_net_boot_params already implements it for the netboot kernel parameters. Resolve it in Perl and hand the template the answer: - xCAT::Template::subiquity_install_netcfg() delegates the order to gen_net_boot_params and returns the netplan set-name (empty when the device is matched by MAC alone) and the address to match on, with mac.mac parsed by xCAT::Utils::parseMacTabEntry so |-separated, !hostname-suffixed entries resolve to THIS node rather than to whichever entry came first. - #SUBIQUITYINSTALLNIC# / #SUBIQUITYINSTALLMAC# render those two values. installnic and primarynic are read blank-okay -- a node that sets neither is normal, and is exactly what "match on mac.mac" means -- while mac.mac stays a required lookup, as it was when the template read it directly. - compute.subiquity.tmpl consumes the resolved values. No part of the fallback, and no mac.mac parsing, is left in shell: it only chooses whether to emit set-name, based on whether a name was resolved. ubuntu_subiquity_installnic.t now passes: the six resolution cases, multi-entry mac.mac, and the netplan the template's own late-command writes for a resolved name and for none. ubuntu_subiquity_template.t asserts the template no longer reads installnic/primarynic or parses MACs itself. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
105 lines
3.8 KiB
Cheetah
105 lines
3.8 KiB
Cheetah
#cloud-config
|
|
autoinstall:
|
|
version: 1
|
|
keyboard: {layout: us, toggle: null, variant: ''}
|
|
locale: en_US
|
|
network:
|
|
version: 2
|
|
ethernets:
|
|
xcat-install:
|
|
match:
|
|
name: "e*"
|
|
dhcp4: true
|
|
ssh:
|
|
allow-pw: true
|
|
authorized-keys: []
|
|
install-server: true
|
|
identity:
|
|
realname: 'xCAT Admin'
|
|
username: xcatadm
|
|
hostname: #HOSTNAME#
|
|
password: "#CRYPTORLOCKED:passwd:key=system,username=root:password#"
|
|
#UBUNTU_SUBIQUITY_APT_CONFIG#
|
|
kernel:
|
|
package: linux-generic
|
|
user-data:
|
|
hostname: #HOSTNAME#
|
|
disable_root: false
|
|
package_update: false
|
|
package_upgrade: false
|
|
timezone: #TABLE:site:key=timezone:value#
|
|
chpasswd:
|
|
list:
|
|
- "root:#CRYPTORLOCKED:passwd:key=system,username=root:password#"
|
|
expire: false
|
|
packages:
|
|
- openssh-server
|
|
- openssh-client
|
|
- wget
|
|
- vim
|
|
- rsync
|
|
- busybox-static
|
|
- gawk
|
|
- bind9-dnsutils
|
|
- chrony
|
|
- gpg
|
|
early-commands:
|
|
- |
|
|
exec >/tmp/pre-install.log 2>&1
|
|
set -eux
|
|
echo "=== xCAT early-commands ==="
|
|
echo "=== network ==="
|
|
ip addr show
|
|
ip route show
|
|
echo "=== disk detection ==="
|
|
wget -T 30 -O /tmp/getinstdisk http://#XCATVAR:XCATMASTER##COLONHTTPPORT#/install/autoinst/getinstdisk
|
|
test -s /tmp/getinstdisk
|
|
chmod u+x /tmp/getinstdisk
|
|
/tmp/getinstdisk
|
|
echo "=== pre-install script ==="
|
|
wget -T 30 -O /tmp/pre.sh http://#XCATVAR:XCATMASTER##COLONHTTPPORT#/install/autoinst/#HOSTNAME#.pre
|
|
test -s /tmp/pre.sh
|
|
chmod u+x /tmp/pre.sh
|
|
/tmp/pre.sh
|
|
echo "=== storage injection ==="
|
|
test -s /tmp/partitionfile
|
|
sed -i '/^\.\.\.$/d' /autoinstall.yaml
|
|
cat /tmp/partitionfile >> /autoinstall.yaml
|
|
echo "=== DNS setup ==="
|
|
rm -f /etc/resolv.conf
|
|
echo "nameserver #TABLE:noderes:$NODE:xcatmaster#" >/etc/resolv.conf
|
|
echo "domain #TABLE:site:key=domain:value#" >>/etc/resolv.conf
|
|
echo "=== early-commands complete ==="
|
|
late-commands:
|
|
- mkdir -p /target/var/log/xcat/
|
|
- '{
|
|
cat /tmp/pre-install.log >> /target/var/log/xcat/xcat.log;
|
|
installnic="#SUBIQUITYINSTALLNIC#";
|
|
installmac="#SUBIQUITYINSTALLMAC#";
|
|
mkdir -p /target/etc/netplan;
|
|
if [ -z "${installnic}" ]; then
|
|
printf ''%s\n'' "network:" " version: 2" " ethernets:" " xcat-install:" " match:" " macaddress: \"${installmac}\"" " dhcp4: true" >/target/etc/netplan/00-xcat-install.yaml;
|
|
else
|
|
printf ''%s\n'' "network:" " version: 2" " ethernets:" " xcat-install:" " match:" " macaddress: \"${installmac}\"" " set-name: ${installnic}" " dhcp4: true" >/target/etc/netplan/00-xcat-install.yaml;
|
|
fi;
|
|
chmod 600 /target/etc/netplan/00-xcat-install.yaml;
|
|
printf ''%s\n'' ''#HOSTNAME#'' >/target/etc/hostname;
|
|
if grep -q ''^127\.0\.1\.1'' /target/etc/hosts; then
|
|
sed -i ''s/^127\.0\.1\.1.*/127.0.1.1 #HOSTNAME#/'' /target/etc/hosts;
|
|
else
|
|
printf ''%s\n'' ''127.0.1.1 #HOSTNAME#'' >>/target/etc/hosts;
|
|
fi;
|
|
mkdir -p /target/etc/cloud;
|
|
touch /target/etc/cloud/cloud-init.disabled;
|
|
echo "Updating kernel command line...";
|
|
printf ''%s\n'' ''GRUB_CMDLINE_LINUX="#TABLEBLANKOKAY:bootparams:$NODE:kcmdline#"'' >>/target/etc/default/grub;
|
|
curtin in-target --target /target update-grub2;
|
|
echo "Running late_command Installation script...";
|
|
wget -T 30 http://#XCATVAR:XCATMASTER##COLONHTTPPORT#/install/autoinst/#HOSTNAME#.post;
|
|
chmod u+x #HOSTNAME#.post;
|
|
cp ./#HOSTNAME#.post /target/root/post.script;
|
|
curtin in-target --target /target /root/post.script;
|
|
} >>/target/var/log/xcat/xcat.log 2>&1'
|
|
error-commands:
|
|
- tar -c --ignore-failed-read --transform='s/^/#HOSTNAME#-logs\//' /var/crash /var/log/installer /tmp/pre-install.log /autoinstall.yaml 2>/dev/null |nc -l 8080
|