܍~c UdZddlmZddlmZddlmZddlmZmZddl m Z ddl m Z ddl mZmZdd lmZejeZd d d Zd ZdddegdeedgdgdZeed<eeZdZdede de dededdf dZdS)z"Resolv Conf: configure resolv.conf)Logger)dedent)log) templaterutil)Cloud)Config) MetaSchema get_meta_doc) PER_INSTANCEz resolv.confzsystemd.resolved.conf)z/etc/resolv.confz/etc/systemd/resolved.confaThis module is intended to manage resolv.conf in environments where early configuration of resolv.conf is necessary for further bootstrapping and/or where configuration management such as puppet or chef own DNS configuration. As Debian/Ubuntu will, by default, utilize resolvconf, and similarly Red Hat will use sysconfig, this module is likely to be of little use unless those are configured correctly. When using a :ref:`datasource_config_drive` and a RHEL-like system, resolv.conf will also be managed automatically due to the available information provided for DNS servers in the :ref:`network_config_v2` format. For those that with to have different settings, use this module. In order for the ``resolv_conf`` section to be applied, ``manage_resolv_conf`` must be set ``true``. .. note:: For Red Hat with sysconfig, be sure to set PEERDNS=no for all DHCP enabled NICs. .. note:: And, in Ubuntu/Debian it is recommended that DNS be configured via the standard /etc/network/interfaces configuration file. cc_resolv_confz Resolv ConfzConfigure resolv.conf)alpinefedoramarineropensusephotonrhelslesa manage_resolv_conf: true resolv_conf: nameservers: - 8.8.8.8 - 8.8.4.4 searchdomains: - foo.example.com - bar.example.com domain: example.com sortlist: - 10.0.0.1/255 - 10.0.0.2 options: rotate: true timeout: 1 manage_resolv_conf)idnametitle descriptiondistros frequencyexamplesactivate_by_schema_keysmetacg}g}d|vrb|dD]G\}}t|tr-|r||2||H||zD] }|d|= |dsi|d<||d<t d|tj|||dS)Noptionsflagsz$Writing resolv.conf from template %s) items isinstanceboolappendgetLOGdebugrrender_to_file) template_fnparams target_fnamer! false_flagskeyvalflags A/usr/lib/python3/dist-packages/cloudinit/config/cc_resolv_conf.pygenerate_resolv_confr2_s EKFy)//11 , ,HC#t$$ ,,LL%%%%&&s+++ #$$ 9 d # # ::i yF7OII4kBBB [,?????rcfgcloudrargsreturnNcd|vr|d|dStj|dds|d|dSd|vr|ddS |t |jj}n&#t$r|dYdSwxYwt||d|jj dS) a[ Handler for resolv.conf @param name: The module name "resolv-conf" from cloud.cfg @param cfg: A nested dict containing the entire cloud config contents. @param cloud: The L{CloudInit} object in use. @param log: Pre-initialized Python logger object to use for logging. @param args: Any module arguments from cloud.cfg rzFSkipping module named %s, no 'manage_resolv_conf' key in configurationNFzGSkipping module named %s, 'manage_resolv_conf' present but set to False resolv_confz3manage_resolv_conf True but no parameters provided!z0No template found, not rendering resolve configs)r*r+r,) r(rget_cfg_option_boolwarningget_template_filenameRESOLVE_CONFIG_TEMPLATE_MAPdistroresolve_conf_fnKeyErrorr2)rr4r5rr6r*s r1handlerAvs'3&&  <      #C)=u E E  =    C IJJJ11 ' (D E    FGGG=!\1  Fs'*BB54B5)__doc__loggingrtextwrapr cloudinitrrrcloudinit.cloudrcloudinit.configr cloudinit.config.schemar r cloudinit.settingsr getLogger__name__r'r=MODULE_DESCRIPTIONr__annotations__r2strlistrAr3r1rQs)(($$$$$$%%%%%%%%!!!!!!######<<<<<<<<++++++g!!&"9 4   $%   *!55I%%j%%%N ,t  @@@.- - - #(- /5- =A-  - - - - - - r3