Module Expr Str ImportFrom alias Import alias Import alias Import alias ImportFrom alias ImportFrom alias identifier TryExcept body Import alias Assign NameStore NameLoad handlers ExceptHandler type NameLoad body Assign NameStore NameLoad Assign NameStore Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad FunctionDef arguments args defaults body Expr Str Return IfExp NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore NameLoad If SubscriptLoad NameLoad Index Num body Assign NameStore SubscriptLoad NameLoad Index Num Assign NameStore Call NameLoad NameLoad NameLoad Assign NameStore Str If BoolOpAnd CompareGt Call NameLoad NameLoad Num Call AttributeLoad SubscriptLoad NameLoad Index Num attr Str body Assign NameStore Call AttributeLoad SubscriptLoad NameLoad Index Num attr Str Str Assign NameStore Call SubscriptLoad NameLoad Index Str Str AugAssignMod NameStore Dict Str Str NameLoad NameLoad TryExcept body Assign NameStore Call NameLoad NameLoad NameLoad handlers ExceptHandler type NameLoad body Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr NameLoad NameLoad Assign NameStore Dict Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad Assign NameStore Dict Assign NameStore Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Str Call NameLoad NameLoad If CompareIs NameLoad NameLoad body Return NameLoad For NameStore Call NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd Str NameLoad Str Str SubscriptLoad NameLoad Index Str If CompareNotEq NameLoad Str body Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Str Call NameLoad Call AttributeLoad NameLoad attr NameLoad If CompareIs Call AttributeLoad NameLoad attr NameLoad NameLoad body Assign NameStore Call NameLoad NameLoad Call AttributeLoad NameLoad attr Str SubscriptLoad NameLoad Index Str Expr Call AttributeLoad NameLoad attr Str Call NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str If CompareIs NameLoad NameLoad body Return NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Dict NameLoad NameLoad Expr Call AttributeLoad NameLoad attr For NameStore NameLoad body Assign NameStore Dict NameLoad NameLoad Return Call NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Str Dict Assign NameStore Call AttributeLoad NameLoad attr Str Dict Assign NameStore Dict Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad If NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Dict orelse Assign NameStore NameLoad Assign NameStore Dict For NameStore TupleLoad Str Str Str Str Str Str Str body Assign NameStore Call AttributeLoad Str attr keyword NameLoad If CompareIn NameLoad NameLoad body Assign SubscriptStore NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad If CompareIn Str NameLoad body Assign NameStore BoolOpOr Call AttributeLoad NameLoad attr Str Str Assign SubscriptStore NameLoad Index Str Call NameLoad SubscriptLoad NameLoad Index Str NameLoad If NameLoad body Return Call AttributeLoad NameLoad attr NameLoad orelse Raise Call NameLoad Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr keyword NameLoad TryExcept body Assign NameStore Call AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr keyword NameLoad Return NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr keyword Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr keyword NameLoad Assign NameStore Call NameLoad NameLoad keyword Lambda arguments args NameParam defaults TupleLoad UnaryOpUSub Call NameLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num For TupleStore NameStore NameStore NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr keyword NameLoad Return NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr keyword NameLoad keyword Call AttributeLoad Str attr GeneratorExp Call NameLoad NameLoad comprehension NameStore NameLoad decorator_list
N/A N/A 
Use Consul K/V as a Pillar source with values parsed as YAML

:depends:  - python-consul

In order to use an consul server, a profile must be created in the master
configuration file:

.. code-block:: yaml

    my_consul_config:
      consul.host: 127.0.0.1
      consul.port: 8500
      consul.token: b6376760-a8bb-edd5-fcda-33bc13bfc556
      consul.scheme: http
      consul.consistency: default
      consul.dc: dev
      consul.verify: True

All parameters are optional.

If you have a multi-datacenter Consul cluster you can map your ``pillarenv``s
to your data centers by providing a dictionary of mappings in ``consul.dc``
field:

.. code-block:: yaml

    my_consul_config:
      consul.dc:
        dev: us-east-1
        prod: us-west-1

