-
Notifications
You must be signed in to change notification settings - Fork 3
Bash: Cobbler
This page will describe how to use the cobbler-util.sh script. A good example can be found in my [personal git repo] (https://github.com/sfloess/scripts/blob/master/bash/cobbler.sh).
We've included a convenience function, cobbler-exec that calls to cobbler and emits information on what's being called (in green) and if the call returns a non-zero, emits a yellow warning message.
For example:
cobbler-exec repo add --mirror-locally="0" --name="CentOS-5-Example" --mirror="http://mirror.centos.org/centos-5/5/extras/x86_64"
cobbler-exec repo add --mirror-locally="0" --name="CentOS-5-Example" --mirror="http://mirror.centos.org/centos-5/5/extras/x86_64"
cobbler-exec repo remove --name="CentOS-5-Example"Yields:
INFO: Executing: cobbler [repo add --mirror-locally=0 --name=CentOS-5-Example --mirror=http://mirror.centos.org/centos-5/5/extras/x86_64]
INFO: Executing: cobbler [repo add --mirror-locally=0 --name=CentOS-5-Example --mirror=http://mirror.centos.org/centos-5/5/extras/x86_64]
exception on server: "it seems unwise to overwrite this object, try 'edit'"
WARNING: Trouble executing [1]: cobbler [repo add --mirror-locally=0 --name=CentOS-5-Example --mirror=http://mirror.centos.org/centos-5/5/extras/x86_64]
INFO: Executing: cobbler [repo remove --name=CentOS-5-Example]Where:
- INFO is in green.
- WARNING is in yellow.
Utility functions for distro manipulation.
For both distro-add and distro-add-atomic, we ensure the --ksmeta param is set appropriately as so:
cobbler distro edit --name="[distro name]" --ksmeta="tree=http://@@server@@/cblr/links/[distro name]"Lists all distros:
distro-listIterates over a list of distro names and removes them:
distro-remove [distro 1] ... [distro N]Remove distros CentOS-7.1 and RHEL-7.2:
distro-remove CentOS-7.1 RHEL-7.2Removes all distros:
distro-remove-allAdds a distro from an iso and ensure the tree is set appropriately.
distro-add [distro name] [path to ISO] [optional cobbler params]Assume importing the CentOS-7.1 ISO /root/distro/iso/CentOS-7-x86_64-Everything-1503-01.iso:
distro-add CentOS-7.1-x86_64 /root/distro/iso/CentOS-7-x86_64-Everything-1503-01.isoAdds an Atomic distro. This function is needed because an Atomic ISO does not quite look like a normal distro - and is almost like a Live CD:
- The
kernelandinitrd.imgare extracted vialivecd-iso-to-pxebootas described [here] (https://fedorahosted.org/cobbler/wiki/HowToPxeAnyLiveCd). - Both are then copied to the
/var/www/cobbler/ks_mirror/[distro name]area. - A sym link is create from
/var/www/cobbler/ks_mirror/[distro name]to/var/www/cobbler/links/[distro name]. - The distro is imported and added.
- The distro's
ksmetais set totree=http://@@server@@/cblr/links/[distro name]
Assume importing the CentOS-7.1 Atomic ISO /root/distro/iso/CentOS-Atomic-Host-7-Installer.iso:
distro-add-atomic CentOS-7.1-Atomic-x86_64 /root/distro/iso/CentOS-Atomic-Host-7-Installer.isoAdds a live distro. This function is needed because there of special logic to importing:
- Extract the
kernelandinitrd.imgare extracted vialivecd-iso-to-pxebootas described [here] (https://fedorahosted.org/cobbler/wiki/HowToPxeAnyLiveCd). - Both are then copied to the
/var/www/cobbler/ks_mirror/[distro name]area and a sym link is create from/var/www/cobbler/ks_mirror/[distro name]to/var/www/cobbler/links/[distro name]. - Set
--koptstorootflags=loop !ksdevice !text root=live:/`basename [ISO]` rootfstype=iso9660 !lang.
While the import works, you must know the default root password in order to login
Assume importing the Centos 7 Live CD /root/distro/iso/CentOS-7-livecd-x86_64.iso:
distro-add-live CentOS-7.1-Live-x86_64 /root/distro/iso/CentOS-7-livecd-x86_64.isoUtility functions for repo manipulation.
List all repos.
repo-listIterates over a list of repo names and removes them:
repo-remove [repo 1] ... [repo N]Remove repos Epel-6 and Epel 7:
repo-remove Epel-6 Epel 7Removes all repos:
repo-remove-allUtility functions for profile manipulation.
Lists all profiles:
profile-listIterates over a list of profile names and removes them:
profile-remove [profile 1] ... [profile N]Remove profiles CentOS-7.1-x86_64 and RHEL-7.2_x86-64:
profile-remove CentOS-7.1-x86_64 RHEL-7.2_x86-64Removes all profiles:
profile-remove-allUtility functions for system manipulation.
Lists all system:
system-listIterates over a list of system names and removes them:
system-remove [system 1] ... [system N]Remove system centos-workstation and rhel-workstation:
system-remove centos-workstation rhel-workstationRemoves all system:
system-remove-allCreate an ISO with all systems (passing in no params) or the ones denoted as parameters:
system-create-isoOr
system-create-iso [system 1] ... [system N]Create an ISO for systems named centos-workstation and rhel-workstation:
system-create-iso centos-workstation rhel-workstationRemoves all systems, profiles, repos and distros:
remove-all