�
oB�]c@s�dZddlmZddlZddlZddlZddlmZddlmZdZ dZ
dZd Zd
e
fd��YZd�Zd
�ZdS(s_
Puppet
------
**Summary:** install, configure and start puppet
This module handles puppet installation and configuration. If the ``puppet``
key does not exist in global configuration, no action will be taken. If a
config entry for ``puppet`` is present, then by default the latest version of
puppet will be installed. If ``install`` is set to ``false``, puppet will not
be installed. However, this will result in an error if puppet is not already
present on the system. The version of puppet to be installed can be specified
under ``version``, and defaults to ``none``, which selects the latest version
in the repos. If the ``puppet`` config key exists in the config archive, this
module will attempt to start puppet even if no installation was performed.
The module also provides keys for configuring the new puppet 4 paths and
installing the puppet package from the puppetlabs repositories:
https://docs.puppet.com/puppet/4.2/reference/whered_it_go.html
The keys are ``package_name``, ``conf_file``, ``ssl_dir`` and
``csr_attributes_path``. If unset, their values will default to
ones that work with puppet 3.x and with distributions that ship modified
puppet 4.x that uses the old paths.
Puppet configuration can be specified under the ``conf`` key. The
configuration is specified as a dictionary containing high-level ````
keys and lists of ``=`` pairs within each section. Each section
name and ``=`` pair is written directly to ``puppet.conf``. As
such, section names should be one of: ``main``, ``master``, ``agent`` or
``user`` and keys should be valid puppet configuration options. The
``certname`` key supports string substitutions for ``%i`` and ``%f``,
corresponding to the instance id and fqdn of the machine respectively.
If ``ca_cert`` is present, it will not be written to ``puppet.conf``, but
instead will be used as the puppermaster certificate. It should be specified
in pem format as a multi-line string (using the ``|`` yaml notation).
Additionally it's possible to create a csr_attributes.yaml for
CSR attributes and certificate extension requests.
See https://puppet.com/docs/puppet/latest/config_file_csr_attributes.html
**Internal name:** ``cc_puppet``
**Module frequency:** per instance
**Supported distros:** all
**Config keys**::
puppet:
install:
version:
conf_file: '/etc/puppet/puppet.conf'
ssl_dir: '/var/lib/puppet/ssl'
csr_attributes_path: '/etc/puppet/csr_attributes.yaml'
package_name: 'puppet'
conf:
agent:
server: "puppetmaster.example.org"
certname: "%i.%f"
ca_cert: |
-------BEGIN CERTIFICATE-------
-------END CERTIFICATE-------
csr_attributes:
custom_attributes:
1.2.840.113549.1.9.7: 342thbjkt82094y0uthhor289jnqthpc2290
extension_requests:
pp_uuid: ED803750-E3C7-44F5-BB08-41A04433FE2E
pp_image_name: my_ami_image
pp_preshared_key: 342thbjkt82094y0uthhor289jnqthpc2290
i����(tStringION(thelpers(tutils/etc/puppet/puppet.confs/var/lib/puppet/ssls/etc/puppet/csr_attributes.yamltpuppettPuppetConstantscBseZd�ZRS(cCsR||_||_tjj|d�|_tjj|jd�|_||_dS(Ntcertssca.pem(t conf_pathtssl_dirtostpathtjointssl_cert_dirt
ssl_cert_pathtcsr_attributes_path(tselftpuppet_conf_filetpuppet_ssl_dirR
tlog((s>/usr/lib/python2.7/site-packages/cloudinit/config/cc_puppet.pyt__init__as
(t__name__t
__module__R(((s>/usr/lib/python2.7/site-packages/cloudinit/config/cc_puppet.pyR_scCs�tjjd�r7tjdddddgdt�notjjd�rhtjddd gdt�n>tjjd
�r�tjd
ddgdt�n
|jd
�dS(Ns/etc/default/puppettseds-is-ess/^START=.*/START=yes/tcaptures/bin/systemctltenablespuppet.services/sbin/chkconfigRtonsASorry we do not know how to enable puppet services on this system(RR texistsRtsubptFalsetwarning(R((s>/usr/lib/python2.7/site-packages/cloudinit/config/cc_puppet.pyt_autostart_puppetjs
cCsGd|kr |jd|�dS|d}tj|dt�}tj|dd�}tj|dt�}tj|dt�} tj|dt�}
tj|dt �}t
| |
||�}|r�|r�|jd �n;|r|jd
|r�|nd�|jj
||f�nd|kr�tj|j�}
tj�}g|
j�D]}|j�^qL}d
j|�}|jt|�d|j�xV|dj�D]A\}}|dkr3tj|jd�tj|jdd�tj|j�tj|jdd�tj|j|�tj|jdd�n{xx|j�D]j\}}|dkr�|jdtj ��}|jd|j!��}|j"�}n|j#|||�q@Wtj$|jd|j�tj|j|j%��q�Wnd|krtj|j&t'j(|ddt)��nt*|�tj+dddgdt)�dS(NRs9Skipping module named %s, no 'puppet' configuration foundtinstalltversiontpackage_namet conf_fileRR
s=Puppet install set false but version supplied, doing nothing.s Attempting to install puppet %s,tlatesttconfs
tfilenametca_certi�troottcertnames%fs%is%s.oldtcsr_attributestdefault_flow_styletservicetstartR(,tdebugRtget_cfg_option_booltTruetget_cfg_option_strtNonetPUPPET_PACKAGE_NAMEtPUPPET_CONF_PATHtPUPPET_SSL_DIRtPUPPET_CSR_ATTRIBUTES_PATHRRtdistrotinstall_packagest load_fileRRtDefaultingConfigParsert
splitlinestlstripR
treadfpRtitemst
ensure_dirRtchownbynameRt
write_fileRtreplacetsockettgetfqdntget_instance_idtlowertsettrenamet stringifyR
tyamltdumpRRR(tnametcfgtcloudRt_argst
puppet_cfgRRR R!RR
tp_constantstcontentst
puppet_configtit
cleaned_linestcleaned_contentstcfg_nametotv((s>/usr/lib/python2.7/site-packages/cloudinit/config/cc_puppet.pythandlezsh
%
(t__doc__tsixRRRARHt cloudinitRRR2R3R4R1tobjectRRRX(((s>/usr/lib/python2.7/site-packages/cloudinit/config/cc_puppet.pytNs