Skip to content

Instantly share code, notes, and snippets.

@hagfelsh
Last active January 5, 2018 16:07
Show Gist options
  • Save hagfelsh/ca56528864dd959b73bad57d89f61f86 to your computer and use it in GitHub Desktop.
Save hagfelsh/ca56528864dd959b73bad57d89f61f86 to your computer and use it in GitHub Desktop.
virt-install script for a standard guest
#!/bin/bash
# This script assumes that there's an ISO installed somewhere (so that its contents can be browsed) and that that ISO is then exported as an NFS export.
# The kickstart file is pushed into the boot image so anaconda can draw from it.
# The serial part of extra-args enables virsh <guestname> console to work. It also allows for a console install.
ksfile="standard-ks.cfg"
kspath="/root/virt-things/virt-install-models/conga-c7/$ksfile"
hostname="c7-standard"
virt-install \
-n $hostname\
--os-type Linux \
--os-variant rhel7 \
--ram 1024 \
--vcpus 1 \
--location nfs://192.168.122.1/mnt/c7-iso \
--initrd-inject $kspath \
--extra-args="ks=file:/${ksfile} console=tty0 console=ttyS0,115200n8 serial ip=dhcp" \
--disk pool=cml1,size=14 \
--network default \
--graphics none
#--debug \
# the location arg refers to a local loop mount of an iso that's THEN presented as an nfs export because the guest installer needs to find it from inside of its world
# the kickstart is hosted from some httpd somewhere so the installer can reach it
# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html-single/virtualization_deployment_and_administration_guide/
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
nfs --server=192.168.122.1 --dir=/mnt/c7-iso
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$Xb/qZOA.$aBWgS0KJomvyNmaS3zXDG0
# System language
lang en_US
# Firewall configuration
firewall --disabled
# System authorization information
auth --useshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use text mode install
text
# SELinux configuration
selinux --permissive
# Do not configure the X Window System
skipx
# add kdump
%addon com_redhat_kdump --enable --reserve-mb=auto
%end
# accept the eula
eula --agreed
# disable the firstboot application
firstboot --disable
# add user
user --name=keiser --password=$6$lZfd6xc8MhoyQ.qk$/mXJnu/ObWzb7pfyaY03ftLKfVtYcng4rXhLgwVRvc8R3xuYr6oZo9vK4uR0GlZU6haccDBaCYzgYt7.BcWeS0 --iscrypted
user --name=cephop --password=$6$lZfd6xc8MhoyQ.qk$/mXJnu/ObWzb7pfyaY03ftLKfVtYcng4rXhLgwVRvc8R3xuYr6oZo9vK4uR0GlZU6haccDBaCYzgYt7.BcWeS0 --iscrypted
# Reboot after installation
reboot
# System timezone
timezone America/Chicago
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all
# Disk partitioning information
part /boot --fstype="ext4" --ondisk=vda --size=512
part swap --fstype="swap" --ondisk=vda --recommended
# manually creating logical volumes
part pv.01 --size=1 --ondisk=vda --grow
volgroup vg_root pv.01
logvol / --vgname=vg_root --size 12288 --name=lv_root --fstype=ext4
#logvol /home --vgname=vg_root --size 2048 --name=lv_home
# add the dell internal repo
repo --name=dell-os --baseurl=http://linuxlib.us.dell.com/pub/Distros/centos/partners.centos.com/7/os/x86_64/ --name="Dell OS" --install
repo --name=dell-extras --baseurl=http://linuxlib.us.dell.com/pub/Distros/centos/partners.centos.com/7/extras/x86_64/ --name="Dell Extras" --install
repo --name=dell-updates --baseurl=http://linuxlib.us.dell.com/pub/Distros/centos/partners.centos.com/7/updates/x86_64/ --name="Dell Updates" --install
repo --name=dell-epel --baseurl=http://linuxlib.us.dell.com/pub/epel/7/x86_64/ --name="Dell Epel" --install
%packages --default --ignoremissing
#@^iSCSI Storgae Client
@^Base
#@NFS file server
htop
tree
vim
tmux
#scsi-target-utils
sg3_utils
ioping
wget
ntp
ntpdate
%end
%post --nochroot
echo "nameserver 100.88.65.10" >> /etc/resolv.conf
cat >/etc/yum.repos.d/dell-internal.repo <<EOF
[dell-os]
name=Dell Internal - OS
baseurl=http://linuxlib.us.dell.com/pub/Distros/centos/partners.centos.com/7/os/x86_64/
gpgcheck=0
enabled=1
#proxy = http://linuxlib.us.dell.com
[dell-Extras]
name=Dell Internal - Extras
baseurl=http://linuxlib.us.dell.com/pub/Distros/centos/partners.centos.com/7/extras/x86_64/
gpgcheck=0
enabled=1
#proxy = http://linuxlib.us.dell.com
[dell-updates]
name=Dell Internal - Updates
baseurl=http://linuxlib.us.dell.com/pub/Distros/centos/partners.centos.com/7/updates/x86_64/
gpgcheck=0
enabled=1
[dell-epel]
name=Dell Internal - EPEL
baseurl=http://linuxlib.us.dell.com/pub/epel/7/x86_64/
gpgcheck=0
enabled=1
skip_if_unavailable = 1
keepcache = 0
EOF
cat >/etc/yum.repos.d/ceph.repo <<EOF
[Ceph]
name=Ceph packages for $basearch
baseurl=http://download.ceph.com/rpm-luminous/el7/$basearch
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://download.ceph.com/keys/release.asc
priority=1
[Ceph-noarch]
name=Ceph noarch packages
baseurl=http://download.ceph.com/rpm-luminous/el7/noarch
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://download.ceph.com/keys/release.asc
priority=1
[ceph-source]
name=Ceph source packages
baseurl=http://download.ceph.com/rpm-luminous/el7/SRPMS
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://download.ceph.com/keys/release.asc
priority=1
EOF
echo 'cephop ALL = (root) NOPASSWD:ALL' > /etc/sudoers.d/cephop
chmod 0440 /etc/sudoers.d/cephop
%end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment