
    fd              
       "   U d Z ddlZddlZddlZddlmZ ddlmZ ddlm	Z	m
Z
 ddlmZ ddlmZ ddlmZmZ dd	lmZ d
ZdZdZdZdgZdddee ed      gedgdZeed<    ee      Z  ej6                  e      ZeeefdZdededede ddf
dZ!y)z6 Mcollective: Install, configure and start mcollective    N)dedent)	ConfigObj)subputil)Cloud)Config)
MetaSchemaget_meta_doc)PER_INSTANCEz&/etc/mcollective/ssl/server-public.pemz'/etc/mcollective/ssl/server-private.pemz/etc/mcollective/server.cfga  This module installs, configures and starts mcollective. If the ``mcollective``
key is present in config, then mcollective will be installed and started.

Configuration for ``mcollective`` can be specified in the ``conf`` key under
``mcollective``. Each config value consists of a key value pair and will be
written to ``/etc/mcollective/server.cfg``. The ``public-cert`` and
``private-cert`` keys, if present in conf may be used to specify the public and
private certificates for mcollective. Their values will be written to
``/etc/mcollective/ssl/server-public.pem`` and
``/etc/mcollective/ssl/server-private.pem``.

.. note::
    The ec2 metadata service is readable by non-root users.
    If security is a concern, use include-once and ssl urls.
allcc_mcollectiveMcollectivez(Install, configure and start mcollectivea              # Provide server private and public key and provide the following
            # config settings in /etc/mcollective/server.cfg:
            # loglevel: debug
            # plugin.stomp.host: dbhost

            # WARNING WARNING WARNING
            # The ec2 metadata service is a network service, and thus is
            # readable by non-root users on the system
            # (ie: 'ec2metadata --user-data')
            # If you want security for this, please use include-once + SSL urls
            mcollective:
              conf:
                loglevel: debug
                plugin.stomp.host: dbhost
                public-cert: |
                    -------BEGIN CERTIFICATE--------
                    <cert data>
                    -------END CERTIFICATE--------
                private-cert: |
                    -------BEGIN CERTIFICATE--------
                    <cert data>
                    -------END CERTIFICATE--------
            mcollective)idnametitledescriptiondistrosexamples	frequencyactivate_by_schema_keysmetac                    	 t        j                  |d      }t        t        j                  |            }| j                         D ]  \  }}|dk(  r#t        j                  ||d       ||d<   d|d	<   .|d
k(  r#t        j                  ||d       ||d<   d|d	<   Vt        |t              r|||<   lt        |t              r4||j                  vri ||<   |j                         D ]  \  }	}
|
||   |	<    t        |      ||<    	 t        j                   |d|z         t        j                         }|j#                  |       t        j                  ||j%                         d       y # t
        $ rI}|j                  t        j                  k7  r t        j                  d|       t               }Y d }~d }~ww xY w# t
        $ r)}|j                  t        j                  k(  rn Y d }~d }~ww xY w)NF)quietz4Did not find file %s (starting with an empty config)zpublic-certi  )modezplugin.ssl_server_publicsslsecurityproviderzprivate-certi  zplugin.ssl_server_privatez%s.old)r   load_binary_filer   ioBytesIOIOErrorerrnoENOENTLOGdebugitems
write_file
isinstancestrdictsectionscopywritegetvalue)config
server_cfgpubcert_filepricert_fileold_contentsmcollective_configecfg_namecfgovcontentss               A/usr/lib/python3/dist-packages/cloudinit/config/cc_mcollective.py	configurer<   \   s   -,,ZuE&rzz,'?@   8#}$OOL#E:=I9:5:12'OOL#E:>J:;5:12#s#/2"8,C$( #5#>#>>35&x0IIK 8DAq67&x038 033x"8,-80	 			*h*56 zz|HX&OOJ 1 1 3%@_  -77ell"IIF "+-J  77ell" s/   5E- G -	F?6>F::F?	G4G//G4r   r7   cloudargsreturnc                     d|vrt         j                  d|        y |d   }|j                  j                  dg       d|v rt	        |d          t        j
                  g dd       y )Nr   z?Skipping module named %s, no 'mcollective' key in configurationconf)r/   )servicer   restartF)capture)r$   r%   distroinstall_packagesr<   r   )r   r7   r=   r>   mcollective_cfgs        r;   handlerH      si    C		M	
 	-(O 
LL!!=/2  01 	II3UC    )"__doc__r"   r   loggingtextwrapr   	configobjr   	cloudinitr   r   cloudinit.cloudr   cloudinit.configr   cloudinit.config.schemar	   r
   cloudinit.settingsr   PUBCERT_FILEPRICERT_FILE
SERVER_CFGMODULE_DESCRIPTIONr   r   __annotations__	getLogger__name__r$   r<   r)   listrH    rI   r;   <module>r\      s    =  	       ! # < +78*
 " ' 7%	
8  -G$j $L t
g!
 	:AzD D6 D% Dt D DrI   