%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/modules/puppet.pyo

�
���^c@@scdZddlmZmZmZddlmZddlZddlZddl	Z	ddl
ZddlZddl
ZddlZddlZddlZddlmZddlmZddlmZeje�Zd�Zd	�Zd
efd��YZd�Zd
�Zd�Z dd�Z"d�Z#d�Z$d�Z%e&d�Z'e&d�Z(dS(u
Execute puppet routines
i(tabsolute_importtprint_functiontunicode_literals(tversionN(tCommandExecutionError(tsix(trangecC@s:djd�dD��}|r2tdj|�fSdSdS(u*
    Only load if puppet is installed
    u, cs@s0|]&}tjjj|�dkr|VqdS(N(tsalttutilstpathtwhichtNone(t.0texe((s7/usr/lib/python2.7/site-packages/salt/modules/puppet.pys	<genexpr> sufacterupuppetu>The puppet execution module cannot be loaded: {0} unavailable.N(ufacterupuppet(tjointFalsetformat(tunavailable_exes((s7/usr/lib/python2.7/site-packages/salt/modules/puppet.pyt__virtual__s
cC@sRy(|jdd�\}}|j�}Wntk
rGd}d}nX||fS(Nu => i(tsplittstript
ValueErrorR(toutputtfacttvalue((s7/usr/lib/python2.7/site-packages/salt/modules/puppet.pyt_format_fact*s

t_PuppetcB@s,eZdZd�Zd�Zdd�ZRS(uD
    Puppet helper class. Used to format command for execution.
    cC@sHd|_g|_idd6|_g|_tjjj�r[d|_d|_	d|_
n�tdd�|_d	|jkr�d
|_d|_	d|_
ni|jgkr�t
j|j�t
jd
�kr�d|_d|_	d|_
nd|_d|_	d|_
|jd|_|jd|_|j	d|_|jd|_dS(u�
        Setup a puppet instance, based on the premis that default usage is to
        run 'puppet agent --test'. Configuration and run states are stored in
        the default locations.
        uagentufalseucoloru$C:\ProgramData\PuppetLabs\puppet\varu$C:\ProgramData\PuppetLabs\puppet\runu$C:\ProgramData\PuppetLabs\puppet\etcucmd.runupuppet --versionu
Enterpriseu/var/opt/lib/pe-puppetu/var/opt/run/pe-puppetu/etc/puppetlabs/puppetu4.0.0u/opt/puppetlabs/puppet/cacheu/var/run/puppetlabsu/var/lib/puppetu/var/run/puppetu/etc/puppetu/state/agent_disabled.locku/state/agent_catalog_run.locku
/agent.pidu/state/last_run_summary.yamlN(tsubcmdtsubcmd_argstkwargstargsRRtplatformt
is_windowstvardirtrundirtconfdirt__salt__tpuppet_versionRt
StrictVersiontdisabled_lockfiletrun_lockfilet
agent_pidfiletlastrunfile(tself((s7/usr/lib/python2.7/site-packages/salt/modules/puppet.pyt__init__8s0							0					cC@s�dj|j�}dj|j�}|djg|jD]}dj|�^q7�7}|djgtj|j�D]\}}dj||�^qr�7}tj	j
j�r�dj||�Sdj||�S(uJ
        Format the command string to executed using cmd.run_all.
        u5puppet {subcmd} --vardir {vardir} --confdir {confdir}u uu --{0}u
 --{0} {1}uEcmd /V:ON /c {0} {1} ^& if !ERRORLEVEL! EQU 2 (EXIT 0) ELSE (EXIT /B)u({0} {1}) || test $? -eq 2(Rt__dict__RRRRt	iteritemsRRRRR (R+tcmdRtktv((s7/usr/lib/python2.7/site-packages/salt/modules/puppet.pyt__repr__\s	)	;cC@sp|rt|�pg}|jdkrA|dg|_|d=n|jdkrc|jdg�n||_dS(u�
        Read in arguments for the current subcommand. These are added to the
        cmd line without '--' appended. Any others are redirected as standard
        options with the double hyphen prefixed.
        uapplyiuagentutestN(tlistRRtextendR(R+R((s7/usr/lib/python2.7/site-packages/salt/modules/puppet.pyt	argumentsqs

N(t__name__t
__module__t__doc__R,R2RR5(((s7/usr/lib/python2.7/site-packages/salt/modules/puppet.pyR4s	$	cO@s�t�}d}xKtt|��D]7}||dkrH|||_q"|||f7}q"W|j|�|jjtjj	j
|��tdt|�dt
�}|S(u=
    Execute a puppet run and return a dict with the stderr, stdout,
    return code, etc. The first positional argument given is checked as a
    subcommand. Following positional arguments should be ordered with arguments
    required by the subcommand first, followed by non-keyword arguments.
    Tags are specified by a tag keyword and comma separated list of values. --
    http://docs.puppetlabs.com/puppet/latest/reference/lang_tags.html

    CLI Examples:

    .. code-block:: bash

        salt '*' puppet.run
        salt '*' puppet.run tags=basefiles::edit,apache::server
        salt '*' puppet.run agent onetime no-daemonize no-usecacheonfailure no-splay ignorecache
        salt '*' puppet.run debug
        salt '*' puppet.run apply /a/b/manifest.pp modulepath=/a/b/modules tags=basefiles::edit,apache::server
    uagentuapplyucmd.run_alltpython_shell((uagentuapply(RRtlenRR5RtupdateRRRtclean_kwargsR$treprtTrue(RRtpuppett	buildargstargtret((s7/usr/lib/python2.7/site-packages/salt/modules/puppet.pytrun�s	
cO@s|d7}t||�S(u�
    Execute a puppet noop run and return a dict with the stderr, stdout,
    return code, etc. Usage is the same as for puppet.run.

    CLI Example:

    .. code-block:: bash

        salt '*' puppet.noop
        salt '*' puppet.noop tags=basefiles::edit,apache::server
        salt '*' puppet.noop debug
        salt '*' puppet.noop apply /a/b/manifest.pp modulepath=/a/b/modules tags=basefiles::edit,apache::server
    unoop(unoop(RC(RR((s7/usr/lib/python2.7/site-packages/salt/modules/puppet.pytnoop�s
cC@s�t�}tjj|j�r}ytj|j�WnAttfk
ru}dj|�}t	j
|�t|��q}XtSnt
S(u�
    .. versionadded:: 2014.7.0

    Enable the puppet agent

    CLI Example:

    .. code-block:: bash

        salt '*' puppet.enable
    uFailed to enable: {0}(RtosR	tisfileR'tremovetIOErrortOSErrorRtlogterrorRR>R(R?texctmsg((s7/usr/lib/python2.7/site-packages/salt/modules/puppet.pytenable�s	
c
C@s�t�}tjj|j�r"tStjjj	|jd���}yO|dk	r^dj|�nd}|jtjj
j|��|j�tSWnAttfk
r�}dj|�}tj|�t|��nXWdQXdS(u2
    .. versionadded:: 2014.7.0

    Disable the puppet agent

    message
        .. versionadded:: 2015.5.2

        Disable message to send to puppet

    CLI Example:

    .. code-block:: bash

        salt '*' puppet.disable
        salt '*' puppet.disable 'Disabled, contact XYZ before enabling'
    uwu{{"disabled_message":"{0}"}}u{}uFailed to disable: {0}N(RRER	RFR'RRRtfilestfopenRRtwritetstringutilstto_strtcloseR>RHRIRJRKR(tmessageR?tlockfileRMRL((s7/usr/lib/python2.7/site-packages/salt/modules/puppet.pytdisable�s	!

cC@sFt�}tjj|j�r"dStjj|j�r�yYtjjj	|jd��8}t
tjjj|j
���}tj|d�WdQXWnttfk
r�dSXdSntjj|j�rByYtjjj	|jd��8}t
tjjj|j
���}tj|d�WdQXWnttfk
r:dSXdSnd	S(
u�
    .. versionadded:: 2014.7.0

    Display puppet agent status

    CLI Example:

    .. code-block:: bash

        salt '*' puppet.status
    uAdministratively disableduriNuStale lockfileuApplying a catalogu
Stale pidfileuIdle daemonuStopped(RRER	RFR'R(RRRORPtintRRt
to_unicodetreadtkillRIRR)(R?tfp_tpid((s7/usr/lib/python2.7/site-packages/salt/modules/puppet.pytstatuss(	!!cC@spt�}ytjjj|jd��}tjjj|�}WdQXi}d|kr�y.tjj	t
|dd��j�|d<Wn$tt
tfk
r�d|d<nXi|d<x:dD]/}||dkr�|d||d|<q�q�Wnd|kr|d|d<nWnXtjjjk
rD}td	j|���n(tk
rk}td
j|���nX|S(u�
    .. versionadded:: 2014.7.0

    Show a summary of the last puppet agent run

    CLI Example:

    .. code-block:: bash

        salt '*' puppet.summary
    urNutimeulast_runuinvalid or missing timestamputotaluconfig_retrievalu	resourcesu*YAML error parsing puppet run summary: {0}u&Unable to read puppet run summary: {0}(utotaluconfig_retrieval(RRRRORPR*tyamlt	safe_loadtdatetimet
fromtimestampRXt	isoformatt	TypeErrorRtKeyErrort	YAMLErrorRRRH(R?R\treporttresulttkeyRL((s7/usr/lib/python2.7/site-packages/salt/modules/puppet.pytsummary+s0
		%

 cC@stdd�}|sdS|S(u�
    Runs a plugin sync between the puppet master and agent

    CLI Example:

    .. code-block:: bash

        salt '*' puppet.plugin_sync
    ucmd.runupuppet plugin downloadu(R$(RB((s7/usr/lib/python2.7/site-packages/salt/modules/puppet.pytplugin_syncZs
cC@s�i}|rdnd}tddj|��}|ddkrTt|d��n|d}xH|j�D]:}|s}qknt|�\}}|s�qkn|||<qkW|S(	uv
    Run facter and return the results

    CLI Example:

    .. code-block:: bash

        salt '*' puppet.facts
    u--puppetuucmd.run_allu
facter {0}uretcodeiustderrustdout(R$RRt
splitlinesR(R?RBt
opt_puppettcmd_retRtlineRR((s7/usr/lib/python2.7/site-packages/salt/modules/puppet.pytfactsks

cC@sm|rdnd}tddj||�dt�}|ddkrWt|d��n|d	sedS|d	S(
uy
    Run facter for a specific fact

    CLI Example:

    .. code-block:: bash

        salt '*' puppet.fact kernel
    u--puppetuucmd.run_allufacter {0} {1}R9uretcodeiustderrustdout(R$RRR(tnameR?RmRB((s7/usr/lib/python2.7/site-packages/salt/modules/puppet.pyR�s
	
()R8t
__future__RRRt	distutilsRtloggingRERatsalt.utils.argsRtsalt.utils.filestsalt.utils.pathtsalt.utils.platformtsalt.utils.yamltsalt.utils.stringutilstsalt.exceptionsRtsalt.extRtsalt.ext.six.movesRt	getLoggerR6RJRRtobjectRRCRDRNRRWR^RjRkRRpR(((s7/usr/lib/python2.7/site-packages/salt/modules/puppet.pyt<module>s6		
V	(		%	(	/	 

Zerion Mini Shell 1.0