ó ƒjbc @sdZddlZddlZddlZddlmZddlmZddlmZddlZdZ e ddd d d d gƒZ e dgƒZ d Z dZdZdZi dd6dd6dd6ed6dd6dd6ed6d d6d d6dd6ed 6dd!6Zed gƒZedddddddd!gƒZeejƒƒZejeƒejeƒejd"d#d$d%gƒeeƒZd&Zd'Ze d(d)d*d+d,gƒZd-„Zd.„Zd/„Z d0„Z!d1„Z"dddd2„Z#d3„Z$d4„Z%d5„Z&dS(6sD Chef ---- **Summary:** module that configures, starts and installs chef. This module enables chef to be installed (from packages or from gems, or from omnibus). Before this occurs chef configurations are written to disk (validation.pem, client.pem, firstboot.json, client.rb), and needed chef folders/directories are created (/etc/chef and /var/log/chef and so-on). Then once installing proceeds correctly if configured chef will be started (in daemon mode or in non-daemon mode) and then once that has finished (if ran in non-daemon mode this will be when chef finishes converging, if ran in daemon mode then no further actions are possible since chef will have forked into its own process) then a post run function can run that can do finishing activities (such as removing the validation pem file). **Internal name:** ``cc_chef`` **Module frequency:** per always **Supported distros:** all **Config keys**:: chef: directories: (defaulting to /etc/chef, /var/log/chef, /var/lib/chef, /var/cache/chef, /var/backups/chef, /run/chef) validation_cert: (optional string to be written to file validation_key) special value 'system' means set use existing file validation_key: (optional the path for validation_cert. default /etc/chef/validation.pem) firstboot_path: (path to write run_list and initial_attributes keys that should also be present in this configuration, defaults to /etc/chef/firstboot.json) exec: boolean to run or not run chef (defaults to false, unless a gem installed is requested where this will then default to true) chef.rb template keys (if falsey, then will be skipped and not written to /etc/chef/client.rb) chef: client_key: encrypted_data_bag_secret: environment: file_backup_path: file_cache_path: json_attribs: log_level: log_location: node_name: omnibus_url: omnibus_url_retries: omnibus_version: pid_file: server_url: show_time: ssl_verify_mode: validation_cert: validation_key: validation_name: iÿÿÿÿN(t templater(t url_helper(tutils1.8s /etc/chefs /var/log/chefs /var/lib/chefs/var/cache/chefs/var/backups/chefs /run/chefs#https://www.chef.io/chef/install.shis/etc/chef/validation.pems/etc/chef/firstboot.jsons :verify_nonetssl_verify_modes:infot log_levels/var/log/chef/client.logt log_locationtvalidation_keytvalidation_certs/etc/chef/client.pemt client_keyt json_attribstfile_cache_pathtfile_backup_paths/run/chef/client.pidtpid_filet show_timetencrypted_data_bag_secrett server_urlt node_namet environmenttvalidation_names/etc/chef/client.rbs/usr/bin/chef-clients-ds-it1800s-st20cCs3tjjtƒstStjttjƒs/tStS(N(tostpathtisfiletCHEF_EXEC_PATHtFalsetaccesstX_OKtTrue(((s</usr/lib/python2.7/site-packages/cloudinit/config/cc_chef.pyt is_installed’s cCsDtj|ddtƒ}|r@tjjtƒr@tjtƒndS(Ntdelete_validation_post_exectdefault(Rtget_cfg_option_boolRRRRtCHEF_VALIDATION_PEM_PATHtunlink(tchef_cfgtlogt delete_pem((s</usr/lib/python2.7/site-packages/cloudinit/config/cc_chef.pyt post_run_chefšs   cCstjƒ}x|jƒD]‚\}}|tkrG|jd|ƒqn|dkr`d||trun((s</usr/lib/python2.7/site-packages/cloudinit/config/cc_chef.pythandleÁsh                 cCs½|jdƒtg}d|kr™|d}t|ttfƒrQ|j|ƒq¦t|tjƒrs|j|ƒq¦|j dt |ƒƒ|jt ƒn |jt ƒt j |dtƒdS(NsRunning chef-clienttexec_argumentssRUnknown type %s provided for chef 'exec_arguments' expected list, tuple, or stringtcapture(R-Rt isinstanceRAttupletextendtsixt string_typestappendRIttypetCHEF_EXEC_DEF_ARGSRtsubpR(R#R$tcmdtcmd_args((s</usr/lib/python2.7/site-packages/cloudinit/config/cc_chef.pyR[ s       c Csˆ|d krt}n|d kr*t}n|d kr?g}n d|g}tjd|d|ƒj}tjd|d|dddtƒS( sgInstall an omnibus unified package from url. @param url: URL where blob of chef content may be downloaded. Defaults to OMNIBUS_URL. @param retries: Number of retries to perform when attempting to read url. Defaults to OMNIBUS_URL_RETRIES @param omnibus_version: Optional version string to require for omnibus install. s-vturltretriestblobtargstbasenameschef-omnibus-installRkN( R.t OMNIBUS_URLtOMNIBUS_URL_RETRIESRtreadurltcontentsRtsubp_blob_in_tempfileR(RwRxtomnibus_versionRztcontent((s</usr/lib/python2.7/site-packages/cloudinit/config/cc_chef.pytinstall_chef_from_omnibus s         cCstj|ddƒ}tj|ddtƒ}|dkr‘tj|ddƒ}tj|dtƒ}t|||jƒtj|ddtƒ}n‡|dkr°|jj dƒnh|d krtj|d ƒ}t d tj|d ƒd tj |dƒd |ƒn|j d|ƒt}|S(Nt install_typetpackagesR?Rtgemstversiont ruby_versionR8tomnibusRRwt omnibus_urlRxtomnibus_url_retriessUnknown chef install type '%s'(schef( RR0R RR.tRUBY_VERSION_DEFAULTtinstall_chef_from_gemstdistroRtinstall_packagesRƒtget_cfg_option_intRI(R^R#R$R„Rht chef_versionRˆR((s</usr/lib/python2.7/site-packages/cloudinit/config/cc_chef.pyRZ9s(        cCs4d|d|g}|dkr0|jdƒn|S(Nsruby%ss ruby%s-devs1.8slibopenssl-ruby1.8s rubygems1.8(slibopenssl-ruby1.8s rubygems1.8(Rn(R‡tpkgs((s</usr/lib/python2.7/site-packages/cloudinit/config/cc_chef.pytget_ruby_packagesVs c CsÏ|jt|ƒƒtjjdƒs<tjd|dƒntjjdƒsetjd|dƒn|r tjdddd|dd d d d g d tƒn+tjddddd d d d gd tƒdS(Ns /usr/bin/gems/usr/bin/gem%ss /usr/bin/rubys/usr/bin/ruby%stinstallR8s-v %ss--no-ris --no-rdocs--bindirs/usr/bins-qRk( RR“RRtexistsRtsym_linkRtR(RˆR‘RŽ((s</usr/lib/python2.7/site-packages/cloudinit/config/cc_chef.pyR^s  ('t__doc__RCRXRt cloudinitRRRRoRŒRmRBRER|R}R!RUR.RR)t frozensetR/RORARWR,RnRTRRsRR&R7RiR[RƒRZR“R(((s</usr/lib/python2.7/site-packages/cloudinit/config/cc_chef.pytHs‚                L