summaryrefslogtreecommitdiffstats
path: root/doc/client/tools/actions.txt
blob: 81486ecd19c5d9da4a278362e40e258a3a93fafd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
.. -*- mode: rst -*-

.. _client-tools-actions:

=======
Actions
=======

This page describes use of the Action configuration entry. Action entries
are commands that are executed either before bundle installation,
after bundle installation or both. If exit status is observed, a
failing pre-action will cause no modification of the enclosing bundle
to be performed; all entries in included in that bundle will not be
modified. Failing actions are reported through Bcfg2's reporting system,
so they can be centrally observed. Actions look like:

.. code-block:: xml

    <Action timing='pre|post|both'
            name='name'
            command='cmd text'
            when='always|modified'
            status='ignore|check'
            build='true|false'/>

.. xml:type:: ActionType

Note that the status attribute tells the bcfg2 client to ignore
return status, causing failures to still not be centrally reported. If
central reporting of action failure is desired, set this attribute to
'check'. Also note that Action entries included in Base will not be
executed.

Actions cannot be completely defined inside of a bundle; they are a bound
entry, much like Packages, Services or Paths. The Rules plugin can bind
these entries. For example to include the above action in a bundle,
first the Action entry must be included in the bundle:

.. code-block:: xml

    <Bundle name='bundle_name'>
      ...
      <Action name='action_name'/>
    </Bundle>

Then a corresponding entry must be included in the Rules directory, like:

.. code-block:: xml

    <Rules priority='0'>
      <Action timing='post' when='modified' name='action_name'
              command='/path/to/command arg1 arg2' status='ignore'/>
    </Rules>

This allows different clients to get different actions as a part of the
same bundle based on group membership.

Example Action (add APT keys)
=============================

This example will add the '0C5A2783' for aptitude. It is useful to run
this during the client bootstrap process so that the proper keys are
installed prior to the bcfg2 client trying to install a package which
requires this key.

.. code-block:: xml

    <Rules priority='0'>
      <Group name='ubuntu'>
        <Action timing='post' name='apt-key-update' command='apt-key adv --recv-keys --keyserver hkp://pgp.mit.edu 0C5A2783' when='modified' status='check'/>
      </Group>
    </Rules>