Skip to content
This repository was archived by the owner on Jun 21, 2020. It is now read-only.

Bash: Cobbler

Scot P. Floess edited this page Nov 28, 2015 · 8 revisions

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).

Executing Cobbler Commands

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.

Distro Functions

Utility functions for distro manipulation.

Adjusting ksmeta

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]"

distro-list

Lists all distros:

distro-list

distro-remove

Iterates over a list of distro names and removes them:

distro-remove [distro 1] ... [distro N]

Example

Remove distros CentOS-7.1 and RHEL-7.2:

distro-remove CentOS-7.1 RHEL-7.2

distro-remove-all

Removes all distros:

distro-remove-all

distro-add

Adds a distro from an iso and ensure the tree is set appropriately.

distro-add [distro name] [path to ISO] [optional cobbler params]

Example

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.iso

distro-add-atomic

Adds 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.
  • 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 ksmeta is set to tree=http://@@server@@/cblr/links/[distro name]

Example

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.iso

distro-add-live

Adds a live distro. This function is needed because there of special logic to importing:

  • Extract 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].
  • Set --kopts to rootflags=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

Example

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.iso

Repo Functions

Utility functions for repo manipulation.

repo-list

List all repos.

Example

repo-list

repo-remove

Iterates over a list of repo names and removes them:

repo-remove [repo 1] ... [repo N]

Example

Remove repos Epel-6 and Epel 7:

repo-remove Epel-6 Epel 7

repo-remove-all

Removes all repos:

repo-remove-all

Profile Functions

Utility functions for profile manipulation.

profile-list

Lists all profiles:

profile-list

profile-remove

Iterates over a list of profile names and removes them:

profile-remove [profile 1] ... [profile N]

Example

Remove profiles CentOS-7.1-x86_64 and RHEL-7.2_x86-64:

profile-remove CentOS-7.1-x86_64 RHEL-7.2_x86-64

profile-remove-all

Removes all profiles:

profile-remove-all

System Functions

Utility functions for system manipulation.

system-list

Lists all system:

system-list

system-remove

Iterates over a list of system names and removes them:

system-remove [system 1] ... [system N]

Example

Remove system centos-workstation and rhel-workstation:

system-remove centos-workstation rhel-workstation

system-remove-all

Removes all system:

system-remove-all

system-create-iso

Create an ISO with all systems (passing in no params) or the ones denoted as parameters:

system-create-iso

Or

system-create-iso [system 1] ... [system N]

Examples

Create an ISO for systems named centos-workstation and rhel-workstation:

system-create-iso centos-workstation rhel-workstation

remove-all

Removes all systems, profiles, repos and distros:

remove-all
Clone this wiki locally