
    f              
          U d Z ddlZddlZddlmZ ddlmZ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d	lmZ d
Zdddeege ed      gdgdZeed<    ee      Z  ej.                  e      Z G d d      Zdedede
deddf
dZy)z&Salt Minion: Setup and run salt minion    N)dedent)safeyamlsubputil)Cloud)Config)
MetaSchemaget_meta_doc)ALL_DISTROS)PER_INSTANCEa.  This module installs, configures and starts salt minion. If the ``salt_minion``
key is present in the config parts, then salt minion will be installed and
started. Configuration for salt minion can be specified in the ``conf`` key
under ``salt_minion``. Any conf values present there will be assigned in
``/etc/salt/minion``. The public and private keys to use for salt minion can be
specified with ``public_key`` and ``private_key`` respectively. Optionally if
you have a custom package name, service name or config directory you can
specify them with ``pkg_name``, ``service_name`` and ``config_dir``.

Salt keys can be manually generated by: ``salt-key --gen-keys=GEN_KEYS``,
where ``GEN_KEYS`` is the name of the keypair, e.g. 'minion'.  The keypair
will be copied to ``/etc/salt/pki`` on the minion instance.
cc_salt_minionzSalt MinionzSetup and run salt minionai              salt_minion:
                pkg_name: salt-minion
                service_name: salt-minion
                config_dir: /etc/salt
                conf:
                    file_client: local
                    fileserver_backend:
                      - gitfs
                    gitfs_remotes:
                      - https://github.com/_user_/_repo_.git
                    master: salt.example.com
                grains:
                    role:
                        - web
                public_key: |
                    ------BEGIN PUBLIC KEY-------
                    <key data>
                    ------END PUBLIC KEY-------
                private_key: |
                    ------BEGIN PRIVATE KEY------
                    <key data>
                    ------END PRIVATE KEY-------
                pki_dir: /etc/salt/pki/minion
            salt_minion)idnametitledescriptiondistros	frequencyexamplesactivate_by_schema_keysmetac                       e Zd ZdZd Zy)SaltConstantsz>
    defines default distribution specific salt variables
    c                 f   t        j                         rd| _        d| _        d| _        nd| _        d| _        d| _        t        j
                  |d| j                        | _        t        j
                  |d| j                        | _        t        j
                  |d| j                        | _        y )	Nzpy-saltr   z/usr/local/etc/saltzsalt-minionz	/etc/saltpkg_name
config_dirservice_name)r   
is_FreeBSDr   srv_nameconf_dirget_cfg_option_str)selfcfgs     A/usr/lib/python3/dist-packages/cloudinit/config/cc_salt_minion.py__init__zSaltConstants.__init__T   s    ??%DM)DM1DM *DM)DM'DM //ZO//t}}
 //
    N)__name__
__module____qualname____doc__r%    r&   r$   r   r   O   s    
r&   r   r   r#   cloudargsreturnc                 .   d|vrt         j                  d|        y |d   }t        |      }|j                  j	                  |j
                  g       t        j                  |j                         d }d|v rdt        j                  j                  |j                  d      }|j                  d      }t        j                  |t        j                  |             d|v rdt        j                  j                  |j                  d      }t        j                  |j                  d            }	t        j                  ||	       d|v r/d|v r*t        j                  j                  |j                  d	      }
t        j                  j!                  |
      s*t        j                  j                  |j                  d
      }
|j                  d|
      }t        j"                  d      5  t        j                  |       t        j                  j                  |d      }t        j                  j                  |d      }t        j                  ||d          t        j                  ||d          d d d        t%        |xr |j                  d      dk(         }|j                  j'                  |rdnd|j(                         |j                  j'                  |rdnd|j(                         |st+        j*                  g dd       y y # 1 sw Y   xY w)Nr   z?Skipping module named %s, no 'salt_minion' key in configuration)r#   confminiongrains
public_keyprivate_keyz
pki/minionpkipki_dir?   z
minion.pubz
minion.pemfile_clientlocalenabledisablerestartstop)z	salt-callz--localzstate.applyF)capture)LOGdebugr   distroinstall_packagesr   r   
ensure_dirr    ospathjoinget
write_filer   dumpsisdirumaskboolmanage_servicer   r   )r   r#   r,   r-   s_cfgconstminion_dataminion_configgrains_configgrains_datapki_dir_defaultr6   pub_namepem_nameminion_daemons                  r$   handlerX   j   sR   C		M	
 	Ee$E 
LL!!5>>"23 	OOENN#K U^^X>ii'x~~k'BC5U^^X>nnUYYx%89{3 u%!7'',,u~~|Dww}}_- ggll5>>5AO))I7ZZ 	<OOG$ww||G\:Hww||G\:HOOHeL&9:OOHeM&:;	< A6'A M 
LL!y%.. 
LL"	  			95I	 %	< 	<s   (BLL)r*   loggingrD   textwrapr   	cloudinitr   r   r   cloudinit.cloudr   cloudinit.configr   cloudinit.config.schemar	   r
   cloudinit.distrosr   cloudinit.settingsr   MODULE_DESCRIPTIONr   __annotations__	getLoggerr'   r?   r   strlistrX   r+   r&   r$   <module>rf      s   
 -  	  * * ! # < ) +   (%}	
: !.I%j %N t
g!
 
6>J >J6 >J% >Jt >J >Jr&   