This repository has been archived by the owner on Aug 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
centos-8-kickstart-openstack.cfg
234 lines (193 loc) · 7.46 KB
/
centos-8-kickstart-openstack.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#version=RHEL8
# Partition clearing information
clearpart --all --initlabel
# Use graphical install
graphical
# Use HD installation media
#cdrom
url --url="http://10.1.200.2/centos"
repo --name="AppStream" --baseurl=http://10.1.200.2/centos/AppStream
repo --name="BaseOS" --baseurl=http://10.1.200.2/centos/BaseOS
#harddrive --partition=/dev/disk/by-label/CentOS-8-x86_64 --dir=/
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Root password
rootpw none
# Run the Setup Agent on first boot
firstboot --enable
# Do not configure the X Window System
skipx
# System services
services --enabled="chronyd" --enabled="tcsd" --enabled="firewalld"
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
timezone UTC --isUtc
%pre --log=/tmp/network.log
ip --brief address show | awk -F' ' '{ print $1 }' > /tmp/hw.out
# shellcheck disable=SC2006
nic_cards=`cat /tmp/hw.out`
nics=()
IFS=$'\n'; for i in $nic_cards; do
if [[ "lo" != "$i" ]]; then
nics+=("$i")
fi
done
HOWLONG=5 ## the number of characters
HOSTNAME_SUFFIX=$(< /dev/urandom 2>/dev/null tr -dc A-Za-z0-9 | head -c100 | head -c$((20+(RANDOM%20))) | tail -c$((20+(RANDOM%20))) | head -c${HOWLONG});
echo "$HOSTNAME_SUFFIX" | tr '[:upper:]' '[:lower:]' > /tmp/system_suffix.log
HOSTNAME_SUFFIX=$(cat /tmp/system_suffix.log)
# count network cards, if odd number - set up failover for internal, if even - set up failover for both.
middle=$(( ${#nics[@]} / 2))
printf '%s\n' "${nics[@]:0:((middle))}" > /tmp/opt_nic.log
external_nics=$(printf '%s,' "${nics[@]:((middle)):${#nics[@]}}")
internal_nics=$(printf '%s,' "${nics[@]:0:((middle))}")
external_nics="${external_nics::${#external_nics}-1}"
internal_nics="${internal_nics::${#internal_nics}-1}"
cat << EOF >> /tmp/nicinfo.log
network --hostname=acton-lane-platform-$HOSTNAME_SUFFIX
network --device=ext-bond --activate --name=ext-bond --noipv6 --bootproto=dhcp --onboot=yes --bondslaves="$external_nics" --bondopts="mode=802.3ad,miimon=100,lacp_rate=fast,xmit_hash_policy=layer2+3"
network --device=int-bond --activate --name=int-bond --noipv6 --bootproto=dhcp --onboot=yes --bondslaves="$internal_nics" --bondopts="mode=802.3ad,miimon=100,lacp_rate=fast,xmit_hash_policy=layer2+3"
EOF
%end
%include /tmp/nicinfo.log
%pre --log=/tmp/ks_pre.log
# shellcheck disable=SC2006
# shellcheck disable=SC2010
USB=`ls -l /dev/disk/by-id/*usb* 2>/dev/null | grep -v part | awk '{ print $NF }' | sed -r 's/..\/..\///g'`
if [ -z "$USB" ]; then
USB=" "
fi
# Determine how many drives we have
# shellcheck disable=SC2046
set $(list-harddrives | sed "/^$USB/d")
let numd=$#/2
d1=$1
d1_size=$(printf "%.0f\n" "$2")
d2=$3
d2_size=$(printf "%.0f\n" "$4")
if [ "$numd" -ge 2 ] ; then
speed_d1=$(hdparm -tv /dev/"$d1" | awk '/Timing buffered disk reads/ {print $11}')
speed_d2=$(hdparm -tv /dev/"$d2" | awk '/Timing buffered disk reads/ {print $11}')
if [ "$speed_d1" -gt "$speed_d2" ]; then
hsd=$d1
hsd_drive_size_gb=$d1_size
rsd=$d2
else
hsd=$d2
hsd_drive_size_gb=$d2_size
rsd=$d1
fi
storage_size=$((hsd_drive_size_gb * 40/100))
## min drive size for 2 drive system is 800GB for regular speed drive (rsd). high speed drive has no minimum.
## single drive is 1TB
## also test for min ram of 200GB.
cat << EOF >> /tmp/partinfo
part biosboot --size=1 --ondisk=$rsd
part / --size=100000 --ondisk=$rsd
part /home --size=1000 --ondisk=$rsd
part /boot --size=1000 --ondisk=$rsd
part swap --size=5000 --ondisk=$rsd
part /VM-VOL-KOLLA --size=60000 --fstype=ext4 --ondisk=$rsd
part /VM-VOL-CONTROL --size=140000 --fstype=ext4 --ondisk=$rsd
part /VM-VOL-NETWORK --size=120000 --fstype=ext4 --ondisk=$rsd
part /VM-VOL-MONITORING --size=200000 --fstype=ext4 --ondisk=$rsd
part /VM-VOL-MISC --size=230000 --fstype=ext4 --ondisk=$rsd
part /VM-VOL-SWIFT --size=$storage_size --fstype=ext4 --ondisk=$hsd
part /VM-VOL-CINDER --size=1024 --grow --fstype=ext4 --ondisk=$rsd
part /VM-VOL-COMPUTE --size=1024 --grow --fstype=ext4 --ondisk=$hsd
EOF
else
storage_size=$((d1_size * 20/100))
cinder_size=$((d1_size * 20/100))
cat << EOF >> /tmp/partinfo
part biosboot --size=1 --ondisk=$d1
part / --size=100000 --ondisk=$d1
part /home --size=1000 --ondisk=$d1
part /boot --size=1000 --ondisk=$d1
part swap --size=5000 --ondisk=$d1
part /VM-VOL-KOLLA --size=60000 --fstype=ext4 --ondisk=$d1
part /VM-VOL-CONTROL --size=140000 --fstype=ext4 --ondisk=$d1
part /VM-VOL-NETWORK --size=120000 --fstype=ext4 --ondisk=$d1
part /VM-VOL-MONITORING --size=200000 --fstype=ext4 --ondisk=$d1
part /VM-VOL-MISC --size=230000 --fstype=ext4 --ondisk=$d1
part /VM-VOL-SWIFT --size=$storage_size --fstype=ext4 --ondisk=$d1
part /VM-VOL-CINDER --size=$cinder_size --fstype=ext4 --ondisk=$d1
part /VM-VOL-COMPUTE --size=1024 --grow --fstype=ext4 --ondisk=$d1
EOF
fi
%end
zerombr
%include /tmp/partinfo
%packages
%include http://10.1.200.2/centos/ks_configs/packages.cfg
%end
%addon com_redhat_kdump --disable
%end
%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end
%post --nochroot
exec 1>/mnt/sysimage/var/log/firstboot.log 2>&1
wget -r -l2 -nH -np -P /mnt/sysroot/tmp --cut-dirs=3 http://10.1.200.2/centos/embedded
#cp /mnt/install/repo/embedded/* /mnt/sysroot/tmp
%include http://10.1.200.2/centos/ks_configs/create-local-repo-pxe.cfg
%include http://10.1.200.2/centos/ks_configs/configure-local-repo.cfg
cp /tmp/*.log /mnt/sysroot/var/log
%end
%post
exec 1>/var/log/init-install.log 2>&1
source /tmp/vm_functions.sh
source /tmp/project_config.sh
sed -i 's/^.*swap.*$/#&/' /etc/fstab
swapoff -a
chmod +x /tmp/*.sh
install_packages_hypervisor
create_virtual_bridge_file "int-net" "$LAN_CENTOS_IP"
generate_pwd 31 | passwd --stdin root
is_intel=$(cat </proc/cpuinfo | grep vendor | uniq | grep -c 'Intel')
arch="intel"
if [[ $is_intel -lt 0 ]]; then
arch="amd"
fi
INSTALLED_RAM=$(dmidecode -t memory | grep Size: | grep -v "No Module Installed" | awk '{sum+=$2}END{print sum}')
RESERVED_RAM=$(( INSTALLED_RAM*RAM_PCT_AVAIL_CLOUD/100 ))
grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) ${arch}_iommu=on"
grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) iommu=on"
grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) default_hugepagesz=1G"
grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) hugepagesz=1G"
grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) hugepages=$RESERVED_RAM"
grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) rhgb"
grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) splash"
grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) quiet"
grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) systemd.log_level=0"
grub2-editenv - set menu_auto_hide=1
grub2-editenv - set GRUB_DISABLE_RECOVERY="true"
#### arch specific
if [[ $is_intel -gt 0 ]]; then
grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) intel_pstate=active"
fi
######
### system profile
tuned-adm profile virtual-host
#############
replace_values_in_root_isos
enable_kvm_module
### disable once syslogs are being sent
systemctl enable --now cockpit.socket
####
sed -i "s/AllowZoneDrifting=yes/AllowZoneDrifting=no/g" /etc/firewalld/firewalld.conf
#Prep initial startup script
mv /tmp/init-openstack.sh /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local
###############################
###Close out cfg file
curl http://10.1.200.2/end-of-install
%end
eula --agreed
reboot --eject
#########