%PDF- %PDF-
| Direktori : /proc/self/root/proc/3522530/root/usr/lib/python2.7/site-packages/salt/pillar/ |
| Current File : //proc/self/root/proc/3522530/root/usr/lib/python2.7/site-packages/salt/pillar/ec2_pillar.pyc |
�
���^c @@ s
d Z d d l m Z m Z m Z d d l Z d d l Z d d l j j Z d d l
m Z d d l m
Z y. d d l Z d d l Z d d l Z e Z Wn e k
r� e Z n Xe j e � Z e j d � j e j � d � Z d � Z e d d d d d
d � Z d S( un
Retrieve EC2 instance data for minions for ec2_tags and ec2_tags_list
The minion id must be the AWS instance-id or value in ``tag_match_key``. For
example set ``tag_match_key`` to ``Name`` to have the minion-id matched against
the tag 'Name'. The tag contents must be unique. The value of
``tag_match_value`` can be 'uqdn' or 'asis'. if 'uqdn', then the domain will be
stripped before comparison.
Additionally, the ``use_grain`` option can be set to ``True``. This allows the
use of an instance-id grain instead of the minion-id. Since this is a potential
security risk, the configuration can be further expanded to include a list of
minions that are trusted to only allow the alternate id of the instances to
specific hosts. There is no glob matching at this time.
.. note::
If you are using ``use_grain: True`` in the configuration for this external
pillar module, the minion must have :conf_minion:`metadata_server_grains`
enabled in the minion config file (see also :py:mod:`here
<salt.grains.metadata>`).
It is important to also note that enabling the ``use_grain`` option allows
the minion to manipulate the pillar data returned, as described above.
The optional ``tag_list_key`` indicates which keys should be added to
``ec2_tags_list`` and be split by ``tag_list_sep`` (by default ``;``). If a tag
key is included in ``tag_list_key`` it is removed from ec2_tags. If a tag does
not exist it is still included as an empty list.
..note::
As with any master configuration change, restart the salt-master daemon for
changes to take effect.
.. code-block:: yaml
ext_pillar:
- ec2_pillar:
tag_match_key: 'Name'
tag_match_value: 'asis'
tag_list_key:
- Role
tag_list_sep: ';'
use_grain: True
minion_ids:
- trusted-minion-1
- trusted-minion-2
- trusted-minion-3
This is a very simple pillar configuration that simply retrieves the instance
data from AWS. Currently the only portion implemented are EC2 tags, which
returns a list of key/value pairs for all of the EC2 tags assigned to the
instance.
i ( t absolute_importt print_functiont unicode_literalsN( t range( t
StrictVersionu botoc C@ sO t s
t St t j � } t d � } | | k rK t j d t | | � t St S( ue
Check for required version of boto and make this pillar available
depending on outcome.
u 2.8.0u@ %s: installed boto version %s < %s, can't retrieve instance data( t HAS_BOTOt Falset _StrictVersiont botot __version__t logt errort __name__t True( t boto_versiont required_boto_version( ( s: /usr/lib/python2.7/site-packages/salt/pillar/ec2_pillar.pyt __virtual__S s
c C@ s% t j j � d } | d | d f S( uj
Helper function to return the instance ID and region of the master where
this pillar is run.
u documentu
instanceIdu region( R t utilst get_instance_identity( t identity( ( s: /usr/lib/python2.7/site-packages/salt/pillar/ec2_pillar.pyt _get_instance_infoc s u asisu ;c
C@ sO d d g } t j d i � j d d* � } | si t j d i � j d i � j d i � j d d* � } n | r� t j d | � d* k r� t j d t | | � d* } n | r� t j d
| � d* k r� t j d t t | t
j � r� | n d � i S| r(| | k r(t j d
t | d j | � � i S| s@d t | f }
n d t | | | f }
t j
|
� d* } d* } t j d | � d* k r�d* } | } nq | r| d k r�i | j d d � d d j | � 6} n i | d j | � 6} | r| j i | d 6� qn | rl| rl| rl| s4t j
d | � i S| d* k rc| | k rct j
d | | � i S| } n | pu| s�t j
d t | | | � i St j j d d d d � }
t |
j � � d k r�t j d t � i St � \ } } y t j j | � } Wn- t j j k
r0} t j d t | � i SX| d* k rTt j d t | � i Sy@ | r{| j d | g d t � } n | j d | d t � } Wn- t j j k
r�} t j d! |
| � i SX| s�t j
d"