f% UdZddlZddlmZddlmZmZmZddlm Z ddl m Z ddl m Z mZddlmZej"eZeZd gZd d d ed eedgedgdZe ed<eeZdede de deddf dZy)z:Bootcmd: run arbitrary commands early in the boot process.N)dedent)subp temp_utilsutil)Cloud)Config) MetaSchema get_meta_doc) PER_ALWAYSall cc_bootcmdBootcmdz0Run arbitrary commands early in the boot processa This module runs arbitrary commands very early in the boot process, only slightly after a boothook would run. This is very similar to a boothook, but more user friendly. The environment variable ``INSTANCE_ID`` will be set to the current instance id for all run commands. Commands can be specified either as lists or strings. For invocation details, see ``runcmd``. .. note:: bootcmd should only be used for things that could not be done later in the boot process. .. note:: when writing files, do not use /tmp dir as it races with systemd-tmpfiles-clean LP: #1707222. Use /run/somedir instead. z bootcmd: - echo 192.168.1.130 us.archive.ubuntu.com > /etc/hosts - [ cloud-init-per, once, mymkfs, mkfs, /dev/vdb ] bootcmd)idnametitle descriptiondistrosexamples frequencyactivate_by_schema_keysmetarcfgcloudargsreturnc vd|vrtjd|ytjd5} t j |d}|j t j||j |j}|r dt|ini}tjd|jg|d  dddy#t$r*}t jtdt|d}~wwxYw#t$rt jtd |wxYw#1swYyxYw) Nrz;Skipping module named %s, no 'bootcmd' key in configurationz.sh)suffixzFailed to shellify bootcmd: %s INSTANCE_IDz/bin/shF) update_envcapturezFailed to run bootcmd module %s)LOGdebugrExtendedTemporaryFilershellifywrite encode_textflush Exceptionlogexcstrget_instance_idrr) rrrrtmpfcontenteiidenvs =/usr/lib/python3/dist-packages/cloudinit/config/cc_bootcmd.pyhandler3Cs  I4    ) ) 74 mmC N3G JJt''0 1 JJL  '')C/2=#c(+C IIy$)),e L   KK=s1v F    KK> E  s<D/A CAD D%C>>DD/&D,,D//D8)__doc__loggingtextwrapr cloudinitrrrcloudinit.cloudrcloudinit.configrcloudinit.config.schemar r cloudinit.settingsr getLogger__name__r"rrr__annotations__r+listr3r2rBsA,,!#<)g!  '   ? &   ){E#j#J t 6%trA