3 \mek @sUdZddlZddlZddlZddlmZddlmZddlm Z m Z ddl m Z ddl mZddlmZmZdd lmZd Zd Zd Zd ZdgZdddeeedgedgdZeeeZejeZeeefddZeee eddddZ dS)z6 Mcollective: Install, configure and start mcollectiveN)dedent) ConfigObj)subputil)Cloud)Config) MetaSchema get_meta_doc) PER_INSTANCEz&/etc/mcollective/ssl/server-public.pemz'/etc/mcollective/ssl/server-private.pemz/etc/mcollective/server.cfgaThis 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. allZcc_mcollectiveZ 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-------- -------END CERTIFICATE-------- private-cert: | -------BEGIN CERTIFICATE-------- -------END CERTIFICATE-------- mcollective)idnametitle descriptiondistrosZexamplesZ frequencyZactivate_by_schema_keysc !Csy"tj|ddd}ttj|}WnDtk rf}z(|jtjkrDntj d|t}WYdd}~XnXx|j D]\}}|dkrtj ||dd||d<d|d <qr|d krtj ||d d||d <d|d <qrt |t r|||<qrt |tr(||jkri||<x0|j D]\} } | ||| <q Wqrt |||<qrWytj|d |Wn6tk r}z|jtjkrpnWYdd}~XnXtj} |j| tj || jdddS)NF)quietdecodez4Did not find file %s (starting with an empty config)z public-certi)modezplugin.ssl_server_publicZsslZsecurityproviderz private-certizplugin.ssl_server_privatez%s.old)rZ load_filerioBytesIOIOErrorerrnoENOENTLOGdebugitemsZ write_file isinstancestrdictZsectionscopywritegetvalue) configZ server_cfgZ pubcert_fileZ pricert_fileZ old_contentsZmcollective_configeZcfg_namecfgovcontentsr)$/usr/lib/python3.6/cc_mcollective.py configure\sH        r+)rr%cloudargsreturncCs\d|krtjd|dS|d}|jjdgd|krDt|ddtjdddgdddS) Nr z?Skipping module named %s, no 'mcollective' key in configurationZconf)r#ZserviceZrestartF)Zcapture)rrZdistroZinstall_packagesr+r)rr%r,r-Zmcollective_cfgr)r)r*handlesr/)!__doc__rrZloggingtextwraprZ configobjrZ cloudinitrrZcloudinit.cloudrZcloudinit.configrZcloudinit.config.schemarr Zcloudinit.settingsr Z PUBCERT_FILEZ PRICERT_FILEZ SERVER_CFGZMODULE_DESCRIPTIONrmetaZ getLogger__name__rr+rlistr/r)r)r)r* s<       9