403Webshell
Server IP : 198.38.94.13  /  Your IP : 216.73.217.33
Web Server : Apache
System : Linux d4744.dxb1.stableserver.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : revivere ( 1140)
PHP Version : 8.2.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/saltstack/salt/lib/python3.10/site-packages/salt/sdb/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/saltstack/salt/lib/python3.10/site-packages/salt/sdb/env.py
"""
Environment sdb Module

:maintainer:    SaltStack
:maturity:      New
:depends:       None
:platform:      all

This module allows access to environment variables using an ``sdb://`` URI.

Example configuration for this module:

.. code-block:: yaml

    osenv:
      driver: env

WARNING:
--------
OS environment variables will be available
to read via SDB.
Please make sure you don't have any sensitive data
in your environment variables!!

Example usage of sdb env module:

.. code-block:: jinja

    set some env var:
      cmd.run:
        - name: echo {{ salt['sdb.set']('sdb://osenv/foo', 'bar') }}
        - order: 1

    {% if salt['sdb.get']('sdb://osenv/foo') == 'bar' %}
    always-changes-and-succeeds:
      test.succeed_with_changes:
        - name: foo
    {% else %}
    always-changes-and-fails:
      test.fail_with_changes:
        - name: foo
    {% endif  %}

The above example will return success.

The ``env`` sdb module can also be used with salt cloud.
Assuming you have exported the environment variable named
``compute`` (and have ``osenv`` defined).
The example below will look for the salt cloud config key ``compute_name``
in the environment:

.. code-block:: yaml

  my-openstack-config:
    compute_name: sdb://osenv/compute
    ..snip

"""

import os

__func_alias__ = {"set_": "set"}


def __virtual__():
    """
    Always load
    """
    return True


def set_(key, value, profile=None):
    """
    Set a key/value pair
    """
    # pylint: disable=unused-argument
    return os.environ.setdefault(key, value)


def get(key, profile=None):
    """
    Get a value
    """
    # pylint: disable=unused-argument
    return os.environ.get(key)

Youez - 2016 - github.com/yon3zu
LinuXploit