Skip to content

Commit 54d8760

Browse files
committed
Added docs for the state-level aggregate keyword
Also added clarification on the two ways to invoke the aggregation function.
1 parent aa964e5 commit 54d8760

File tree

1 file changed

+40
-13
lines changed

1 file changed

+40
-13
lines changed

doc/ref/states/aggregate.rst

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,71 @@ all, it makes Salt much more dynamic.
1313
How it Works
1414
============
1515

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
1717
been adding the ability to install all packages defined at the same time. The
1818
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
2121
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.
2424

2525
How to Use it
2626
=============
2727

28-
2928
.. note::
3029

3130
Since this option changes the basic behavior of the state runtime, after
3231
it is enabled states should be executed using `test=True` to ensure that
3332
the desired behavior is preserved.
3433

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

38-
To enable for all states just add:
44+
Enable for all states:
3945

4046
.. code-block:: yaml
4147
4248
state_aggregate: True
4349
44-
Similarly only specific states can be enabled:
50+
Enable for only specific state modules:
4551

4652
.. code-block:: yaml
4753
4854
state_aggregate:
4955
- pkg
5056
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
5481
5582
Adding mod_aggregate to a State Module
5683
======================================

0 commit comments

Comments
 (0)