In the example above we specifying static mapping between Pillar environments
and data centers: the data for ``dev`` and ``prod`` Pillar environments will
be fetched from ``us-east-1`` and ``us-west-1`` datacenter respectively.

In fact when ``consul.dc`` is set to dictionary keys are processed as regular
expressions (that can capture named parameters) and values are processed as
string templates as per PEP 3101.

.. code-block:: yaml

    my_consul_config:
      consul.dc:
        ^dev-.*$: dev-datacenter
        ^(?P<region>.*)-prod$: prod-datacenter-{region}

This example maps all Pillar environments starting with ``dev-`` to
``dev-datacenter`` whereas Pillar environment like ``eu-prod`` will be
mapped to ``prod-datacenter-eu``.

Before evaluation patterns are sorted by length in descending order.

If Pillar environment names correspond to data center names a single pattern
can be used:

.. code-block:: yaml

    my_consul_config:
      consul.dc:
        ^(?P<env>.*)$: '{env}'

After the profile is created, configure the external pillar system to use it.
Optionally, a root may be specified.

.. code-block:: yaml

    ext_pillar:
      - consul: my_consul_config

    ext_pillar:
      - consul: my_consul_config root=/salt

Using these configuration profiles, multiple consul sources may also be used:

.. code-block:: yaml

    ext_pillar:
      - consul: my_consul_config
      - consul: my_other_consul_config

Either the ``minion_id``, or the ``role`` grain  may be used in the ``root``
path to expose minion-specific information stored in consul.

.. code-block:: yaml

    ext_pillar:
      - consul: my_consul_config root=/salt/%(minion_id)s
      - consul: my_consul_config root=/salt/%(role)s

Minion-specific values may override shared values when the minion-specific root
appears after the shared root:

.. code-block:: yaml

    ext_pillar:
      - consul: my_consul_config root=/salt-shared
      - consul: my_other_consul_config root=/salt-private/%(minion_id)s

If using the ``role`` grain in the consul key path, be sure to define it using
`/etc/salt/grains`, or similar:

