Cobbler Primitives

Primitives are the building blocks Cobbler uses to represent builds, as outlined in the "How We Model Things" section of the Introduction to Cobbler page. These objects are generally loosely related, though the distro/profile/system relation is somewhat more strict.

This section covers the creation and use of these objects, as well as how they relate to each other - including the methodology by which attributes are inherited from parent objects.

Standard Rules

Cobbler has a standard set of rules for manipulating primitive field values and, in the case of distros/profiles/systems, how those values are inherited from parents to children.

Inheritance of Values

Inheritance of values is based on the field type.

  • For regular fields and arrays, the value will only be inherited if the field is set to '<<inherit>>'. Since distros and other objects like repos do not have a parent, these values are inherited from the defaults in Cobbler Settings. If the field is specifically set to an empty string, no value will be inherited.
  • For hashes, the values from the parent will always be inherited and blended with the child values. If the parent and child have the same key, the child's values will win an override the parent's.

Array Fields

Some fields in Cobbler (for example, the --name-servers field) are stored as arrays. These arrays are always considered arrays of strings, and are always specified in Cobbler as a space-separated list when using add/edit.

Example:

$ cobbler [object] edit --name=foo --field="a b c d"

Hash Fields (key=value)

Other fields in Cobbler (for example, the --ksmeta field) are stored as hashes - that is a list of key=value pairs. As with arrays, both the keys and values are always interpreted as strings.

Preserving Values When Editing

By default, any time a hash field is manipulated during an edit, the contents of the field are replaced completely with the new values specified during the edit.

Example:

$ cobbler distro edit --name=foo --ksmeta="a=b c=d"
$ cobbler distro report --name=foo | grep "Kickstart Meta"
Kickstart Metadata             : {'a': 'b', 'c': 'd'}
$ cobbler distro edit --name=foo --ksmeta="e=f"
$ cobbler distro report --name=foo | grep "Kickstart Meta"
Kickstart Metadata             : {'e': 'f'}

To preserve the contents of these fields, --in-place should be specified:

$ cobbler distro edit --name=foo --ksmeta="a=b c=d"
$ cobbler distro report --name=foo | grep "Kickstart Meta"
Kickstart Metadata             : {'a': 'b', 'c': 'd'}
$ cobbler distro edit --name=foo --in-place --ksmeta="e=f"
$ cobbler distro report --name=foo | grep "Kickstart Meta"
Kickstart Metadata             : {'a': 'b', 'c': 'd', 'e': 'f'}

Removing Values

To remove a single value from the hash, use the '~' (tilde) character along with --in-place:

$ cobbler distro edit --name=foo --ksmeta="a=b c=d"
$ cobbler distro report --name=foo | grep "Kickstart Meta"
Kickstart Metadata             : {'a': 'b', 'c': 'd'}
$ cobbler distro edit --name=foo --in-place --ksmeta='~a'
$ cobbler distro report --name=foo | grep "Kickstart Meta"
Kickstart Metadata             : {'c': 'd'}

Suppressing Values

You can also suppress values from being used, by specifying the '-' character in front of the key name:

$ cobbler distro edit --name=foo --ksmeta="a=b c=d"
$ cobbler distro report --name=foo | grep "Kickstart Meta"
Kickstart Metadata             : {'a': 'b', 'c': 'd'}
$ cobbler distro edit --name=foo --in-place --ksmeta='-a'
$ cobbler distro report --name=foo | grep "Kickstart Meta"
Kickstart Metadata             : {'-a': 'b', 'c': 'd'}

In this case, the key=value pair will be ignored when the field is accessed.

Keys Without Values

You can always specify keys without a value:

$ cobbler distro edit --name=foo --ksmeta="a b c"
$ cobbler distro report --name=foo | grep "Kickstart Meta"
Kickstart Metadata             : {'a': '~', 'c': '~', 'b': '~'}

Note: While valid syntax, this could cause problems for some fields where Cobbler expects a value (for example, --template-files).

Keys With Multiple Values

It is also possible to specify multiple values for the same key. In this situation, Cobbler will convert the value portion to an array:

$ cobbler distro edit --name=foo --in-place --ksmeta="a=b a=c a=d"
$ cobbler distro report --name=foo | grep "Kickstart Meta"
Kickstart Metadata             : {'a': ['b', 'c', 'd']}

Note: You must specify --in-place for this to work. By default the behavior will result in a single value, with the last specified value being the winner.

Standard Primitive Sub-commands

All primitive objects support the following standard sub-commands:

List

The list command simply prints out an alphabetically sorted list of all objects.

Example:

$ cobbler distro list
   centos6.3-x86_64
   debian6.0.5-x86_64
   f17-x86_64
   f18-beta6-x86_64
   opensuse12.2-i386
   opensuse12.2-x86_64
   opensuse12.2-xen-i386
   opensuse12.2-xen-x86_64
   sl6.2-i386
   sl6.2-x86_64
   ubuntu-12.10-i386
   ubuntu-12.10-x86_64

The list command is actually available as a top-level command as well, in which case it will iterate through every object type and list everything currently stored in your Cobbler database.

Report

The report command prints a formatted report of each objects configuration. The optional --name argument can be used to limit the output to a single object, otherwise a report will be printed out for every object (if you have a lot of objects in a given category, this can be somewhat slow).

As with the list command, the report command is also available as a top-level command, in which case it will print a report for every object that is stored in your Cobbler database.

Remove

The remove command uses only the --name option.

Note: Removing an object will also remove any child objects (profiles, sub-profiles and/or systems). Prior versions of Cobbler required an additional --recursive option to enable this behavior, but it has become the default in recent versions so use remove with caution.

Example:

$ cobbler [object] remove --name=foo

Copy/Rename

The copy and rename commands work similarly, with both requiring a --name and --newname options.

Example:

$ cobbler [object] copy --name=foo --newname=bar

or

$ cobbler [object] rename --name=foo --newname=bar

Find

The find command allows you to search for objects based on object attributes.

Please refer to the Command Line Search section for more details regarding the find sub-command.

Dumpvars (Debugging)

The dumpvars command is intended to be used for debugging purposes, and for those writing snippets. In general, it is not required for day-to-day use.


comments powered by Disqus