File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/loop.cpython-310.pyc
o
�N�g� � @ s^ d Z ddlZddlZddlZddlZe�e�ZdZdd� Z d
dd �Z
ddd�ZdS )a|
Loop state
Allows for looping over execution modules.
.. versionadded:: 2017.7.0
In both examples below, the execution module function ``boto_elb.get_instance_health``
returns a list of dicts. The condition checks the ``state``-key of the first dict
in the returned list and compares its value to the string `InService`.
.. code-block:: yaml
wait_for_service_to_be_healthy:
loop.until:
- name: boto_elb.get_instance_health
- condition: m_ret[0]['state'] == 'InService'
- period: 5
- timeout: 20
- m_args:
- {{ elb }}
- m_kwargs:
keyid: {{ access_key }}
key: {{ secret_key }}
instances: "{{ instance }}"
.. warning::
This state allows arbitrary python code to be executed through the condition
parameter which is literally evaluated within the state. Please use caution.
.. versionchanged:: 3000
A version that does not use eval is now available. It uses either the python ``operator``
to compare the result of the function called in ``name``, which can be one of the
following: lt, le, eq (default), ne, ge, gt.
Alternatively, `compare_operator` can be filled with a function from an execution
module in ``__salt__`` or ``__utils__`` like the example below.
The function :py:func:`data.subdict_match <salt.utils.data.subdict_match>` checks if the
``expected`` expression matches the data returned by calling the ``name`` function
(with passed ``args`` and ``kwargs``).
.. code-block:: yaml
Wait for service to be healthy:
loop.until_no_eval:
- name: boto_elb.get_instance_health
- expected: '0:state:InService'
- compare_operator: data.subdict_match
- period: 5
- timeout: 20
- args:
- {{ elb }}
- kwargs:
keyid: {{ access_key }}
key: {{ secret_key }}
instances: "{{ instance }}"
� NZloopc C s dS )NT� r r r �D/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/loop.py�__virtual__H s r � �<