.. code-block:: yaml

    role: my-minion-role

 __future__ absolute_import N/A logging N/A re N/A yaml salt.exceptions CommandExecutionError salt.utils.dictupdate update dict_merge N/A N/A N/A consul N/A HAS_CONSUL True N/A N/A N/A ImportError N/A N/A HAS_CONSUL False N/A __virtualname__ consul N/A log N/A N/A logging getLogger __name__ __virtual__ N/A N/A N/A N/A N/A 
    Only return if python-consul is installed
     N/A N/A HAS_CONSUL __virtualname__ False N/A ext_pillar N/A N/A minion_id pillar conf N/A N/A N/A 
    Check consul for all data
     N/A comps N/A N/A conf split N/A profile None N/A N/A comps N/A 0 N/A N/A profile N/A comps N/A 0 N/A client N/A get_conn __opts__ profile N/A path N/A N/A N/A N/A len comps 1 N/A N/A N/A comps N/A 1 startswith root= N/A N/A path N/A N/A N/A comps N/A 1 replace root= N/A role N/A N/A __salt__ N/A grains.get role N/A path N/A minion_id role minion_id role N/A N/A N/A pillar N/A fetch_tree client path N/A N/A N/A KeyError N/A N/A N/A N/A log error N/A N/A No such key in consul profile {0}: {1} format profile path N/A pillar N/A N/A pillar N/A consul_fetch N/A N/A client path N/A N/A N/A 
    Query consul for all keys/values within base path
     N/A N/A N/A N/A client kv get path recurse True N/A fetch_tree N/A N/A client path N/A N/A N/A 
    Grab data from consul, trim base path and remove any keys which
    are folders. Take the remaining data and send it to be formatted
    in such a way as to be used as pillar data.
     N/A N/A index items N/A consul_fetch client path N/A ret N/A N/A has_children N/A N/A re compile /$ N/A N/A N/A log debug Fetched items: %r N/A format items N/A N/A items None N/A N/A ret N/A item N/A reversed items N/A N/A key N/A N/A re sub N/A N/A ^ path /? N/A item N/A Key N/A N/A key N/A N/A N/A N/A log debug N/A N/A key/path - {0}: {1} format path key N/A N/A N/A log debug has_children? %r N/A format N/A N/A has_children search key N/A N/A N/A N/A has_children search key None N/A N/A ret N/A pillar_format ret N/A N/A key split / N/A item N/A Value N/A N/A N/A log debug Fetching subkeys for key: %r N/A format item N/A ret N/A pillar_format N/A N/A ret keys value N/A N/A N/A 
    Perform data formatting to be used as pillar data and
    merge it with the current pillar data
     N/A N/A value None N/A N/A ret N/A pillar_value N/A N/A yaml load value N/A keyvalue N/A N/A keys pop N/A pil N/A keyvalue pillar_value N/A N/A N/A keys reverse N/A k keys N/A N/A pil N/A k pil N/A N/A dict_merge ret pil N/A get_conn N/A N/A opts profile N/A N/A N/A 
    Return a client object for accessing consul
     N/A opts_pillar N/A N/A opts get pillar N/A N/A opts_master N/A N/A opts_pillar get master N/A N/A opts_merged N/A N/A N/A N/A opts_merged update opts_master N/A N/A N/A opts_merged update opts_pillar N/A N/A N/A opts_merged update opts N/A profile N/A N/A conf N/A N/A opts_merged get profile N/A N/A N/A conf opts_merged N/A params N/A N/A key N/A host port token scheme consistency dc verify N/A N/A prefixed_key N/A N/A consul.{key} format key key N/A N/A prefixed_key conf N/A N/A N/A params N/A key N/A conf N/A prefixed_key N/A N/A dc params N/A N/A pillarenv N/A N/A N/A opts_merged get pillarenv base N/A N/A params N/A dc N/A _resolve_datacenter N/A params N/A dc pillarenv N/A HAS_CONSUL N/A N/A N/A N/A consul Consul params N/A N/A N/A CommandExecutionError (unable to import consul, module most likely not installed. Download python-consul module and be sure to import consul) N/A _resolve_datacenter N/A N/A dc pillarenv N/A N/A N/A 
    If ``dc`` is a string - return it as is.

    If it's a dict then sort it in descending order by key length and try
    to use keys as RegEx patterns to match against ``pillarenv``.
    The value for matched pattern should be a string (that can use
    ``str.format`` syntax togetehr with captured variables from pattern)
    pointing to targe data center to use.

    If none patterns matched return ``None`` which meanse us datacenter of
    conencted Consul agent.
     N/A N/A N/A log debug N/A N/A Resolving Consul datacenter based on: {dc} format dc dc N/A N/A N/A mappings N/A N/A dc items N/A N/A N/A AttributeError N/A N/A N/A N/A log debug N/A N/A Using pre-defined DC: {dc!r} format dc dc N/A dc N/A N/A N/A log debug N/A N/A Selecting DC based on pillarenv using {num} pattern(s) format num N/A len mappings N/A N/A N/A log debug N/A N/A Pillarenv set to {env!r} format env pillarenv N/A sorted_mappings N/A sorted mappings key N/A N/A N/A m N/A N/A N/A N/A len N/A m N/A 0 N/A m N/A 0 N/A N/A pattern target sorted_mappings N/A N/A match N/A N/A re match pattern pillarenv N/A match N/A N/A N/A N/A log debug N/A N/A Matched pattern: {pattern!r} format pattern pattern N/A result N/A N/A target format N/A N/A match groupdict N/A N/A N/A log debug N/A N/A Resolved datacenter: {result!r} format result result N/A result N/A N/A N/A log debug N/A N/A None of following patterns matched pillarenv={env}: {lst} format env pillarenv lst N/A N/A ,  join N/A N/A repr x N/A x mappings N/A