Skip to content

Commit 84f8258

Browse files
szarkoskbsingh
authored andcommitted
Merge kickstart config for Azure (#132)
1 parent 4a3879a commit 84f8258

File tree

1 file changed

+123
-103
lines changed

1 file changed

+123
-103
lines changed

cloudimg/CentOS-7-x86_64-Azure.ks

Lines changed: 123 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,90 @@
1+
# Kickstart for creating a CentOS 7 Azure VM
2+
3+
# System authorization information
14
auth --enableshadow --passalgo=sha512
2-
reboot
3-
url --url="mirror.centos.org/centos/7/os/x86_64"
4-
firewall --enabled --service=ssh
5+
6+
# Use text install
7+
text
8+
9+
# Do not run the Setup Agent on first boot
510
firstboot --disable
6-
ignoredisk --only-use=vda
11+
12+
# Keyboard layouts
713
keyboard --vckeymap=us --xlayouts='us'
14+
815
# System language
916
lang en_US.UTF-8
17+
18+
# Network information
19+
network --bootproto=dhcp
20+
network --hostname=localhost.localdomain
21+
firewall --enabled --service=ssh
22+
23+
# Use network installation
24+
url --url="mirror.centos.org/centos/7/os/x86_64"
1025
repo --name "os" --baseurl="http://mirror.centos.org/centos/7/os/x86_64/" --cost=100
1126
repo --name "updates" --baseurl="http://mirror.centos.org/centos/7/updates/x86_64/" --cost=100
1227
repo --name "extras" --baseurl="http://mirror.centos.org/centos/7/extras/x86_64/" --cost=100
13-
# Network information
14-
network --bootproto=dhcp
15-
network --hostname=localhost.localdomain
28+
1629
# Root password
17-
rootpw --iscrypted thereisnopasswordanditslocked
30+
rootpw --plaintext "to_be_disabled"
1831
selinux --enforcing
19-
services --disabled="kdump" --enabled="network,sshd,rsyslog,chronyd"
20-
timezone UTC --isUtc
21-
# Disk
22-
bootloader --append="console=tty0" --location=mbr --timeout=1 --boot-drive=vda
32+
33+
# System services
34+
services --disabled="kdump,abrtd" --enabled="network,sshd,rsyslog,chronyd,waagent,dnsmasq,NetworkManager"
35+
%addon com_redhat_kdump --disable
36+
%end
37+
38+
# System timezone
39+
timezone Etc/UTC --isUtc
40+
41+
# Disk partitioning information
2342
zerombr
24-
clearpart --all --initlabel
25-
part / --fstype="xfs" --ondisk=vda --size=4096 --grow
43+
clearpart --all --initlabel
44+
part /boot --fstype="xfs" --size=500
45+
part / --fstype="xfs" --size=1 --grow --asprimary
2646

27-
%post --erroronfail
28-
passwd -d root
29-
passwd -l root
47+
# System bootloader configuration
48+
bootloader --append="console=tty0" --location=mbr --timeout=1
3049

31-
# setup systemd to boot to the right runlevel
32-
rm -f /etc/systemd/system/default.target
33-
ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
50+
# Don't configure X
51+
skipx
3452

35-
yum -C -y remove linux-firmware
53+
# Power down the machine after install
54+
poweroff
3655

37-
# Remove firewalld; it is required to be present for install/image building.
38-
# but we dont ship it in cloud
39-
yum -C -y remove firewalld --setopt="clean_requirements_on_remove=1"
40-
yum -C -y remove avahi\* Network\*
41-
sed -i '/^#NAutoVTs=.*/ a\
42-
NAutoVTs=0' /etc/systemd/logind.conf
4356

44-
cat > /etc/sysconfig/network << EOF
45-
NETWORKING=yes
46-
NOZEROCONF=yes
47-
EOF
57+
%packages
58+
@base
59+
@console-internet
60+
chrony
61+
cifs-utils
62+
sudo
63+
python-pyasn1
64+
parted
65+
WALinuxAgent
66+
hypervkvpd
67+
-dracut-config-rescue
68+
%end
4869

49-
rm -f /etc/udev/rules.d/70*
50-
ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules
5170

52-
# simple eth0 config, again not hard-coded to the build hardware
53-
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
54-
DEVICE="eth0"
55-
BOOTPROTO="dhcp"
56-
ONBOOT="yes"
57-
TYPE="Ethernet"
58-
USERCTL="yes"
59-
PEERDNS="yes"
60-
IPV6INIT="no"
61-
PERSISTENT_DHCLIENT="1"
62-
EOF
71+
%post --erroronfail --log=/var/log/anaconda/post-install.log
72+
#!/bin/bash
6373

64-
echo "virtual-guest" > /etc/tuned/active_profile
74+
usermod root -p '!!'
6575

66-
# generic localhost names
67-
cat > /etc/hosts << EOF
68-
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
69-
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
76+
# setup systemd to boot to the right runlevel
77+
rm -f /etc/systemd/system/default.target
78+
ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
7079

71-
EOF
72-
echo .
80+
# Set the kernel cmdline
81+
sed -i 's/^\(GRUB_CMDLINE_LINUX\)=".*"$/\1="console=tty1 console=ttyS0,115200n8 earlyprintk=ttyS0,115200 rootdelay=300 net.ifnames=0"/g' /etc/default/grub
7382

74-
systemctl mask tmp.mount
83+
# Enable grub serial console
84+
echo 'GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"' >> /etc/default/grub
85+
sed -i 's/^GRUB_TERMINAL_OUTPUT=".*"$/GRUB_TERMINAL="serial console"/g' /etc/default/grub
7586

87+
# Set default kernel
7688
cat <<EOL > /etc/sysconfig/kernel
7789
# UPDATEDEFAULT specifies if new-kernel-pkg should make
7890
# new kernels the default
@@ -82,73 +94,81 @@ UPDATEDEFAULT=yes
8294
DEFAULTKERNEL=kernel
8395
EOL
8496

85-
# make sure firstboot doesn't start
86-
echo "RUN_FIRSTBOOT=NO" > /etc/sysconfig/firstboot
97+
# Rebuild grub.cfg
98+
grub2-mkconfig -o /boot/grub2/grub.cfg
99+
100+
# Ensure Hyper-V drivers are built into initramfs
101+
echo -e "\nadd_drivers+=\"hv_vmbus hv_netvsc hv_storvsc\"" >> /etc/dracut.conf
102+
kversion=$( rpm -q kernel | sed 's/kernel\-//' )
103+
dracut -v -f "/boot/initramfs-${kversion}.img" "$kversion"
104+
105+
# Import CentOS public key
106+
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
107+
108+
# Enable SSH keepalive
109+
sed -i 's/^#\(ClientAliveInterval\).*$/\1 180/g' /etc/ssh/sshd_config
110+
111+
# Configure network
112+
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-eth0
113+
DEVICE=eth0
114+
ONBOOT=yes
115+
BOOTPROTO=dhcp
116+
TYPE=Ethernet
117+
USERCTL=no
118+
PEERDNS=yes
119+
IPV6INIT=no
120+
NM_CONTROLLED=no
121+
PERSISTENT_DHCLIENT=yes
122+
EOF
87123

88-
yum clean all
124+
cat << EOF > /etc/sysconfig/network
125+
NETWORKING=yes
126+
NOZEROCONF=yes
127+
HOSTNAME=localhost.localdomain
128+
EOF
89129

90-
# XXX instance type markers - MUST match CentOS Infra expectation
91-
echo 'azure' > /etc/yum/vars/infra
92130

93-
# chance dhcp client retry/timeouts to resolve #6866
131+
# Disable persistent net rules
132+
rm -f /etc/udev/rules.d/70* 2>/dev/null
133+
ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules
134+
135+
# Disable NetworkManager handling of the SRIOV interfaces
136+
cat <<EOF > /etc/udev/rules.d/68-azure-sriov-nm-unmanaged.rules
137+
# Accelerated Networking on Azure exposes a new SRIOV interface to the VM.
138+
# This interface is transparently bonded to the synthetic interface,
139+
# so NetworkManager should just ignore any SRIOV interfaces.
140+
SUBSYSTEM=="net", DRIVERS=="hv_pci", ACTION=="add", ENV{NM_UNMANAGED}="1"
141+
142+
EOF
143+
144+
# Change dhcp client retry/timeouts to resolve #6866
94145
cat >> /etc/dhcp/dhclient.conf << EOF
95146

96147
timeout 300;
97148
retry 60;
98149
EOF
99150

151+
# Blacklist the nouveau driver as it is incompatible
152+
# with Azure GPU instances.
153+
cat << EOF > /etc/modprobe.d/blacklist-nouveau.conf
154+
blacklist nouveau
155+
options nouveau modeset=0
156+
EOF
157+
100158
echo "Fixing SELinux contexts."
101159
touch /var/log/cron
102160
touch /var/log/boot.log
103161
mkdir -p /var/cache/yum
104162
/usr/sbin/fixfiles -R -a restore
105163

106-
# reorder console entries
107-
sed -i 's/console=tty0/console=tty0 console=ttyS0,115200n8/' /boot/grub2/grub.cfg
164+
# Modify yum, clean cache
165+
echo "http_caching=packages" >> /etc/yum.conf
166+
yum clean all
108167

109-
%end
168+
# XXX instance type markers - MUST match CentOS Infra expectation
169+
echo 'azure' > /etc/yum/vars/infra
110170

111-
%packages
112-
@core
113-
chrony
114-
WALinuxAgent
115-
dracut-config-generic
116-
dracut-norescue
117-
firewalld
118-
grub2
119-
kernel
120-
nfs-utils
121-
rsync
122-
tar
123-
yum-utils
124-
-NetworkManager
125-
-aic94xx-firmware
126-
-alsa-firmware
127-
-alsa-lib
128-
-alsa-tools-firmware
129-
-biosdevname
130-
-iprutils
131-
-ivtv-firmware
132-
-iwl100-firmware
133-
-iwl1000-firmware
134-
-iwl105-firmware
135-
-iwl135-firmware
136-
-iwl2000-firmware
137-
-iwl2030-firmware
138-
-iwl3160-firmware
139-
-iwl3945-firmware
140-
-iwl4965-firmware
141-
-iwl5000-firmware
142-
-iwl5150-firmware
143-
-iwl6000-firmware
144-
-iwl6000g2a-firmware
145-
-iwl6000g2b-firmware
146-
-iwl6050-firmware
147-
-iwl7260-firmware
148-
-libertas-sd8686-firmware
149-
-libertas-sd8787-firmware
150-
-libertas-usb8388-firmware
151-
-plymouth
171+
# Set tuned profile
172+
echo "virtual-guest" > /etc/tuned/active_profile
152173

153174
%end
154-

0 commit comments

Comments
 (0)