Compare commits
3 Commits
846ded0e57
...
345b29b84c
Author | SHA1 | Date | |
---|---|---|---|
345b29b84c | |||
e1fa427ddd | |||
87a0251fe0 |
@ -31,11 +31,6 @@ addpkglist="{{ addpkglist }}"
|
|||||||
filesystem="{{ filesystem }}"
|
filesystem="{{ filesystem }}"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{%- if skip_blockcheck is defined and skip_blockcheck %}
|
|
||||||
# Skip block zeroing; only recommended for testing, slow, low-endurance, or known-zeroed block devices.
|
|
||||||
skip_blockcheck="y"
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
###
|
###
|
||||||
### Per-host definitions (required)
|
### Per-host definitions (required)
|
||||||
###
|
###
|
||||||
|
@ -210,6 +210,7 @@ seed_config() {
|
|||||||
host_macaddr=$( ip -br link show ${target_interface} | awk '{ print $3 }' )
|
host_macaddr=$( ip -br link show ${target_interface} | awk '{ print $3 }' )
|
||||||
host_ipaddr=$( ip -br address show ${target_interface} | awk '{ print $3 }' | awk -F '/' '{ print $1 }' )
|
host_ipaddr=$( ip -br address show ${target_interface} | awk '{ print $3 }' | awk -F '/' '{ print $1 }' )
|
||||||
|
|
||||||
|
o_target_disk="${target_disk}"
|
||||||
# Handle the target disk
|
# Handle the target disk
|
||||||
case "${target_disk}" in
|
case "${target_disk}" in
|
||||||
/dev/*)
|
/dev/*)
|
||||||
@ -219,12 +220,12 @@ seed_config() {
|
|||||||
detect:*)
|
detect:*)
|
||||||
# Read the detect string into separate variables
|
# Read the detect string into separate variables
|
||||||
# A detect string is formated thusly:
|
# A detect string is formated thusly:
|
||||||
# detect:<Controller-or-Model-Name>:<0-indexed-ID>:<Capacity-in-human-units>
|
# detect:<Controller-or-Model-Name>:<Capacity-in-human-units><0-indexed-ID>
|
||||||
# For example:
|
# For example:
|
||||||
# detect:INTEL:1:800GB
|
# detect:INTEL:800GB:1
|
||||||
# detect:DELLBOSS:0:240GB
|
# detect:DELLBOSS:240GB:0
|
||||||
# detect:PERC H330 Mini:0:200GB
|
# detect:PERC H330 Mini:200GB:0
|
||||||
IFS=: read detect b_name b_id b_size <<<"${target_disk}"
|
IFS=: read detect b_name b_size b_id <<<"${target_disk}"
|
||||||
# Get the lsscsi output (exclude NVMe)
|
# Get the lsscsi output (exclude NVMe)
|
||||||
lsscsi_data_all="$( lsscsi -s -N )"
|
lsscsi_data_all="$( lsscsi -s -N )"
|
||||||
# Get the available sizes, and match to within +/- 2%
|
# Get the available sizes, and match to within +/- 2%
|
||||||
@ -272,7 +273,7 @@ EOF
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ ! -b ${target_disk} ]]; then
|
if [[ ! -b ${target_disk} ]]; then
|
||||||
echo "Invalid disk or disk not found!"
|
echo "Invalid disk or disk not found for '${o_target_disk}'!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -376,15 +377,6 @@ interactive_config() {
|
|||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
done
|
done
|
||||||
echo "2c) Skip disk zeroing? Only recommended for slow, low-endurance, or known-"
|
|
||||||
echo -n "zeroed block devices. [y/N] "
|
|
||||||
read skip_blockcheck
|
|
||||||
if [[ ${skip_blockcheck} == 'y' || ${skip_blockcheck} == 'Y' ]]; then
|
|
||||||
skip_blockcheck="y"
|
|
||||||
else
|
|
||||||
skip_blockcheck=""
|
|
||||||
fi
|
|
||||||
echo
|
|
||||||
|
|
||||||
for interface in $( ip address | grep '^[0-9]' | grep 'eno\|enp\|ens\|wlp' | awk '{ print $2 }' | tr -d ':' ); do
|
for interface in $( ip address | grep '^[0-9]' | grep 'eno\|enp\|ens\|wlp' | awk '{ print $2 }' | tr -d ':' ); do
|
||||||
ip link set ${interface} up
|
ip link set ${interface} up
|
||||||
@ -690,47 +682,21 @@ for pv in $( pvscan | grep "${target_disk}" | awk '{ print $2 }' ); do
|
|||||||
done
|
done
|
||||||
echo "done."
|
echo "done."
|
||||||
|
|
||||||
blockcheck() {
|
echo -n "Wiping partition signatures on '${target_disk}'... "
|
||||||
# Skip checking if the key is set
|
wipefs -a ${target_disk} >&2
|
||||||
if [[ -n ${skip_blockcheck} ]]; then
|
echo "done."
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Determine optimal block size for zeroing
|
echo -n "Preparing GPT partitions on '${target_disk}'... "
|
||||||
exponent=16
|
|
||||||
remainder=1
|
|
||||||
while [[ ${remainder} -gt 0 && ${exponent} -gt 0 ]]; do
|
|
||||||
exponent=$(( ${exponent} - 1 ))
|
|
||||||
size=$(( 2**9 * 2 ** ${exponent} ))
|
|
||||||
count=$(( ${blockdev_size_bytes} / ${size} ))
|
|
||||||
remainder=$(( ${blockdev_size_bytes} - ${count} * ${size} ))
|
|
||||||
done
|
|
||||||
if [[ ${remainder} -gt 0 ]]; then
|
|
||||||
echo "Failed to find a suitable block size for wiping... skipping."
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -n "Checking if block device '${target_disk}' is already wiped... "
|
|
||||||
if ! cmp --silent --bytes ${blockdev_size_bytes} /dev/zero ${target_disk}; then
|
|
||||||
echo "false."
|
|
||||||
echo "Wiping block device '${target_disk}' (${count} blocks of ${size} bytes)..."
|
|
||||||
dd if=/dev/zero of=${target_disk} bs=${size} count=${count} oflag=direct status=progress 2>&1
|
|
||||||
else
|
|
||||||
echo "done."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
blockcheck
|
|
||||||
|
|
||||||
echo -n "Preparing block device '${target_disk}'... "
|
|
||||||
# New GPT, part 1 32MB BIOS boot, part 2 64MB ESP, part 3 928MB BOOT, part 4 inf LVM PV
|
# New GPT, part 1 32MB BIOS boot, part 2 64MB ESP, part 3 928MB BOOT, part 4 inf LVM PV
|
||||||
echo -e "o\ny\nn\n1\n\n32M\nEF02\nn\n2\n\n64M\nEF00\nn\n3\n\n928M\n8300\nn\n4\n\n\n8E00\nw\ny\n" | gdisk ${target_disk} >&2
|
echo -e "o\ny\nn\n1\n\n32M\nEF02\nn\n2\n\n64M\nEF00\nn\n3\n\n928M\n8300\nn\n4\n\n\n8E00\nw\ny\n" | gdisk ${target_disk} >&2
|
||||||
echo "done."
|
echo "done."
|
||||||
|
|
||||||
echo -n "Rescanning disks... "
|
echo -n "Rescanning disks... "
|
||||||
partprobe >&2 || true
|
partprobe >&2 || true
|
||||||
|
sleep 5
|
||||||
echo "done."
|
echo "done."
|
||||||
|
|
||||||
echo -n "Creating LVM PV... "
|
echo -n "Creating LVM PV on '${target_disk}4'... "
|
||||||
yes | pvcreate -ffy ${target_disk}4 >&2
|
yes | pvcreate -ffy ${target_disk}4 >&2
|
||||||
echo "done."
|
echo "done."
|
||||||
|
|
||||||
@ -887,6 +853,7 @@ host_macaddr=\$( ip -br link show \${target_interface} | awk '{ print \$3 }' )
|
|||||||
host_ipaddr=\$( ip -br address show \${target_interface} | awk '{ print \$3 }' | awk -F '/' '{ print \$1 }' )
|
host_ipaddr=\$( ip -br address show \${target_interface} | awk '{ print \$3 }' | awk -F '/' '{ print \$1 }' )
|
||||||
bmc_macaddr=\$( ipmitool lan print | grep 'MAC Address ' | awk '{ print \$NF }' )
|
bmc_macaddr=\$( ipmitool lan print | grep 'MAC Address ' | awk '{ print \$NF }' )
|
||||||
bmc_ipaddr=\$( ipmitool lan print | grep 'IP Address ' | awk '{ print \$NF }' )
|
bmc_ipaddr=\$( ipmitool lan print | grep 'IP Address ' | awk '{ print \$NF }' )
|
||||||
|
|
||||||
if [[ -f /etc/pvc-install.hooks ]]; then
|
if [[ -f /etc/pvc-install.hooks ]]; then
|
||||||
# The third boot, when all hooks have been completed
|
# The third boot, when all hooks have been completed
|
||||||
action="system-boot_completed"
|
action="system-boot_completed"
|
||||||
@ -897,6 +864,9 @@ else
|
|||||||
# The first boot, when Ansible has not been run yet
|
# The first boot, when Ansible has not been run yet
|
||||||
action="system-boot_initial"
|
action="system-boot_initial"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
sleep 30
|
||||||
|
|
||||||
curl -X POST \
|
curl -X POST \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"action\":\"\${action}\",\"hostname\":\"\$( hostname -s )\",\"host_macaddr\":\"\${host_macaddr}\",\"host_ipaddr\":\"\${host_ipaddr}\",\"bmc_macaddr\":\"\${bmc_macaddr}\",\"bmc_ipaddr\":\"\${bmc_ipaddr}\"}" \
|
-d "{\"action\":\"\${action}\",\"hostname\":\"\$( hostname -s )\",\"host_macaddr\":\"\${host_macaddr}\",\"host_ipaddr\":\"\${host_ipaddr}\",\"bmc_macaddr\":\"\${bmc_macaddr}\",\"bmc_ipaddr\":\"\${bmc_ipaddr}\"}" \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user