Skip to content

Instantly share code, notes, and snippets.

@duncaninnes
Last active June 2, 2019 15:41
Show Gist options
  • Save duncaninnes/182ad50c2e7c612ccf0a9d81872dd988 to your computer and use it in GitHub Desktop.
Save duncaninnes/182ad50c2e7c612ccf0a9d81872dd988 to your computer and use it in GitHub Desktop.
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
install
text
network --bootproto=dhcp
url --url="http://192.168.122.1/centos7.2.1511"
lang en_GB
keyboard 'uk'
zerombr
clearpart --drives=vda --all --initlabel
bootloader --boot-drive=vda
timezone Europe/London --isUtc
auth --useshadow --passalgo=sha512
rootpw --iscrypted SecretStuffHere
selinux --enforcing
reboot
firewall --disabled
skipx
part biosboot --fstype=biosboot --size=1
part /boot --fstype=xfs --size=512 --ondisk=vda
part pv.01 --size=1024 --grow --ondisk=vda
volgroup vg_root pv.01
logvol / --vgname=vg_root --name=lv_root --size=10240 --fstype=xfs
logvol swap --vgname=vg_root --name=lv_swap --size=512 --fstype=swap
logvol /var --vgname=vg_root --name=lv_var --size=4096 --fstype=xfs
logvol /tmp --vgname=vg_root --name=lv_tmp --size=1024 --fstype=xfs
logvol /home --vgname=vg_root --name=lv_home --size=1024 --fstype=xfs
logvol /var/lib/pulp --vgname=vg_root --name=lv_pulp --size=32768 --fstype=xfs
logvol /var/lib/mongodb --vgname=vg_root --name=lv_mongo --size=8192 --fstype=xfs
%packages --excludedocs --nobase
@core --nodefaults
chrony
-aic94xx-firmware*
-alsa*
-biosdevname
-btrfs-progs*
-dracut-network
-ethtool
-iprutils
-ivtv*
-iwl*firmware*
-kexec-tools
-man-db
-microcode_ctl
-NetworkManager*
-parted
-plymouth*
-postfix
-rdma
-tcp_wrappers*
-tuned
-wpa_supplicant
%end
%post --log /root/ks-vm-post.log
echo "`date +%F-%T` - Post Installation Log Start"
echo "`date +%F-%T`"
echo "`date +%F-%T` - Modify login text"
cat > /etc/issue <<'EOF'
********************************************************************************
* *
* NOTICE TO USERS *
* =============== *
* *
* This computer system is the private property of ${USERNAME}. *
* *
* *
* LOG OFF IMMEDIATELY if you do not know what you are doing. *
* *
********************************************************************************
EOF
echo "`date +%F-%T` - Modify NTP settings"
sed -i -e 's/0\..*\.pool\.ntp\.org/192.168.122.1/g' /etc/chrony.conf
sed -i -e '/org iburst/d' /etc/chrony.conf
echo "`date +%F-%T` - Configure ssh key & install script"
/usr/bin/cat > /root/katello_install.sh <<INSTALLEOF
foreman-installer --scenario katello --foreman-admin-password password123 --foreman-initial-organization ACME --foreman-initial-location Laptop --enable-foreman-plugin-bootdisk --enable-foreman-plugin-remote-execution --enable-foreman-proxy-plugin-remote-execution-ssh --foreman-proxy-tftp true --enable-foreman-plugin-openscap --enable-foreman-proxy-plugin-openscap
/usr/bin/mkdir /root/.hammer
/usr/bin/cat > /root/.hammer/cli_config.yml <<HAMMEREOF
:foreman:
:enable_module: true
:host: 'https://localhost/'
:username: 'admin'
:password: 'password123'
HAMMEREOF
/usr/bin/chmod 600 /root/.hammer/cli_config.yml
/usr/bin/yum -y install foreman-libvirt
/usr/bin/katello-service restart
/usr/bin/sleep 30
/usr/bin/hammer subnet create --organizations="ACME" --locations="Laptop" --name="Libvirt-default" --network=192.168.122.0 --mask=255.255.255.0 --boot-mode="DHCP" --dns-primary=192.168.122.1 --domains="acme.net" --from=192.168.122.2 --to=192.168.122.254 --gateway=192.168.122.1 --ipam="DHCP"
/usr/bin/hammer compute-resource create --name=Libvirt --provider=libvirt --url="qemu+ssh://root@192.168.122.1/system" --description="Laptop" --locations="Laptop" --organizations="ACME"
/usr/bin/hammer product create --organization-id=1 --name=CentOS --label=CentOS --description="CentOS 7.3.1611 x86_64 repositories"
/usr/bin/hammer product create --organization-id=1 --name=EPEL --label=EPEL --description="EPEL 7 x86_64 repository"
/usr/bin/hammer product create --organization-id=1 --name=Katello --label=Katello --description="Katello Client 3.3 for CentOS 7 x86_64 repository"
/usr/bin/hammer repository create --organization-id=1 --product=CentOS --content-type=yum --name="CentOS 7 Base" --label="CentOS_7_Base" --url="https://www.mirrorservice.org/sites/mirror.centos.org/7.3.1611/os/x86_64/"
/usr/bin/hammer repository create --organization-id=1 --product=CentOS --content-type=yum --name="CentOS 7 Updates" --label="CentOS_7_Updates" --url="https://www.mirrorservice.org/sites/mirror.centos.org/7.3.1611/updates/x86_64/"
/usr/bin/hammer repository create --organization-id=1 --product=CentOS --content-type=yum --name="CentOS 7 Extras" --label="CentOS_7_Extras" --url="https://www.mirrorservice.org/sites/mirror.centos.org/7.3.1611/extras/x86_64/"
/usr/bin/hammer repository create --organization-id=1 --product=CentOS --content-type=yum --name="CentOS 7 SCLo sclo" --label="CentOS_7_SCLo_sclo" --url="https://www.mirrorservice.org/sites/mirror.centos.org/7.3.1611/sclo/x86_64/sclo/"
/usr/bin/hammer repository create --organization-id=1 --product=CentOS --content-type=yum --name="CentOS 7 SCLo rh" --label="CentOS_7_SCLo_rh" --url="https://www.mirrorservice.org/sites/mirror.centos.org/7.3.1611/sclo/x86_64/rh/"
/usr/bin/hammer repository create --organization-id=1 --product=EPEL --content-type=yum --name="EPEL 7" --label="EPEL_7" --url="https://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/7/x86_64/"
/usr/bin/hammer repository create --organization-id=1 --product=Katello --content-type=yum --name="Katello Client 3.3" --label="Katello_Client_3.3" --url="https://fedorapeople.org/groups/katello/releases/yum/3.3/client/el7/x86_64/"
/usr/bin/hammer content-view create --organization-id 1 --name "CentOS 7 Client" --label "CentOS_7_Client" --description "CentOS 7 Base OS & Katello client repos"
/usr/bin/hammer content-view add-repository --organization-id 1 --name "CentOS 7 Client" --repository "CentOS 7 Base"
/usr/bin/hammer content-view add-repository --organization-id 1 --name "CentOS 7 Client" --repository "CentOS 7 Updates"
/usr/bin/hammer content-view add-repository --organization-id 1 --name "CentOS 7 Client" --repository "CentOS 7 Extras"
/usr/bin/hammer content-view add-repository --organization-id 1 --name "CentOS 7 Client" --repository "EPEL 7"
/usr/bin/hammer content-view add-repository --organization-id 1 --name "CentOS 7 Client" --repository "Katello Client 3.3"
/usr/bin/cat ~foreman-proxy/.ssh/id_rsa_foreman_proxy.pub >> /root/.ssh/authorized_keys
INSTALLEOF
/usr/bin/chmod +x /root/katello_install.sh
/usr/bin/chmod 600 /root/.ssh/authorized_keys
echo "`date +%F-%T` - Run yum update"
yum -y update
echo "`date +%F-%T` - Install Katello repos"
yum -y localinstall http://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm
yum -y localinstall http://yum.theforeman.org/releases/1.12/el7/x86_64/foreman-release.rpm
yum -y localinstall http://fedorapeople.org/groups/katello/releases/yum/3.1/katello/el7/x86_64/katello-repos-latest.rpm
yum -y localinstall http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install foreman-release-scl
echo "`date +%F-%T` - Install Katello packages"
yum -y install katello
echo "`date +%F-%T` - ******************************"
echo "`date +%F-%T` - * Post Installation Complete *"
echo "`date +%F-%T` - ******************************"
%end
@Tomelin
Copy link

Tomelin commented Apr 16, 2018

Hi dear,

This url (url --url="http://192.168.122.1/centos7.2.1511") in name.ks is name product Centos7 ? Or not reference the product?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment