-
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 kernel and initrd.img are extracted via livecd-iso-to-pxeboot as 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].
Assume importing the CentOS-7.1 Atomic ISO /root/distro/iso/CentOS-Atomic-Host-7-Installer.iso:
distro-add CentOS-7.1-Atomic-x86_64 /root/distro/iso/CentOS-Atomic-Host-7-Installer.iso