summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_chef.py
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2022-01-31 20:45:29 -0700
committerGitHub <noreply@github.com>2022-01-31 20:45:29 -0700
commitaf7eb1deab12c7208853c5d18b55228e0ba29c4d (patch)
treedb4f4b836a972f72aa4fdddf3840c136bc1abb57 /cloudinit/config/cc_chef.py
parent46a0126e874927353e83b385b58ab054e58667cc (diff)
downloadvyos-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_chef.py')
-rw-r--r--cloudinit/config/cc_chef.py301
1 files changed, 2 insertions, 299 deletions
diff --git a/cloudinit/config/cc_chef.py b/cloudinit/config/cc_chef.py
index 67889683..aaf7eaf1 100644
--- a/cloudinit/config/cc_chef.py
+++ b/cloudinit/config/cc_chef.py
@@ -14,7 +14,7 @@ import os
from textwrap import dedent
from cloudinit import subp, temp_utils, templater, url_helper, util
-from cloudinit.config.schema import get_meta_doc, validate_cloudconfig_schema
+from cloudinit.config.schema import get_meta_doc
from cloudinit.settings import PER_ALWAYS
RUBY_VERSION_DEFAULT = "1.8"
@@ -137,303 +137,7 @@ meta = {
"frequency": frequency,
}
-schema = {
- "type": "object",
- "properties": {
- "chef": {
- "type": "object",
- "additionalProperties": False,
- "properties": {
- "directories": {
- "type": "array",
- "items": {"type": "string"},
- "uniqueItems": True,
- "description": dedent(
- """\
- Create the necessary directories for chef to run. By
- default, it creates the following directories:
-
- {chef_dirs}"""
- ).format(
- chef_dirs="\n".join(
- [" - ``{}``".format(d) for d in CHEF_DIRS]
- )
- ),
- },
- "validation_cert": {
- "type": "string",
- "description": dedent(
- """\
- Optional string to be written to file validation_key.
- Special value ``system`` means set use existing file.
- """
- ),
- },
- "validation_key": {
- "type": "string",
- "default": CHEF_VALIDATION_PEM_PATH,
- "description": dedent(
- """\
- Optional path for validation_cert. default to
- ``{}``.""".format(
- CHEF_VALIDATION_PEM_PATH
- )
- ),
- },
- "firstboot_path": {
- "type": "string",
- "default": CHEF_FB_PATH,
- "description": dedent(
- """\
- Path to write run_list and initial_attributes keys that
- should also be present in this configuration, defaults
- to ``{}``.""".format(
- CHEF_FB_PATH
- )
- ),
- },
- "exec": {
- "type": "boolean",
- "default": False,
- "description": dedent(
- """\
- define if we should run or not run chef (defaults to
- false, unless a gem installed is requested where this
- will then default to true)."""
- ),
- },
- "client_key": {
- "type": "string",
- "default": CHEF_RB_TPL_DEFAULTS["client_key"],
- "description": dedent(
- """\
- Optional path for client_cert. default to
- ``{}``.""".format(
- CHEF_RB_TPL_DEFAULTS["client_key"]
- )
- ),
- },
- "encrypted_data_bag_secret": {
- "type": "string",
- "default": None,
- "description": dedent(
- """\
- Specifies the location of the secret key used by chef
- to encrypt data items. By default, this path is set
- to None, meaning that chef will have to look at the
- path ``{}`` for it.
- """.format(
- CHEF_ENCRYPTED_DATA_BAG_PATH
- )
- ),
- },
- "environment": {
- "type": "string",
- "default": CHEF_ENVIRONMENT,
- "description": dedent(
- """\
- Specifies which environment chef will use. By default,
- it will use the ``{}`` configuration.
- """.format(
- CHEF_ENVIRONMENT
- )
- ),
- },
- "file_backup_path": {
- "type": "string",
- "default": CHEF_RB_TPL_DEFAULTS["file_backup_path"],
- "description": dedent(
- """\
- Specifies the location in which backup files are
- stored. By default, it uses the
- ``{}`` location.""".format(
- CHEF_RB_TPL_DEFAULTS["file_backup_path"]
- )
- ),
- },
- "file_cache_path": {
- "type": "string",
- "default": CHEF_RB_TPL_DEFAULTS["file_cache_path"],
- "description": dedent(
- """\
- Specifies the location in which chef cache files will
- be saved. By default, it uses the ``{}``
- location.""".format(
- CHEF_RB_TPL_DEFAULTS["file_cache_path"]
- )
- ),
- },
- "json_attribs": {
- "type": "string",
- "default": CHEF_FB_PATH,
- "description": dedent(
- """\
- Specifies the location in which some chef json data is
- stored. By default, it uses the
- ``{}`` location.""".format(
- CHEF_FB_PATH
- )
- ),
- },
- "log_level": {
- "type": "string",
- "default": CHEF_RB_TPL_DEFAULTS["log_level"],
- "description": dedent(
- """\
- Defines the level of logging to be stored in the log
- file. By default this value is set to ``{}``.
- """.format(
- CHEF_RB_TPL_DEFAULTS["log_level"]
- )
- ),
- },
- "log_location": {
- "type": "string",
- "default": CHEF_RB_TPL_DEFAULTS["log_location"],
- "description": dedent(
- """\
- Specifies the location of the chef lof file. By
- default, the location is specified at
- ``{}``.""".format(
- CHEF_RB_TPL_DEFAULTS["log_location"]
- )
- ),
- },
- "node_name": {
- "type": "string",
- "description": dedent(
- """\
- The name of the node to run. By default, we will
- use th instance id as the node name."""
- ),
- },
- "omnibus_url": {
- "type": "string",
- "default": OMNIBUS_URL,
- "description": dedent(
- """\
- Omnibus URL if chef should be installed through
- Omnibus. By default, it uses the
- ``{}``.""".format(
- OMNIBUS_URL
- )
- ),
- },
- "omnibus_url_retries": {
- "type": "integer",
- "default": OMNIBUS_URL_RETRIES,
- "description": dedent(
- """\
- The number of retries that will be attempted to reach
- the Omnibus URL"""
- ),
- },
- "omnibus_version": {
- "type": "string",
- "description": dedent(
- """\
- Optional version string to require for omnibus
- install."""
- ),
- },
- "pid_file": {
- "type": "string",
- "default": CHEF_RB_TPL_DEFAULTS["pid_file"],
- "description": dedent(
- """\
- The location in which a process identification
- number (pid) is saved. By default, it saves
- in the ``{}`` location.""".format(
- CHEF_RB_TPL_DEFAULTS["pid_file"]
- )
- ),
- },
- "server_url": {
- "type": "string",
- "description": "The URL for the chef server",
- },
- "show_time": {
- "type": "boolean",
- "default": True,
- "description": "Show time in chef logs",
- },
- "ssl_verify_mode": {
- "type": "string",
- "default": CHEF_RB_TPL_DEFAULTS["ssl_verify_mode"],
- "description": dedent(
- """\
- Set the verify mode for HTTPS requests. We can have
- two possible values for this parameter:
-
- - ``:verify_none``: No validation of SSL \
- certificates.
- - ``:verify_peer``: Validate all SSL certificates.
-
- By default, the parameter is set as ``{}``.
- """.format(
- CHEF_RB_TPL_DEFAULTS["ssl_verify_mode"]
- )
- ),
- },
- "validation_name": {
- "type": "string",
- "description": dedent(
- """\
- The name of the chef-validator key that Chef Infra
- Client uses to access the Chef Infra Server during
- the initial Chef Infra Client run."""
- ),
- },
- "force_install": {
- "type": "boolean",
- "default": False,
- "description": dedent(
- """\
- If set to ``True``, forces chef installation, even
- if it is already installed."""
- ),
- },
- "initial_attributes": {
- "type": "object",
- "items": {"type": "string"},
- "description": dedent(
- """\
- Specify a list of initial attributes used by the
- cookbooks."""
- ),
- },
- "install_type": {
- "type": "string",
- "default": "packages",
- "description": dedent(
- """\
- The type of installation for chef. It can be one of
- the following values:
-
- - ``packages``
- - ``gems``
- - ``omnibus``"""
- ),
- },
- "run_list": {
- "type": "array",
- "items": {"type": "string"},
- "description": "A run list for a first boot json.",
- },
- "chef_license": {
- "type": "string",
- "description": dedent(
- """\
- string that indicates if user accepts or not license
- related to some of chef products"""
- ),
- },
- },
- }
- },
-}
-
-__doc__ = get_meta_doc(meta, schema)
+__doc__ = get_meta_doc(meta)
def post_run_chef(chef_cfg, log):
@@ -489,7 +193,6 @@ def handle(name, cfg, cloud, log, _args):
)
return
- validate_cloudconfig_schema(cfg, schema)
chef_cfg = cfg["chef"]
# Ensure the chef directories we use exist