%PDF- %PDF-
| Direktori : /proc/self/root/proc/self/root/usr/lib/python2.7/site-packages/salt/states/ |
| Current File : //proc/self/root/proc/self/root/usr/lib/python2.7/site-packages/salt/states/grains.pyc |
�
���^c @@ s� d Z d d l m Z m Z m Z d d l Z d d l m Z e d � Z e e d � Z
e d � Z e d � Z e e e d � Z
e e d
� Z d S( uG
Manage grains on the minion
===========================
This state allows for grains to be set.
Grains set or altered with this module are stored in the 'grains'
file on the minions, By default, this file is located at: ``/etc/salt/grains``
.. note::
This does **NOT** override any grains set in the minion config file.
i ( t absolute_importt print_functiont unicode_literalsN( t DEFAULT_TARGET_DELIMc C@ sz t j | t | � } i | d 6i d 6t d 6d d 6} t � } t d | | � } | | k rv t | d <d | d <n | S( u�
Ensure that a grain is set
name
The grain name
delimiter
A delimiter different from the default can be provided.
Check whether a grain exists. Does not attempt to check or set the value.
u nameu changesu resultu Grain existsu commentu
grains.getu Grain does not exist( t ret subR t Truet objectt __salt__t False( t namet delimitert rett
_non_existentt existing( ( s6 /usr/lib/python2.7/site-packages/salt/states/grains.pyt exists s
c C@ sC t j | t | � } i | d 6i d 6t d 6d d 6} t � } t d | | � } | | k rm d | d <| St d r� d | d <| | k r� d j | � | d <i | d
6| d <n+ d j | � | d <i i | | 6d 6| d <| St d
| | d | �} | d t k r5| d i k r5d j | | � | d <n | | d <| S( u�
Ensure that a grain is set
.. versionchanged:: v2015.8.2
name
The grain name
value
The value to set on the grain
force
If force is True, the existing grain will be overwritten
regardless of its existing or provided value type. Defaults to False
.. versionadded:: v2015.8.2
delimiter
A delimiter different from the default can be provided.
.. versionadded:: v2015.8.2
It is now capable to set a grain to a complex value (ie. lists and dicts)
and supports nested grains as well.
If the grain does not yet exist, a new grain is set to the given value. For
a nested grain, the necessary keys are created if they don't exist. If
a given key is an existing value, it will be converted, but an existing value
different from the given key will fail the state.
If the grain with the given name exists, its value is updated to the new
value unless its existing or provided value is complex (list or dict). Use
`force: True` to overwrite.
.. code-block:: yaml
cheese:
grains.present:
- value: edam
nested_grain_with_complex_value:
grains.present:
- name: icinga:Apache SSL
- value:
- command: check_https
- params: -H localhost -p 443 -S
with,a,custom,delimiter:
grains.present:
- value: yay
- delimiter: ','
u nameu changesu resultu u commentu
grains.getu Grain is already setu testu Grain {0} is set to be addedu newu Grain {0} is set to be changedu changedu
grains.sett forceu Set grain {0} to {1}N( R R R R R R t __opts__t Nonet format( R
t valueR R R R
R ( ( s6 /usr/lib/python2.7/site-packages/salt/states/grains.pyt present0 s. 5
c C@ s t j | t | � } i | d 6i d 6t d 6d d 6} t d | � } | r
t | t � s} t | d <d j | � | d <| St | t � r�t | � j
t t d | � � � r� d j | | � | d <| S| t j d i � k rMt | � j
t j d i � | � } | rMt t | � j t d | � � } d
j | | � | d <qMn d t k rfi t d <n | t d k r�t � t d | <n t d | j | � n&