diff options
author | Chad Smith <chad.smith@canonical.com> | 2022-01-31 20:45:29 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-31 20:45:29 -0700 |
commit | af7eb1deab12c7208853c5d18b55228e0ba29c4d (patch) | |
tree | db4f4b836a972f72aa4fdddf3840c136bc1abb57 /cloudinit/config/cc_disable_ec2_metadata.py | |
parent | 46a0126e874927353e83b385b58ab054e58667cc (diff) | |
download | vyos-cloud-init-af7eb1deab12c7208853c5d18b55228e0ba29c4d.tar.gz vyos-cloud-init-af7eb1deab12c7208853c5d18b55228e0ba29c4d.zip |
Schema a d (#1211)
Migrate from legacy schema or define new schema in
cloud-init-schema.json, adding extensive schema tests for:
- cc_apt_configure
- cc_bootcmd
- cc_byobu
- cc_ca_certs
- cc_chef
- cc_debug
- cc_disable_ec2_metadata
- cc_disk_setup
Deprecate config hyphenated schema keys in favor of underscores:
- ca_certs and ca_certs.remove_defaults instead of
ca-certs and ca-certs.remove-defaults
- Continue to honor deprecated config keys but emit DEPRECATION
warnings in logs for continued use of the deprecated keys:
- apt_sources key
- any apt v1 or v2 keys
- use or ca-certs or ca_certs.remove-defaults
- Extend apt_configure schema
- Define more strict schema below object opaque keys using
patternProperties
- create common $def apt_configure.mirror for reuse in 'primary'
and 'security' schema definitions within cc_apt_configure
Co-Authored-by: James Falcon <james.falcon@canonical.com>
Diffstat (limited to 'cloudinit/config/cc_disable_ec2_metadata.py')
-rw-r--r-- | cloudinit/config/cc_disable_ec2_metadata.py | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/cloudinit/config/cc_disable_ec2_metadata.py b/cloudinit/config/cc_disable_ec2_metadata.py index 5e528e81..6a5e7eda 100644 --- a/cloudinit/config/cc_disable_ec2_metadata.py +++ b/cloudinit/config/cc_disable_ec2_metadata.py @@ -6,34 +6,35 @@ # # This file is part of cloud-init. See LICENSE file for license information. -""" -Disable EC2 Metadata --------------------- -**Summary:** disable aws ec2 metadata +"""Disable EC2 Metadata: Disable AWS EC2 metadata.""" -This module can disable the ec2 datasource by rejecting the route to -``169.254.169.254``, the usual route to the datasource. This module is disabled -by default. - -**Internal name:** ``cc_disable_ec2_metadata`` - -**Module frequency:** always - -**Supported distros:** all - -**Config keys**:: - - disable_ec2_metadata: <true/false> -""" +from textwrap import dedent from cloudinit import subp, util +from cloudinit.config.schema import get_meta_doc +from cloudinit.distros import ALL_DISTROS from cloudinit.settings import PER_ALWAYS -frequency = PER_ALWAYS - REJECT_CMD_IF = ["route", "add", "-host", "169.254.169.254", "reject"] REJECT_CMD_IP = ["ip", "route", "add", "prohibit", "169.254.169.254"] +meta = { + "id": "cc_disable_ec2_metadata", + "name": "Disable EC2 Metadata", + "title": "Disable AWS EC2 Metadata", + "description": dedent( + """\ + This module can disable the ec2 datasource by rejecting the route to + ``169.254.169.254``, the usual route to the datasource. This module + is disabled by default.""" + ), + "distros": [ALL_DISTROS], + "frequency": PER_ALWAYS, + "examples": ["disable_ec2_metadata: true"], +} + +__doc__ = get_meta_doc(meta) + def handle(name, cfg, _cloud, log, _args): disabled = util.get_cfg_option_bool(cfg, "disable_ec2_metadata", False) |