Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the configuration to use a recent live desktop setup #3

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
Building Custom CentOS 6.4 LiveCD With Ansible
Building Custom CentOS 6.8 LiveCD With Ansible
==============================================

Step by Step Instruction are available here [Building Custom CentOS 6.4 LiveCD With Ansible](http://gr360ry.github.io/blog/2013/11/28/building-custom-centos-6-dot-4-livecd-with-ansible/)
Initial work and step-by-step instructions are available in the blog post: [Building Custom CentOS 6.4 LiveCD With Ansible](http://gr360ry.github.io/blog/2013/11/28/building-custom-centos-6-dot-4-livecd-with-ansible/)

Master branch is being used to build a minimal live cd system, while the desktop branch is being used to build a full desktop live cd.

## Requirements:
1. CentOS 6.X machine.
2. livecd-tools, git, python-argparse, screen and ansible – all packages available in EPEL repository.
1. CentOS 6.X machine or virtual machine.
2. livecd-tools, git, python-argparse, python-jinja2, screen and ansible – all packages available in EPEL repository.

Install EPEL repository if not already installed:

# yum -y install http://ftp.nluug.nl/pub/os/Linux/distr/fedora-epel/6/i386/epel-release-6-8.noarch.rpm
# yum -y install http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

Install required packages:

# yum -y install livecd-tools git ansible python-argparse screen
# yum -y install livecd-tools git ansible python-argparse screen python-jinja2

Clone livecd-ansible repository:

$ git clone https://github.com/GR360RY/livecd-ansible.git
$ git clone https://github.com/kalxas/livecd-ansible.git -b desktop

Add your custom ansible roles, modify centos6-mini.yml and generate the CD:
Add your custom ansible roles, modify centos6-desktop.yml and generate the CD:

$ cd livecd-ansible
$ ./generate_config.py centos6-mini.yml
$ ./generate_config.py centos6-desktop.yml
$ sudo -s
# livecd-creator -c centos6-mini.ks --cache=cache -f centos6-mini

# livecd-creator -c centos6-desktop.ks --cache=cache -f centos6-desktop

Many thanks to Gregory for his initial work!
13 changes: 7 additions & 6 deletions centos6-mini.yml → centos6-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
gather_facts: false

vars:
cdlabel: centos6-mini
hostname: centos6-mini
cdlabel: centos6-desktop
hostname: centos6-desktop
livecd_user: centos
root_password: centos

# Variables below not used directly in playbook. Used by generate_config.py to create basic kickstart file.

lang: en_US.UTF-8
keyboard: us
timezone: Asia/Jerusalem
timezone: Europe/Athens
partition_size: 4096

repos_list:
- { name: 'a-base', baseurl: 'http://mirror.isoc.org.il/pub/centos/6/os/$basearch' }
- { name: 'a-updates', baseurl: 'http://mirror.isoc.org.il/pub/centos/6/updates/$basearch' }
- { name: 'a-base', baseurl: 'http://mirror.centos.org/centos/6.8/os/$basearch' }
- { name: 'a-updates', baseurl: 'http://mirror.centos.org/centos/6.8/updates/$basearch' }

# End of variable block used by generate_config.py

Expand All @@ -27,7 +27,8 @@
# Add your ansible roles here
# - epel-repo
# - centos-sshd-service
- livecd-pxe-common
# Until here
# - livecd-pxe-common
- livecd-post-common


Expand Down
2 changes: 1 addition & 1 deletion generate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
config_file_name=str(sys.argv[1])

template_folder='templates'
default_template='centos6-mini.ks.j2'
default_template='centos6-desktop.ks.j2'

script_path, script_filename = os.path.split(os.path.abspath(__file__))
template_folder=os.path.join(script_path,template_folder)
Expand Down
2 changes: 1 addition & 1 deletion livecd-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#livecd_ansible_src_path: /opt/livecd-ansible
livecd_ansible_src_path: /vagrant

livecd_label: centos6-mini
livecd_label: centos6-desktop

# Upload tasks to tftp and iso server are done in "naive" way.
# It is expected that livecd-builder server has root ssh keys for both servers.
Expand Down
18 changes: 12 additions & 6 deletions roles/livecd-isolinux-common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
- name: Get CDLABEL from isolinux.cfg
shell: /bin/grep CDLABEL {{ live_root }}/isolinux/isolinux.cfg | /usr/bin/head -n1 | /bin/awk '{print $3}' | /bin/awk -F= '{print $3}'
register: cdlabel
changed_when: "cdlabel.rc != 0"
- name: Deploy postnochroot-install
template: src=postnochroot-install.j2 dest={{ live_root }}/postnochroot-install owner=root group=root

- name: Deploy modified isolinux.cfg
template: src=isolinux_isolinux.cfg.j2 dest={{ live_root }}/isolinux/isolinux.cfg owner=root group=root
- name: Execute postnochroot-install
command: /bin/bash {{ live_root }}/postnochroot-install

# - name: Get CDLABEL from isolinux.cfg
# shell: /bin/grep CDLABEL {{ live_root }}/isolinux/isolinux.cfg | /usr/bin/head -n1 | /bin/awk '{print $3}' | /bin/awk -F= '{print $3}'
# register: cdlabel
# changed_when: "cdlabel.rc != 0"

# - name: Deploy modified isolinux.cfg
# template: src=isolinux_isolinux.cfg.j2 dest={{ live_root }}/isolinux/isolinux.cfg owner=root group=root
49 changes: 49 additions & 0 deletions roles/livecd-isolinux-common/templates/postnochroot-install.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# Copy licensing information
cp {{ install_root }}/usr/share/doc/*-release-*/GPL {{ live_root }}/GPL

# add livecd-iso-to-disk utility on the LiveCD
# only works on x86, x86_64
if [ "$(uname -i)" = "i386" -o "$(uname -i)" = "x86_64" ]; then
if [ ! -d {{ live_root }}/LiveOS ]; then mkdir -p {{ live_root }}/LiveOS ; fi
cp /usr/bin/livecd-iso-to-disk {{ live_root }}/LiveOS
fi

# customize boot menu entries
grep -B4 'menu default' {{ live_root }}/isolinux/isolinux.cfg > {{ live_root }}/isolinux/default.txt
grep -B3 'xdriver=vesa' {{ live_root }}/isolinux/isolinux.cfg > {{ live_root }}/isolinux/basicvideo.txt
grep -A3 'label check0' {{ live_root }}/isolinux/isolinux.cfg > {{ live_root }}/isolinux/check.txt
grep -A2 'label memtest' {{ live_root }}/isolinux/isolinux.cfg > {{ live_root }}/isolinux/memtest.txt
grep -A2 'label local' {{ live_root }}/isolinux/isolinux.cfg > {{ live_root }}/isolinux/localboot.txt

sed "s/label linux0/label linuxtext0/" {{ live_root }}/isolinux/default.txt > {{ live_root }}/isolinux/textboot.txt
sed -i "s/Boot/Boot (Text Mode)/" {{ live_root }}/isolinux/textboot.txt
sed -i "s/liveimg/liveimg 3/" {{ live_root }}/isolinux/textboot.txt
sed -i "/menu default/d" {{ live_root }}/isolinux/textboot.txt

sed "s/label linux0/label install0/" {{ live_root }}/isolinux/default.txt > {{ live_root }}/isolinux/install.txt
sed -i "s/Boot/Install/" {{ live_root }}/isolinux/install.txt
sed -i "s/liveimg/liveimg liveinst noswap nolvmmount/" {{ live_root }}/isolinux/install.txt
sed -i "s/ quiet / /" {{ live_root }}/isolinux/install.txt
sed -i "s/ rhgb / /" {{ live_root }}/isolinux/install.txt
sed -i "/menu default/d" {{ live_root }}/isolinux/install.txt

sed "s/label linux0/label textinstall0/" {{ live_root }}/isolinux/default.txt > {{ live_root }}/isolinux/textinstall.txt
sed -i "s/Boot/Install (Text Mode)/" {{ live_root }}/isolinux/textinstall.txt
sed -i "s/liveimg/liveimg textinst noswap nolvmmount/" {{ live_root }}/isolinux/textinstall.txt
sed -i "s/ quiet / /" {{ live_root }}/isolinux/textinstall.txt
sed -i "s/ rhgb / /" {{ live_root }}/isolinux/textinstall.txt
sed -i "/menu default/d" {{ live_root }}/isolinux/textinstall.txt

cat {{ live_root }}/isolinux/default.txt {{ live_root }}/isolinux/basicvideo.txt {{ live_root }}/isolinux/check.txt {{ live_root }}/isolinux/memtest.txt {{ live_root }}/isolinux/localboot.txt > {{ live_root }}/isolinux/current.txt
diff {{ live_root }}/isolinux/isolinux.cfg {{ live_root }}/isolinux/current.txt | sed '/^[0-9][0-9]*/d; s/^. //; /^---$/d' > {{ live_root }}/isolinux/cleaned.txt
cat {{ live_root }}/isolinux/cleaned.txt {{ live_root }}/isolinux/default.txt {{ live_root }}/isolinux/textboot.txt {{ live_root }}/isolinux/basicvideo.txt {{ live_root }}/isolinux/install.txt {{ live_root }}/isolinux/textinstall.txt {{ live_root }}/isolinux/memtest.txt {{ live_root }}/isolinux/localboot.txt > {{ live_root }}/isolinux/isolinux.cfg
rm -f {{ live_root }}/isolinux/*.txt

# Forcing plymouth to show the logo in vesafb
#sed -i "s/rhgb/rhgb vga=791/g" \$LIVE_ROOT/isolinux/isolinux.cfg

# Disabling auto lvm/disk mount (that will crash the "Install to Hard Drive feature")
sed -i "s/quiet/quiet nodiskmount nolvmmount/g" {{ live_root }}/isolinux/isolinux.cfg

15 changes: 11 additions & 4 deletions roles/livecd-post-common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
- livesys
- livesys-late

- name: Go ahead and pre-make the man -k cache
command: /usr/sbin/makewhatis -w

- name: Clean up RPM database
file: path={{ item }} state=absent
with_fileglob: /var/lib/rpm/__db*
Expand All @@ -29,11 +32,15 @@
- name: Disable readahead
file: path=/.readahead_collect state=absent

- name: convince readahead not to collect
file: path=/var/lib/readahead/early.sorted state=touch

# Newer servers come with 10Gbit interfaces on board. Make sure 10gbit Intel driver (ixgbe) is loaded before 1Gbit driver (igb).
# This will insure that first two physical 10Gbit NICs will be detected as eth0 and eth1
# TODO: The same procedure should be repited for 10Gbit Broadcom cards.
- name: Load 10Gbit interfaces first on boot
template: src=etc_modprobe.d_netorder.conf.j2 dest=/etc/modprobe.d/netorder.conf owner=root group=root

- name: Add LINKDELAY for eth0 interface
lineinfile: dest=/etc/sysconfig/network-scripts/ifcfg-eth0 regexp=^LINKDELAY= line=LINKDELAY=10 state=present insertafter=EOF
# - name: Load 10Gbit interfaces first on boot
# template: src=etc_modprobe.d_netorder.conf.j2 dest=/etc/modprobe.d/netorder.conf owner=root group=root

# - name: Add LINKDELAY for eth0 interface
# lineinfile: dest=/etc/sysconfig/network-scripts/ifcfg-eth0 regexp=^LINKDELAY= line=LINKDELAY=10 state=present insertafter=EOF
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ for o in `cat /proc/cmdline` ; do
done

# if liveinst or textinst is given, start anaconda
#if strstr "`cat /proc/cmdline`" liveinst ; then
# plymouth --quit
# /usr/sbin/liveinst $ks
#fi
#if strstr "`cat /proc/cmdline`" textinst ; then
# plymouth --quit
# /usr/sbin/liveinst --text $ks
#fi
if strstr "`cat /proc/cmdline`" liveinst ; then
plymouth --quit
/usr/sbin/liveinst $ks
fi
if strstr "`cat /proc/cmdline`" textinst ; then
plymouth --quit
/usr/sbin/liveinst --text $ks
fi

# configure X, allowing user to override xdriver
if [ -n "\$xdriver" ]; then
exists system-config-display --noui --reconfig --set-depth=24 $xdriver
fi

# Fix the "liveinst doesn't start in gui mode when not enough memory available" - switching to terminal mode
# sed -i "s/Terminal=false/Terminal=true/" /home/$LIVECD_USER/Desktop/liveinst.desktop
sed -i "s/Terminal=false/Terminal=true/" /home/{{ livecd_user }}/Desktop/liveinst.desktop
65 changes: 65 additions & 0 deletions roles/livecd-post-common/templates/etc_rc.d_init.d_livesys.j2
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ fi


## fix various bugs and issues
# unmute sound card
exists alsaunmute 0 2> /dev/null

# turn off firstboot for livecd boots
echo "RUN_FIRSTBOOT=NO" > /etc/sysconfig/firstboot
Expand Down Expand Up @@ -165,6 +167,69 @@ sed -i -e 's/HOSTNAME=localhost.localdomain/HOSTNAME={{ hostname }}/g' /etc/sysc
# give default user sudo privileges
echo "{{ livecd_user }} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

## configure default user's desktop
# set up timed auto-login at 10 seconds
cat >> /etc/gdm/custom.conf << FOE
[daemon]
TimedLoginEnable=true
TimedLogin={{ livecd_user }}
TimedLoginDelay=10
FOE

# add keyboard and display configuration utilities to the desktop
mkdir -p /home/{{ livecd_user }}/Desktop >/dev/null
cp /usr/share/applications/gnome-keyboard.desktop /home/{{ livecd_user }}/Desktop/
cp /usr/share/applications/gnome-display-properties.desktop /home/{{ livecd_user }}/Desktop/

# disable screensaver locking
gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t bool /apps/gnome-screensaver/lock_enabled "false" >/dev/null

# disable PackageKit update checking by default
gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t int /apps/gnome-packagekit/update-icon/frequency_get_updates "0" >/dev/null

# Switching to Thunderbird as the default MUA
gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults --type string --set /desktop/gnome/url-handlers/mailto/command "thunderbird %" >/dev/null

# Creating a file for anaconda, to create the correct grub entry
echo -e "CentOS.$(uname -m)\nCentOS Linux\n6\nyes" > /.buildstamp

# detecting disk partitions and logical volumes
CreateDesktopIconHD()
{
cat > /home/$LIVECD_USER/Desktop/Local\ hard\ drives.desktop << EOF_HDicon
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Link
Name=Local hard drives
Name[en_US]=Local hard drives
Name[fr_CA]=Disques durs locaux
URL=/mnt/disc
Icon=/usr/share/icons/gnome/32x32/devices/gnome-dev-harddisk.png
EOF_HDicon

chmod 755 /home/{{ livecd_user }}/Desktop/Local\ hard\ drives.desktop
}

CreateDesktopIconLVM()
{
mkdir -p /home/{{ livecd_user }}/Desktop >/dev/null

cat > /home/{{ livecd_user }}/Desktop/Local\ logical\ volumes.desktop << EOF_LVMicon
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Link
Name=Local logical volumes
Name[en_US]=Local logical volumes
Name[fr_CA]=Volumes logiques locaux
URL=/mnt/lvm
Icon=/usr/share/icons/gnome/32x32/devices/gnome-dev-harddisk.png
EOF_LVMicon

chmod 755 /home/{{ livecd_user }}/Desktop/Local\ logical\ volumes.desktop
}

# don't mount disk partitions if 'nodiskmount' is given as a boot option
if ! strstr "`cat /proc/cmdline`" nodiskmount ; then
MOUNTOPTION="ro"
Expand Down
Loading