%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/roster/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/roster/ansible.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddl	m
Z
idd6dd6d	d
6dd6d
d6dd6ZdZd�Z
dd�Zd�Zd�ZdS(u-
Read in an Ansible inventory file or script

Flat inventory files should be in the regular ansible inventory format.

.. code-block:: ini

    [servers]
    salt.gtmanfred.com ansible_ssh_user=gtmanfred ansible_ssh_host=127.0.0.1 ansible_ssh_port=22 ansible_ssh_pass='password'

    [desktop]
    home ansible_ssh_user=gtmanfred ansible_ssh_host=12.34.56.78 ansible_ssh_port=23 ansible_ssh_pass='password'

    [computers:children]
    desktop
    servers

    [names:vars]
    http_port=80

then salt-ssh can be used to hit any of them

.. code-block:: bash

    [~]# salt-ssh -N all test.ping
    salt.gtmanfred.com:
        True
    home:
        True
    [~]# salt-ssh -N desktop test.ping
    home:
        True
    [~]# salt-ssh -N computers test.ping
    salt.gtmanfred.com:
        True
    home:
        True
    [~]# salt-ssh salt.gtmanfred.com test.ping
    salt.gtmanfred.com:
        True

There is also the option of specifying a dynamic inventory, and generating it on the fly

.. code-block:: bash

    #!/bin/bash
    echo '{
      "servers": [
        "salt.gtmanfred.com"
      ],
      "desktop": [
        "home"
      ],
      "computers": {
        "hosts": [],
        "children": [
          "desktop",
          "servers"
        ]
      },
      "_meta": {
        "hostvars": {
          "salt.gtmanfred.com": {
            "ansible_ssh_user": "gtmanfred",
            "ansible_ssh_host": "127.0.0.1",
            "ansible_sudo_pass": "password",
            "ansible_ssh_port": 22
          },
          "home": {
            "ansible_ssh_user": "gtmanfred",
            "ansible_ssh_host": "12.34.56.78",
            "ansible_sudo_pass": "password",
            "ansible_ssh_port": 23
          }
        }
      }
    }'

This is the format that an inventory script needs to output to work with ansible, and thus here.

.. code-block:: bash

    [~]# salt-ssh --roster-file /etc/salt/hosts salt.gtmanfred.com test.ping
    salt.gtmanfred.com:
            True

Any of the [groups] or direct hostnames will return.  The 'all' is special, and returns everything.
i(tabsolute_importtprint_functiontunicode_literalsN(tget_roster_fileuhostuansible_ssh_hostuportuansible_ssh_portuuseruansible_ssh_userupasswduansible_ssh_passusudouansible_sudo_passuprivuansible_ssh_private_key_fileuansiblecC@stjjjd�otdfS(Nuansible-inventoryu"Install `ansible` to use inventory(tsalttutilstpathtwhicht__virtualname__(((s7/usr/lib/python2.7/site-packages/salt/roster/ansible.pyt__virtual__osuglobcK@s�tdddjtt���}tdtd|��td<|dkr�gtd�D]}tj||�rY|^qY}n|d	kr�t|�}nd
�|D�S(uZ
    Return the targets from the ansible inventory_file
    Default: /etc/salt/roster
    usalt.cmducmd.runuansible-inventory -i {0} --listu
json.loadsustringutils.to_stru	inventoryuglobuallu	nodegroupcS@si|]}t|�|�qS((t
_get_hostvars(t.0thost((s7/usr/lib/python2.7/site-packages/salt/roster/ansible.pys
<dictcomp>s	(t
__runner__tformatRt__opts__t	__utils__t__context__t_get_hosts_from_grouptfnmatch(ttgtttgt_typetkwargst	inventoryRthosts((s7/usr/lib/python2.7/site-packages/salt/roster/ansible.pyttargetsss"4cC@sktd}g||jdg�D]}|^q!}x1||jdg�D]}|jt|��qJW|S(Nu	inventoryuhostsuchildren(RtgettextendR(tgroupRRRtchild((s7/usr/lib/python2.7/site-packages/salt/roster/ansible.pyR�s

)cC@s�tddjdi�j|i�}tjtjdi��}x4tD],}||krH|j|�|t|<qHqHW||d<d|kr�||d<n|S(Nu	inventoryu_metauhostvarsuroster_defaultsuminion_optsuhost(RRtcopytdeepcopyRt
CONVERSIONtpop(Rthostvarstrettvalue((s7/usr/lib/python2.7/site-packages/salt/roster/ansible.pyR
�s&


(t__doc__t
__future__RRRRRtsalt.utils.pathRtsalt.rosterRR RR	RRR
(((s7/usr/lib/python2.7/site-packages/salt/roster/ansible.pyt<module>Ys"
		

Zerion Mini Shell 1.0