Created
March 2, 2012 07:27
-
-
Save sirkonst/1956489 to your computer and use it in GitHub Desktop.
State of states module for salt (saltstack)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
State module | |
============ | |
The state module for logical union of several states. | |
Available Functions | |
------------------- | |
The module only has a single function, the ``present`` function | |
present | |
Combining multiple states in one | |
example: | |
.. code-block:: yaml | |
# some service configs in one state | |
some_config: | |
state: | |
- present | |
- watch: # or require declaration | |
- file: /etc/some_service/conf_1.conf | |
- file: /etc/some_service/conf_2.conf | |
- file: /etc/some_service/conf_3. | |
- host: myhost.local # you can include different state | |
some_service: | |
service: | |
- running | |
# if will changed some of some_config watchers OR tag | |
# service will be restarted | |
- watch: | |
- state: some_config | |
another_service: | |
service: | |
- running | |
# Service check running if all watch (or require) state in | |
# some_config and state file: /etc/another_service/conf.conf | |
# is true | |
- require: | |
- state: some_config | |
- file: /etc/another_service/conf.conf | |
# union two state service as one state | |
services_running: | |
state: | |
- present | |
- require: | |
- service: some_service | |
- service: another_service | |
# command running if one of service will restarted | |
do_some_think: | |
cmd: | |
- wait | |
- watch: | |
- state: services_running | |
""" | |
def present(name): | |
""" | |
State | |
:param name: state name | |
""" | |
return {'name': name, | |
'result': True, | |
'changes': {}, | |
'comment': 'State present'} | |
# ---------------------------------------------------------------------------- | |
def watcher(name, tag=None): | |
res = present(name, tag) | |
res['changes'].update({'state': 'Watch requires changed'}) | |
return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment