Configuration cheat sheet

Written
26 February 2014
Updated
16 June 2026
Author
James Adams

This article is intended as quick reference, or cheat sheet showing examples of a variety of common and simple configuration snippets in Quattor.

If you have any other examples, please add them!

Packages

Add default (latest) version of a package

'/software/packages' = pkg_repl('ruby');

Add default (latest) version of multiple packages:

'/software/packages' = {
    pkg_repl('ruby');
    pkg_repl('git');
};

Pin the version and/or architecture of a package

Pin version:

'/software/packages' = pkg_repl("example-package", "0.1.19-1.el6");

Pin Architecture:

'/software/packages/{example-package.noarch}' ?= dict();

Pin both:

'/software/packages' = pkg_repl("example-package", "0.1.19-1.el6", "noarch");

You can also use wildcards for pinning. Note that this will apply to packages which match and exist the specified version and architecture, others are silently ignored.

'/software/packages' = pkg_repl("python*", "2.6.19-1.el6", "x86_64");

This would pin python-devel and python-libs at 2.6.19-1.el6, but leave python-urlgrabber at 3.1.0-6.el5.

'noarch' could of course be 'x86_64', 'i686', PKG_ARCH_DEFAULT or a variable depending on your requirements!

Repositories

Add a repository

'/software/repositories' = append(create('repository/clockwork_angels'));

Exclude a package from a repository

In the config.pan file for the repository, add the following to exclude a package:

'excludepkgs' = list (
    'package_1',
    'package_2
);

Directory and Files

Ensure a directory exists (and has correct permissions)

include 'components/dirperm/config';

'/software/components/dirperm/paths' = append(SELF, dict(
    'path', "/opt/temple",
    'owner', "syrinx:syrinx",
    'perm', '0755',
    'type', 'd',
));

Include the contents of an arbitrary file from the source tree

include 'components/filecopy/config';

prefix '/software/components/filecopy/services/{/etc/rsyslog.conf}';
'config' = file_contents('site/logging/rsyslog/nameserver.conf');

Download a file from a web server

include 'components/download/config';

'/software/components/download/files/{/opt/java-mess/horrible.jar}' = dict(
    'href', 'https://download.example.com/java-mess/jar/horrible-1.2.3.jar',
    'owner', 'root',
    'group', 'root',
    'perm', '0644',
);

This is useful for files where you do not have control over the origin, in particular files that are frequently regenerated automatically.

If the files do not change frequently and/or have other dependencies you should consider building real packages to ship the files.

If you find yourself using this heavily you should definitely consider mirroring the files on a local server or at least using a caching proxy.

Copy and run a script

This assumes that there is a script foo.sh present:

include 'components/filecopy/config';

prefix '/software/components/filecopy/services{/root/foo.sh}';
'config' = file_contents('bar/foo.sh');
'owner' = 'root:root';
'perms' = '0644';
'restart' = '/root/foo.sh';
include 'components/symlink/config';

'/software/components/symlink/links' ?= list();

'/software/components/symlink/links' = merge(SELF, list(
    dict(
        'name', '/opt/foo',
        'target', '/home/alex/bar',
        'exists', true,
    ),
));

Services

Configure a service to start

include 'components/chkconfig/config';

prefix '/software/components/chkconfig/service/rsyslog';
'on' = '';
'startstop' = true;

User Creation and User Groups

Add a user group

include 'components/accounts/config';

'/software/components/accounts/groups/syrinx/gid' = 2112;

Add a user account

include 'components/accounts/config';

'/software/components/accounts/users/alex' = dict(
    'uid', 760401,
    'groups', list('syrinx'),
    'comment', 'Everything is awesome',
    'homeDir', '/home/alex',
    'shell', '/bin/bash',
);