/usr/lib/python3.6/site-packages/cloudinit/config
NameSizeModeActions
schemas/-0755rm
__pycache__/-0755rm
cc_ansible.py88940644editdlrm
cc_apk_configure.py57920644editdlrm
cc_apt_configure.py429950644editdlrm
cc_apt_pipelining.py27710644editdlrm
cc_bootcmd.py29210644editdlrm
cc_byobu.py37380644editdlrm
cc_ca_certs.py93470644editdlrm
cc_chef.py141020644editdlrm
cc_disable_ec2_metadata.py20740644editdlrm
cc_disk_setup.py331360644editdlrm
cc_fan.py30930644editdlrm
cc_final_message.py34700644editdlrm
cc_growpart.py215380644editdlrm
cc_grub_dpkg.py68120644editdlrm
cc_install_hotplug.py39040644editdlrm
cc_keyboard.py24390644editdlrm
cc_keys_to_console.py36940644editdlrm
cc_landscape.py54330644editdlrm
cc_locale.py19030644editdlrm
cc_lxd.py185800644editdlrm
cc_mcollective.py62510644editdlrm
cc_migrator.py35690644editdlrm
cc_mounts.py201860644editdlrm
cc_ntp.py213410644editdlrm
cc_package_update_upgrade_install.py46520644editdlrm
cc_phone_home.py56150644editdlrm
cc_power_state_change.py75910644editdlrm
cc_puppet.py144350644editdlrm
cc_reset_rmc.py45750644editdlrm
cc_resizefs.py109830644editdlrm
cc_resolv_conf.py51030644editdlrm
cc_rh_subscription.py173780644editdlrm
cc_rightscale_userdata.py43870644editdlrm
cc_rsyslog.py138000644editdlrm
cc_runcmd.py29740644editdlrm
cc_salt_minion.py60220644editdlrm
cc_scripts_per_boot.py16970644editdlrm
cc_scripts_per_instance.py18520644editdlrm
cc_scripts_per_once.py18030644editdlrm
cc_scripts_user.py18930644editdlrm
cc_scripts_vendor.py23470644editdlrm
cc_seed_random.py48370644editdlrm
cc_set_hostname.py52540644editdlrm
cc_set_passwords.py112340644editdlrm
cc_snap.py64480644editdlrm
cc_spacewalk.py35140644editdlrm
cc_ssh.py152160644editdlrm
cc_ssh_authkey_fingerprints.py43180644editdlrm
cc_ssh_import_id.py62640644editdlrm
cc_timezone.py14920644editdlrm
cc_ubuntu_advantage.py174110644editdlrm
cc_ubuntu_autoinstall.py46040644editdlrm
cc_ubuntu_drivers.py46680644editdlrm
cc_update_etc_hosts.py52830644editdlrm
cc_update_hostname.py39630644editdlrm
cc_users_groups.py87770644editdlrm
cc_wireguard.py94390644editdlrm
cc_write_files.py68190644editdlrm
cc_write_files_deferred.py17210644editdlrm
cc_yum_add_repo.py76330644editdlrm
cc_zypper_add_repo.py67490644editdlrm
modules.py120190644editdlrm
schema.py561650644editdlrm
__init__.py140644editdlrm
Edit: /usr/lib/python3.6/site-packages/cloudinit/config/cc_runcmd.py (2974B)
# Copyright (C) 2009-2010 Canonical Ltd. # Copyright (C) 2012 Hewlett-Packard Development Company, L.P. # # Author: Scott Moser # Author: Juerg Haefliger # # This file is part of cloud-init. See LICENSE file for license information. """Runcmd: run arbitrary commands at rc.local with output to the console""" import logging import os from textwrap import dedent from cloudinit import util from cloudinit.cloud import Cloud from cloudinit.config import Config from cloudinit.config.schema import MetaSchema, get_meta_doc from cloudinit.distros import ALL_DISTROS from cloudinit.settings import PER_INSTANCE # The schema definition for each cloud-config module is a strict contract for # describing supported configuration parameters for each cloud-config section. # It allows cloud-config to validate and alert users to invalid or ignored # configuration options before actually attempting to deploy with said # configuration. MODULE_DESCRIPTION = """\ Run arbitrary commands at a rc.local like time-frame with output to the console. Each item can be either a list or a string. The item type affects how it is executed: * If the item is a string, it will be interpreted by ``sh``. * If the item is a list, the items will be executed as if passed to execve(3) (with the first arg as the command). Note that the ``runcmd`` module only writes the script to be run later. The module that actually runs the script is ``scripts_user`` in the :ref:`Final` boot stage. .. note:: all commands must be proper yaml, so you have to quote any characters yaml would eat (':' can be problematic) .. note:: when writing files, do not use /tmp dir as it races with systemd-tmpfiles-clean LP: #1707222. Use /run/somedir instead. """ meta: MetaSchema = { "id": "cc_runcmd", "name": "Runcmd", "title": "Run arbitrary commands", "description": MODULE_DESCRIPTION, "distros": [ALL_DISTROS], "frequency": PER_INSTANCE, "examples": [ dedent( """\ runcmd: - [ ls, -l, / ] - [ sh, -xc, "echo $(date) ': hello world!'" ] - [ sh, -c, echo "=========hello world'=========" ] - ls -l /root - [ wget, "http://example.org", -O, /tmp/index.html ] """ ) ], "activate_by_schema_keys": ["runcmd"], } __doc__ = get_meta_doc(meta) LOG = logging.getLogger(__name__) def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None: if "runcmd" not in cfg: LOG.debug( "Skipping module named %s, no 'runcmd' key in configuration", name ) return out_fn = os.path.join(cloud.get_ipath("scripts"), "runcmd") cmd = cfg["runcmd"] try: content = util.shellify(cmd) util.write_file(out_fn, content, 0o700) except Exception as e: raise type(e)("Failed to shellify {} into file {}".format(cmd, out_fn))