@@ -13,44 +13,71 @@ all, it makes Salt much more dynamic.
13
13
How it Works
14
14
============
15
15
16
- The best example is the `pkg ` state. One of the major requests in Salt has long
16
+ The best example is the `` pkg ` ` state. One of the major requests in Salt has long
17
17
been adding the ability to install all packages defined at the same time. The
18
18
mod_aggregate system makes this a reality. While executing Salt's state system,
19
- when a `pkg ` state is reached the ``mod_aggregate `` function in the state module
20
- is called. For `pkg ` this function scans all of the other states that are slated
19
+ when a `` pkg ` ` state is reached the ``mod_aggregate `` function in the state module
20
+ is called. For `` pkg ` ` this function scans all of the other states that are slated
21
21
to run, and picks up the references to ``name `` and ``pkgs ``, then adds them to
22
- ``pkgs `` in the first state. The result is calling yum/ apt-get/pacman etc. just
23
- once to install of the packages as part of the first package install.
22
+ ``pkgs `` in the first state. The result is a single call to yum, apt-get,
23
+ pacman, etc as part of the first package install.
24
24
25
25
How to Use it
26
26
=============
27
27
28
-
29
28
.. note ::
30
29
31
30
Since this option changes the basic behavior of the state runtime, after
32
31
it is enabled states should be executed using `test=True ` to ensure that
33
32
the desired behavior is preserved.
34
33
35
- Since this behavior can dramatically change the flow of configuration
36
- management inside of Salt it is disabled by default. But enabling it is easy.
34
+ In config files
35
+ ---------------
36
+
37
+ The first way to enable aggregation is with a configuration option in either
38
+ the master or minion configuration files. Salt will invoke ``mod_aggregate ``
39
+ the first time it encounters a state module that has aggregate support.
40
+
41
+ If this option is set in the master config it will apply to all state runs on
42
+ all minions, if set in the minion config it will only apply to said minion.
37
43
38
- To enable for all states just add :
44
+ Enable for all states:
39
45
40
46
.. code-block :: yaml
41
47
42
48
state_aggregate : True
43
49
44
- Similarly only specific states can be enabled :
50
+ Enable for only specific state modules :
45
51
46
52
.. code-block :: yaml
47
53
48
54
state_aggregate :
49
55
- pkg
50
56
51
- To the master or minion config and restart the master or minion, if this option
52
- is set in the master config it will apply to all state runs on all minions, if
53
- set in the minion config it will only apply to said minion.
57
+ In states
58
+ ---------
59
+
60
+ The second way to enable aggregation is with the state-level ``aggregate ``
61
+ keyword. In this configuration, Salt will invoke the ``mod_aggregate `` function
62
+ the first time it encounters this keyword. Any additional occurances of the
63
+ keyword will be ignored as the aggregation has already taken place.
64
+
65
+ The following example will trigger ``mod_aggregate `` when the ``lamp_stack ``
66
+ state is processed resulting in a single call to the underlying package
67
+ manager.
68
+
69
+ .. code-block :: yaml
70
+
71
+ lamp_stack :
72
+ pkg.installed :
73
+ - pkgs :
74
+ - php
75
+ - mysql-client
76
+ - aggregate : True
77
+
78
+ memcached :
79
+ pkg.installed :
80
+ - name : memcached
54
81
55
82
Adding mod_aggregate to a State Module
56
83
======================================
0 commit comments