golden hour
/opt/saltstack/salt/lib/python3.10/site-packages/salt/pillar
⬆️ Go Up
Upload
File/Folder
Size
Actions
__init__.py
50.98 KB
Del
OK
__pycache__
-
Del
OK
azureblob.py
13.88 KB
Del
OK
cmd_json.py
787 B
Del
OK
cmd_yaml.py
893 B
Del
OK
cmd_yamlex.py
674 B
Del
OK
cobbler.py
1.64 KB
Del
OK
confidant.py
3.29 KB
Del
OK
consul_pillar.py
11.61 KB
Del
OK
csvpillar.py
1.85 KB
Del
OK
digicert.py
1007 B
Del
OK
django_orm.py
7.74 KB
Del
OK
ec2_pillar.py
10.08 KB
Del
OK
etcd_pillar.py
4.04 KB
Del
OK
extra_minion_data_in_pillar.py
2.18 KB
Del
OK
file_tree.py
18.03 KB
Del
OK
foreman.py
3.66 KB
Del
OK
git_pillar.py
19.61 KB
Del
OK
gpg.py
560 B
Del
OK
hg_pillar.py
3.2 KB
Del
OK
hiera.py
846 B
Del
OK
http_json.py
3.37 KB
Del
OK
http_yaml.py
3.08 KB
Del
OK
libvirt.py
5.78 KB
Del
OK
makostack.py
21.99 KB
Del
OK
mongo.py
6.05 KB
Del
OK
mysql.py
3.76 KB
Del
OK
nacl.py
744 B
Del
OK
netbox.py
36.22 KB
Del
OK
neutron.py
2.41 KB
Del
OK
nodegroups.py
1.7 KB
Del
OK
pepa.py
20.99 KB
Del
OK
pillar_ldap.py
10.82 KB
Del
OK
postgres.py
2.82 KB
Del
OK
puppet.py
846 B
Del
OK
reclass_adapter.py
4 KB
Del
OK
redismod.py
3.28 KB
Del
OK
rethinkdb_pillar.py
4.71 KB
Del
OK
s3.py
14.4 KB
Del
OK
saltclass.py
1.49 KB
Del
OK
sql_base.py
16.51 KB
Del
OK
sqlcipher.py
3.42 KB
Del
OK
sqlite3.py
2.67 KB
Del
OK
stack.py
22.92 KB
Del
OK
svn_pillar.py
5.74 KB
Del
OK
varstack_pillar.py
1.1 KB
Del
OK
vault.py
6.54 KB
Del
OK
venafi.py
966 B
Del
OK
virtkey.py
586 B
Del
OK
vmware_pillar.py
16.83 KB
Del
OK
Edit: hg_pillar.py
# Copyright (C) 2014 Floris Bruynooghe <flub@devork.be> r""" Use remote Mercurial repository as a Pillar source. .. versionadded:: 2015.8.0 The module depends on the ``hglib`` python module being available. This is the same requirement as for hgfs\_ so should not pose any extra hurdles. This external Pillar source can be configured in the master config file as such: .. code-block:: yaml ext_pillar: - hg: ssh://hg@example.co/user/repo """ import copy import hashlib import logging import os import salt.pillar import salt.utils.stringutils from salt.config import DEFAULT_HASH_TYPE try: import hglib except ImportError: hglib = None log = logging.getLogger(__name__) __virtualname__ = "hg" def __virtual__(): """ Only load if hglib is available. """ ext_pillar_sources = [x for x in __opts__.get("ext_pillar", [])] if not any(["hg" in x for x in ext_pillar_sources]): return False if not hglib: log.error("hglib not present") return False return __virtualname__ def __init__(__opts__): """ Initialise This is called every time a minion calls this external pillar. """ def ext_pillar(minion_id, pillar, repo, branch="default", root=None): """ Extract pillar from an hg repository """ with Repo(repo) as repo: repo.update(branch) envname = "base" if branch == "default" else branch if root: path = os.path.normpath(os.path.join(repo.working_dir, root)) else: path = repo.working_dir opts = copy.deepcopy(__opts__) opts["pillar_roots"][envname] = [path] pil = salt.pillar.Pillar(opts, __grains__, minion_id, envname) return pil.compile_pillar(ext=False) def update(repo_uri): """ Execute an hg pull on all the repos """ with Repo(repo_uri) as repo: repo.pull() class Repo: """ Deal with remote hg (mercurial) repository for Pillar """ def __init__(self, repo_uri): """Initialize a hg repo (or open it if it already exists)""" self.repo_uri = repo_uri cachedir = os.path.join(__opts__["cachedir"], "hg_pillar") hash_type = getattr(hashlib, __opts__.get("hash_type", DEFAULT_HASH_TYPE)) repo_hash = hash_type(salt.utils.stringutils.to_bytes(repo_uri)).hexdigest() self.working_dir = os.path.join(cachedir, repo_hash) if not os.path.isdir(self.working_dir): self.repo = hglib.clone(repo_uri, self.working_dir) self.repo.open() else: self.repo = hglib.open(self.working_dir) def pull(self): log.debug("Updating hg repo from hg_pillar module (pull)") self.repo.pull() def update(self, branch="default"): """ Ensure we are using the latest revision in the hg repository """ log.debug("Updating hg repo from hg_pillar module (pull)") self.repo.pull() log.debug("Updating hg repo from hg_pillar module (update)") self.repo.update(branch, clean=True) def close(self): """ Cleanup mercurial command server """ self.repo.close() def __enter__(self): return self def __exit__(self, exc_type, exc_value, traceback): self.close()
Save