Skip to content

Commit 823ec0c

Browse files
committed
add generic ks, remove the stale file, add c6 ks
1 parent de9b2a3 commit 823ec0c

File tree

2 files changed

+225
-8
lines changed

2 files changed

+225
-8
lines changed

cloudimg/CentOS-6-x86_64-hvm.ks

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# Build a basic CentOS 6.5 x86_64
2+
lang en_US.UTF-8
3+
keyboard us
4+
timezone --utc UTC
5+
auth --useshadow --enablemd5
6+
rootpw --iscrypted nothing
7+
selinux --enforcing
8+
firewall --service=ssh
9+
bootloader --timeout=1
10+
network --bootproto=dhcp --device=eth0 --onboot=on
11+
services --enabled=network
12+
zerombr
13+
clearpart --all --initlabel
14+
part / --size 4096 --grow --fstype ext4
15+
reboot
16+
17+
# Repositories
18+
repo --name=CentOS6-Base --baseurl=http://mirrorsnap.centos.org/DATESTAMP/centos/6/os/x86_64
19+
repo --name=CentOS6-Updates --baseurl=http://mirrorsnap.centos.org/DATESTAMP/centos/6/updates/x86_64
20+
repo --name=CentOS6-Extras --baseurl=http://mirrorsnap.centos.org/DATESTAMP/centos/6/extras/x86_64
21+
22+
#
23+
#
24+
# Add all the packages after the base packages
25+
#
26+
%packages --nobase --instLangs=en
27+
@core
28+
system-config-securitylevel-tui
29+
newt-python
30+
system-config-firewall-base
31+
audit
32+
pciutils
33+
bash
34+
coreutils
35+
kernel
36+
grub
37+
e2fsprogs
38+
passwd
39+
policycoreutils
40+
chkconfig
41+
rootfiles
42+
yum
43+
yum-presto
44+
vim-minimal
45+
acpid
46+
openssh-clients
47+
openssh-server
48+
curl
49+
man
50+
rsync
51+
#Allow for dhcp access
52+
dhclient
53+
iputils
54+
55+
# cloud stuff
56+
cloud-init
57+
58+
#stuff we really done want
59+
-kernel-firmware
60+
-xorg-x11-drv-ati-firmware
61+
-iwl6000g2a-firmware
62+
-aic94xx-firmware
63+
-iwl6000-firmware
64+
-iwl100-firmware
65+
-ql2200-firmware
66+
-libertas-usb8388-firmware
67+
-ipw2100-firmware
68+
-atmel-firmware
69+
-iwl3945-firmware
70+
-ql2500-firmware
71+
-rt61pci-firmware
72+
-ipw2200-firmware
73+
-iwl6050-firmware
74+
-iwl1000-firmware
75+
-bfa-firmware
76+
-iwl5150-firmware
77+
-iwl5000-firmware
78+
-ql2400-firmware
79+
-rt73usb-firmware
80+
-ql23xx-firmware
81+
-iwl4965-firmware
82+
-ql2100-firmware
83+
-ivtv-firmware
84+
-zd1211-firmware
85+
86+
%end
87+
88+
#
89+
# Add custom post scripts after the base post.
90+
#
91+
%post
92+
%end
93+
94+
# more ec2-ify
95+
%post --erroronfail
96+
# disable root password based login
97+
cat >> /etc/ssh/sshd_config << EOF
98+
PermitRootLogin without-password
99+
UseDNS no
100+
EOF
101+
102+
sed -i 's|PasswordAuthentication yes|PasswordAuthentication no|' /etc/ssh/sshd_config
103+
104+
# set the firstrun flag
105+
touch /root/firstrun
106+
107+
# lock the root pass
108+
passwd -l root
109+
110+
# chance dhcp client retry/timeouts to resolve #6866
111+
cat >> /etc/dhcp/dhclient.conf << EOF
112+
113+
timeout 300
114+
retry 60
115+
EOF
116+
# set up ssh key fetching and set a random root passwd if needed
117+
cat >> /etc/rc.local << EOF
118+
119+
# set a random pass on first boot
120+
if [ -f /root/firstrun ]; then
121+
dd if=/dev/urandom count=50|md5sum|passwd --stdin root
122+
passwd -l root
123+
rm /root/firstrun
124+
fi
125+
126+
if [ ! -d /root/.ssh ]; then
127+
mkdir -m 0700 -p /root/.ssh
128+
restorecon /root/.ssh
129+
fi
130+
EOF
131+
132+
# Do some basic cleanup
133+
sed -i -e 's/^ACTIVE_CONSOLES=\/dev\/tty\[1-6\]/ACTIVE_CONSOLES=\/dev\/tty1/' /etc/sysconfig/init
134+
135+
# make sure the kernel can be updated
136+
rm /boot/grub/menu.lst
137+
rm /etc/grub.conf
138+
ln -s /boot/grub/grub.conf /boot/grub/menu.lst
139+
ln -s /boot/grub/grub.conf /etc/grub.conf
140+
cat >> /etc/sysconfig/kernel << EOF
141+
UPDATEDEFAULT=yes
142+
DEFAULTKERNEL=kernel
143+
EOF
144+
145+
# clear out some network stuff
146+
sed -i "/HWADDR/d" /etc/sysconfig/network-scripts/ifcfg-eth*
147+
rm -f /etc/udev/rules.d/*-persistent-net.rules
148+
touch /etc/udev/rules.d/75-persistent-net-generator.rules
149+
echo NOZEROCONF=yes >> /etc/sysconfig/network
150+
151+
152+
#echo "Zeroing out empty space."
153+
# This forces the filesystem to reclaim space from deleted files
154+
dd bs=1M if=/dev/zero of=/var/tmp/zeros || :
155+
rm -f /var/tmp/zeros
156+
echo "(Don't worry -- that out-of-space error was expected.)"
157+
158+
%end
159+

cloudimg/CentOS-7-x86_64-GenericCloud-201606-r1.ks renamed to cloudimg/CentOS-7-x86_64-hvm.ks

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
1+
# System authorization information
12
auth --enableshadow --passalgo=sha512
3+
# Reboot after installation
24
reboot
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
48
firewall --enabled --service=ssh
59
firstboot --disable
610
ignoredisk --only-use=vda
11+
# Keyboard layouts
12+
# old format: keyboard us
13+
# new format:
714
keyboard --vckeymap=us --xlayouts='us'
815
# System language
916
lang 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
1421
network --bootproto=dhcp
1522
network --hostname=localhost.localdomain
1623
# Root password
17-
rootpw --iscrypted thereisnopasswordanditslocked
24+
rootpw --iscrypted nothing
1825
selinux --enforcing
1926
services --disabled="kdump" --enabled="network,sshd,rsyslog,chronyd"
2027
timezone UTC --isUtc
@@ -25,10 +32,16 @@ clearpart --all --initlabel
2532
part / --fstype="xfs" --ondisk=vda --size=4096 --grow
2633

2734
%post --erroronfail
35+
36+
# workaround anaconda requirements
2837
passwd -d root
2938
passwd -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
3245
echo -n "Creating grub.conf for pvgrub"
3346
rootuuid=$( awk '$2=="/" { print $1 };' /etc/fstab )
3447
mkdir /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
4255
done
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"
4359
ln -sf grub.conf /boot/grub/menu.lst
4460
ln -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"
4764
rm -f /etc/systemd/system/default.target
4865
ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
4966
echo .
5067
68+
# this is installed by default but we don't need it in virt
69+
echo "Removing linux-firmware package."
5170
yum -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."
5574
yum -C -y remove firewalld --setopt="clean_requirements_on_remove=1"
75+
76+
# remove avahi and networkmanager
77+
echo "Removing avahi/zeroconf and NetworkManager"
5678
yum -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.
5784
sed -i '/^#NAutoVTs=.*/ a\
5885
NAutoVTs=0' /etc/systemd/logind.conf
5986
87+
echo -n "Network fixes"
88+
# initscripts don't like this file to be missing.
6089
cat > /etc/sysconfig/network << EOF
6190
NETWORKING=yes
6291
NOZEROCONF=yes
@@ -79,6 +108,7 @@ IPV6INIT="no"
79108
PERSISTENT_DHCLIENT="1"
80109
EOF
81110
111+
# set virtual-guest as default profile for tuned
82112
echo "virtual-guest" > /etc/tuned/active_profile
83113
84114
# generic localhost names
@@ -89,6 +119,10 @@ cat > /etc/hosts << EOF
89119
EOF
90120
echo .
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."
92126
systemctl mask tmp.mount
93127
94128
cat <<EOL > /etc/sysconfig/kernel
@@ -103,9 +137,18 @@ EOL
103137
# make sure firstboot doesn't start
104138
echo "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."
106149
yum clean all
107150
108-
# XXX instance type markers - MUST match CentOS Infra expectation
151+
echo "set instance type markers"
109152
echo 'genclo' > /etc/yum/vars/infra
110153
111154
# chance dhcp client retry/timeouts to resolve #6866
@@ -115,6 +158,15 @@ timeout 300;
115158
retry 60;
116159
EOF
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+
118170
echo "Fixing SELinux contexts."
119171
touch /var/log/cron
120172
touch /var/log/boot.log
@@ -124,6 +176,12 @@ mkdir -p /var/cache/yum
124176
# reorder console entries
125177
sed -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

Comments
 (0)