Server IP : 23.254.227.96 / Your IP : 216.73.216.7 Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64 User : viralblo ( 1001) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3.6/site-packages/cloudinit/config/__pycache__/ |
Upload File : |
3 ��b67 � @ s� d Z ddlZddlZddlmZ ddlZddlmZmZm Z m Z mZ dZdgZ G dd� de�Zd d � Zdd� Zeddd fdd�Zdd� ZdS )aK 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. Agent packages from the puppetlabs repositories can be installed by setting ``install_type`` to ``aio``. Based on this setting, the default config/SSL/CSR paths will be adjusted accordingly. To maintain backwards compatibility this setting defaults to ``packages`` which will install puppet from the distro packages. If installing ``aio`` packages, ``collection`` can also be set to one of ``puppet`` (rolling release), ``puppet6``, ``puppet7`` (or their nightly counterparts) in order to install specific release streams. By default, the puppetlabs repository will be purged after installation finishes; set ``cleanup`` to ``false`` to prevent this. AIO packages are installed through a shell script which is downloaded on the machine and then executed; the path to this script can be overridden using the ``aio_install_url`` key. Puppet configuration can be specified under the ``conf`` key. The configuration is specified as a dictionary containing high-level ``<section>`` keys and lists of ``<key>=<value>`` pairs within each section. Each section name and ``<key>=<value>`` pair is written directly to ``puppet.conf``. As such, section names should be one of: ``main``, ``server``, ``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 puppetserver 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`` file for CSR attributes and certificate extension requests. See https://puppet.com/docs/puppet/latest/config_file_csr_attributes.html By default, the puppet service will be automatically enabled after installation and set to automatically start on boot. To override this in favor of manual puppet execution set ``start_service`` to ``false``. A single manual run can be triggered by setting ``exec`` to ``true``, and additional arguments can be passed to ``puppet agent`` via the ``exec_args`` key (by default the agent will execute with the ``--test`` flag). **Internal name:** ``cc_puppet`` **Module frequency:** per instance **Supported distros:** all **Config keys**:: puppet: install: <true/false> version: <version> collection: <aio collection> install_type: <packages/aio> aio_install_url: 'https://git.io/JBhoQ' cleanup: <true/false> conf_file: '/etc/puppet/puppet.conf' ssl_dir: '/var/lib/puppet/ssl' csr_attributes_path: '/etc/puppet/csr_attributes.yaml' package_name: 'puppet' exec: <true/false> exec_args: ['--test'] start_service: <true/false> conf: agent: server: "puppetserver.example.org" certname: "%i.%f" ca_cert: | -------BEGIN CERTIFICATE------- <cert data> -------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 � N)�StringIO)�helpers�subp� temp_utils� url_helper�utilzKhttps://raw.githubusercontent.com/puppetlabs/install-puppet/main/install.shz--testc @ s e Zd Zdd� ZdS )�PuppetConstantsc C s8 || _ || _tjj|d�| _tjj| jd�| _|| _d S )NZcertszca.pem)� conf_path�ssl_dir�os�path�join�ssl_cert_dir� ssl_cert_path�csr_attributes_path)�selfZpuppet_conf_fileZpuppet_ssl_dirr �log� r �/usr/lib/python3.6/cc_puppet.py�__init__z s zPuppetConstants.__init__N)�__name__� __module__�__qualname__r r r r r r y s r c C sx t jjd�r&tjdddddgdd� nNt jjd�rHtjdd d gdd� n,t jjd�rjtjddd gdd� n | jd� d S )Nz/etc/default/puppetZsedz-iz-ezs/^START=.*/START=yes/F)�capturez/bin/systemctl�enablezpuppet.servicez/sbin/chkconfig�puppetZonzASorry we do not know how to enable puppet services on this system)r r �existsr �warning)r r r r �_autostart_puppet� s r c C s t j | dd|g�\}}|j� S )z�Get the config value for a given setting using `puppet config print` :param puppet_bin: path to puppet binary :param setting: setting to query �config�print)r �rstrip)� puppet_binZsetting�out�_r r r �get_config_value� s r% Tc C s� g }|dk rd|g}|dk r(|d|g7 }|r6|dg7 }t j| dd�j}tjdd��4}tjj|d �}tj ||d d� t j |g| dd �S Q R X dS )aq Install puppet-agent from the puppetlabs repositories using the one-shot shell script :param url: URL from where to download the install script :param version: version to install, blank defaults to latest :param collection: collection to install, blank defaults to latest :param cleanup: whether to purge the puppetlabs repo after installation Nz-vz-cz --cleanup� )�urlZretriesT)Z needs_exezpuppet-installi� )�modeF)r )r Zreadurl�contentsr Ztempdirr r r r � write_filer )r'