This commit is contained in:
parent
a179470603
commit
990a67664a
50
states/_modules/paulbsdclass.py
Normal file
50
states/_modules/paulbsdclass.py
Normal file
@ -0,0 +1,50 @@
|
||||
"""
|
||||
SaltClass Pillar Module
|
||||
=======================
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
ext_pillar:
|
||||
- saltclass:
|
||||
- path: /srv/saltclass
|
||||
|
||||
For additional configuration instructions, see the :mod:`saltclass <salt.tops.saltclass>` module
|
||||
"""
|
||||
|
||||
|
||||
import logging
|
||||
|
||||
import salt.utils.saltclass as sc
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
This module has no external dependencies
|
||||
"""
|
||||
return True
|
||||
|
||||
|
||||
def ext_pillar(minion_id, pillar, *args, **kwargs):
|
||||
"""
|
||||
Compile pillar data
|
||||
"""
|
||||
for i in args:
|
||||
if "path" not in i:
|
||||
path = "/srv/saltclass"
|
||||
args[i]["path"] = path
|
||||
log.warning("path variable unset, using default: %s", path)
|
||||
else:
|
||||
path = i["path"]
|
||||
|
||||
salt_data = {
|
||||
"__opts__": __opts__,
|
||||
"__salt__": __salt__,
|
||||
"__grains__": __grains__,
|
||||
"__pillar__": pillar,
|
||||
"minion_id": minion_id,
|
||||
"path": path,
|
||||
}
|
||||
|
||||
return sc.get_pillars(minion_id, salt_data)
|
44
states/_tops/paulbsdclass.py
Normal file
44
states/_tops/paulbsdclass.py
Normal file
@ -0,0 +1,44 @@
|
||||
import logging
|
||||
|
||||
import salt.loader
|
||||
import salt.utils.saltclass as sc
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
Only run if properly configured
|
||||
"""
|
||||
if __opts__["master_tops"].get("paulbsdclass"):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def top(**kwargs):
|
||||
"""
|
||||
Compile tops
|
||||
"""
|
||||
_opts = __opts__["master_tops"]["paulbsdclass"]
|
||||
if "path" not in _opts:
|
||||
path = "/srv/saltclass"
|
||||
log.warning("path variable unset, using default: %s", path)
|
||||
else:
|
||||
path = _opts["path"]
|
||||
|
||||
if "id" not in kwargs["opts"]:
|
||||
log.warning("Minion id not found - Returning empty dict")
|
||||
return {}
|
||||
else:
|
||||
minion_id = kwargs["opts"]["id"]
|
||||
|
||||
salt_data = {
|
||||
"__opts__": kwargs["opts"],
|
||||
"__salt__": salt.loader.minion_mods(__opts__,whitelist=["saltutil", "mine", "grains"]),
|
||||
"__grains__": kwargs["grains"],
|
||||
"__pillar__": {},
|
||||
"minion_id": minion_id,
|
||||
"path": path,
|
||||
}
|
||||
|
||||
return sc.get_tops(minion_id, salt_data)
|
Loading…
Reference in New Issue
Block a user