Skip to content

Commit 8a7134e

Browse files
committed
Merge pull request saltstack#18672 from whiteinge/mod_aggregate-state-level
Add docs for mod_aggregate state-level keywords
2 parents 64bab7c + 54d8760 commit 8a7134e

File tree

3 files changed

+56
-13
lines changed

3 files changed

+56
-13
lines changed

conf/master

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,14 @@
327327
# If set to 'changes', the output will be full unless the state didn't change.
328328
#state_output: full
329329

330+
# Automatically aggregate all states that have support for mod_aggregate by
331+
# setting to True. Or pass a list of state module names to automatically
332+
# aggregate just those types.
333+
#
334+
# state_aggregate:
335+
# - pkg
336+
#
337+
#state_aggregate: False
330338

331339
##### File Server settings #####
332340
##########################################

conf/minion

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,14 @@
368368
# Top file to execute if startup_states is 'top':
369369
#top_file: ''
370370

371+
# Automatically aggregate all states that have support for mod_aggregate by
372+
# setting to True. Or pass a list of state module names to automatically
373+
# aggregate just those types.
374+
#
375+
# state_aggregate:
376+
# - pkg
377+
#
378+
#state_aggregate: False
371379

372380
##### File Directory Settings #####
373381
##########################################

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)