1+ # System authorization information
12auth --enableshadow --passalgo=sha512
3+ # Reboot after installation
24reboot
3- url --url=" mirror.centos.org/centos/7/os/x86_64"
5+ # Use network installation
6+ url --url=" mirrorsnap.centos.org/DATESTAMP/centos/7/os/x86_64"
7+ # Firewall configuration
48firewall --enabled --service=ssh
59firstboot --disable
610ignoredisk --only-use=vda
11+ # Keyboard layouts
12+ # old format: keyboard us
13+ # new format:
714keyboard --vckeymap=us --xlayouts=' us'
815# System language
916lang en_US.UTF-8
10- repo --name " os" --baseurl=" http://mirror .centos.org/centos/7/os/x86_64/" --cost=100
11- repo --name " updates" --baseurl=" http://mirror .centos.org/centos/7/updates/x86_64/" --cost=100
12- repo --name " extras" --baseurl=" http://mirror .centos.org/centos/7/extras/x86_64/" --cost=100
17+ repo --name " os" --baseurl=" http://mirrorsnap .centos.org/DATESTAMP /centos/7/os/x86_64/" --cost=100
18+ repo --name " updates" --baseurl=" http://mirrorsnap .centos.org/DATESTAMP /centos/7/updates/x86_64/" --cost=100
19+ repo --name " extras" --baseurl=" http://mirrorsnap .centos.org/DATESTAMP /centos/7/extras/x86_64/" --cost=100
1320# Network information
1421network --bootproto=dhcp
1522network --hostname=localhost.localdomain
1623# Root password
17- rootpw --iscrypted thereisnopasswordanditslocked
24+ rootpw --iscrypted nothing
1825selinux --enforcing
1926services --disabled=" kdump" --enabled=" network,sshd,rsyslog,chronyd"
2027timezone UTC --isUtc
@@ -25,10 +32,16 @@ clearpart --all --initlabel
2532part / --fstype=" xfs" --ondisk=vda --size=4096 --grow
2633
2734%post --erroronfail
35+
36+ # workaround anaconda requirements
2837passwd -d root
2938passwd -l root
3039
31- # pvgrub support
40+ # Create grub.conf for EC2. This used to be done by appliance creator but
41+ # anaconda doesn't do it. And, in case appliance-creator is used, we're
42+ # overriding it here so that both cases get the exact same file.
43+ # Note that the console line is different -- that's because EC2 provides
44+ # different virtual hardware, and this is a convenient way to act differently
3245echo -n " Creating grub.conf for pvgrub"
3346rootuuid=$( awk ' $2=="/" { print $1 };' /etc/fstab )
3447mkdir /boot/grub
@@ -40,23 +53,39 @@ for kv in $( ls -1v /boot/vmlinuz* |grep -v rescue |sed s/.*vmlinuz-// ); do
4053 echo -e " \tinitrd /boot/initramfs-$kv .img" >> /boot/grub/grub.conf
4154 echo
4255done
56+
57+ # link grub.conf to menu.lst for ec2 to work
58+ echo -n " Linking menu.lst to old-style grub.conf for pv-grub"
4359ln -sf grub.conf /boot/grub/menu.lst
4460ln -sf /boot/grub/grub.conf /etc/grub.conf
4561
4662# setup systemd to boot to the right runlevel
63+ echo -n " Setting default runlevel to multiuser text mode"
4764rm -f /etc/systemd/system/default.target
4865ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
4966echo .
5067
68+ # this is installed by default but we don't need it in virt
69+ echo " Removing linux-firmware package."
5170yum -C -y remove linux-firmware
5271
5372# Remove firewalld; it is required to be present for install/image building.
54- # but we dont ship it in cloud
73+ echo " Removing firewalld. "
5574yum -C -y remove firewalld --setopt=" clean_requirements_on_remove=1"
75+
76+ # remove avahi and networkmanager
77+ echo " Removing avahi/zeroconf and NetworkManager"
5678yum -C -y remove avahi\* Network\*
79+
80+ echo -n " Getty fixes"
81+ # although we want console output going to the serial console, we don't
82+ # actually have the opportunity to login there. FIX.
83+ # we don't really need to auto-spawn _any_ gettys.
5784sed -i ' /^#NAutoVTs=.*/ a\
5885NAutoVTs=0' /etc/systemd/logind.conf
5986
87+ echo -n " Network fixes"
88+ # initscripts don't like this file to be missing.
6089cat > /etc/sysconfig/network << EOF
6190NETWORKING=yes
6291NOZEROCONF=yes
@@ -79,6 +108,7 @@ IPV6INIT="no"
79108PERSISTENT_DHCLIENT="1"
80109EOF
81110
111+ # set virtual-guest as default profile for tuned
82112echo " virtual-guest" > /etc/tuned/active_profile
83113
84114# generic localhost names
@@ -89,6 +119,10 @@ cat > /etc/hosts << EOF
89119EOF
90120echo .
91121
122+ # Because memory is scarce resource in most cloud/virt environments,
123+ # and because this impedes forensics, we are differing from the Fedora
124+ # default of having /tmp on tmpfs.
125+ echo " Disabling tmpfs for /tmp."
92126systemctl mask tmp.mount
93127
94128cat << EOL > /etc/sysconfig/kernel
103137# make sure firstboot doesn't start
104138echo " RUN_FIRSTBOOT=NO" > /etc/sysconfig/firstboot
105139
140+ # workaround https://bugzilla.redhat.com/show_bug.cgi?id=966888
141+ # if ! grep -q growpart /etc/cloud/cloud.cfg; then
142+ # sed -i 's/ - resizefs/ - growpart\n - resizefs/' /etc/cloud/cloud.cfg
143+ # fi
144+
145+
146+ # echo -e 'cloud-user\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers
147+
148+ echo " Cleaning old yum repodata."
106149yum clean all
107150
108- # XXX instance type markers - MUST match CentOS Infra expectation
151+ echo " set instance type markers"
109152echo ' genclo' > /etc/yum/vars/infra
110153
111154# chance dhcp client retry/timeouts to resolve #6866
@@ -115,6 +158,15 @@ timeout 300;
115158retry 60;
116159EOF
117160
161+ # clean up installation logs"
162+ rm -rf /var/log/yum.log
163+ rm -rf /var/lib/yum/*
164+ rm -rf /root/install.log
165+ rm -rf /root/install.log.syslog
166+ rm -rf /root/anaconda-ks.cfg
167+ rm -rf /var/log/anaconda*
168+ rm -rf /root/anac*
169+
118170echo " Fixing SELinux contexts."
119171touch /var/log/cron
120172touch /var/log/boot.log
@@ -124,6 +176,12 @@ mkdir -p /var/cache/yum
124176# reorder console entries
125177sed -i ' s/console=tty0/console=tty0 console=ttyS0,115200n8/' /boot/grub2/grub.cfg
126178
179+ # echo "Zeroing out empty space."
180+ # This forces the filesystem to reclaim space from deleted files
181+ dd bs=1M if=/dev/zero of=/var/tmp/zeros || :
182+ rm -f /var/tmp/zeros
183+ echo " (Don't worry -- that out-of-space error was expected.)"
184+
127185%end
128186
129187%packages
0 commit comments