diff --git a/cloudinit/config/cc_apk_configure.py b/cloudinit/config/cc_apk_configure.py index d3cfd091c16a..26befb20df89 100644 --- a/cloudinit/config/cc_apk_configure.py +++ b/cloudinit/config/cc_apk_configure.py @@ -12,7 +12,7 @@ from cloudinit import temp_utils, templater, util from cloudinit.cloud import Cloud from cloudinit.config import Config -from cloudinit.config.schema import MetaSchema, get_meta_doc +from cloudinit.config.schema import MetaSchema from cloudinit.settings import PER_INSTANCE LOG = logging.getLogger(__name__) @@ -52,61 +52,13 @@ """ - -frequency = PER_INSTANCE -distros = ["alpine"] meta: MetaSchema = { "id": "cc_apk_configure", - "name": "APK Configure", - "title": "Configure apk repositories file", - "description": dedent( - """\ - This module handles configuration of the /etc/apk/repositories file. - - .. note:: - To ensure that apk configuration is valid yaml, any strings - containing special characters, especially ``:`` should be quoted. - """ - ), - "distros": distros, - "examples": [ - dedent( - """\ - # Keep the existing /etc/apk/repositories file unaltered. - apk_repos: - preserve_repositories: true - """ - ), - dedent( - """\ - # Create repositories file for Alpine v3.12 main and community - # using default mirror site. - apk_repos: - alpine_repo: - community_enabled: true - version: 'v3.12' - """ - ), - dedent( - """\ - # Create repositories file for Alpine Edge main, community, and - # testing using a specified mirror site and also a local repo. - apk_repos: - alpine_repo: - base_url: 'https://some-alpine-mirror/alpine' - community_enabled: true - testing_enabled: true - version: 'edge' - local_repo_base_url: 'https://my-local-server/local-alpine' - """ - ), - ], - "frequency": frequency, + "distros": ["alpine"], + "frequency": PER_INSTANCE, "activate_by_schema_keys": ["apk_repos"], } -__doc__ = get_meta_doc(meta) - def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None: """ diff --git a/cloudinit/config/cc_apt_pipelining.py b/cloudinit/config/cc_apt_pipelining.py index 0dbf90311fc2..c068a306b78e 100644 --- a/cloudinit/config/cc_apt_pipelining.py +++ b/cloudinit/config/cc_apt_pipelining.py @@ -12,13 +12,11 @@ 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.config.schema import MetaSchema from cloudinit.settings import PER_INSTANCE LOG = logging.getLogger(__name__) -frequency = PER_INSTANCE -distros = ["ubuntu", "debian"] DEFAULT_FILE = "/etc/apt/apt.conf.d/90cloud-init-pipelining" APT_PIPE_TPL = ( "//Written by cloud-init per 'apt_pipelining'\n" @@ -31,33 +29,11 @@ meta: MetaSchema = { "id": "cc_apt_pipelining", - "name": "Apt Pipelining", - "title": "Configure apt pipelining", - "description": dedent( - """\ - This module configures apt's ``Acquire::http::Pipeline-Depth`` option, - which controls how apt handles HTTP pipelining. It may be useful for - pipelining to be disabled, because some web servers, such as S3 do not - pipeline properly (LP: #948461). - - Value configuration options for this module are: - - * ``os``: (Default) use distro default - * ``false`` disable pipelining altogether - * ````: Manually specify pipeline depth. This is not recommended.""" # noqa: E501 - ), - "distros": distros, - "frequency": frequency, - "examples": [ - "apt_pipelining: false", - "apt_pipelining: os", - "apt_pipelining: 3", - ], + "distros": ["ubuntu", "debian"], + "frequency": PER_INSTANCE, "activate_by_schema_keys": ["apt_pipelining"], } -__doc__ = get_meta_doc(meta) - def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None: apt_pipe_value = cfg.get("apt_pipelining", "os") diff --git a/cloudinit/config/schemas/schema-cloud-config-v1.json b/cloudinit/config/schemas/schema-cloud-config-v1.json index 12146bc12d87..ba74fe78af1c 100644 --- a/cloudinit/config/schemas/schema-cloud-config-v1.json +++ b/cloudinit/config/schemas/schema-cloud-config-v1.json @@ -897,7 +897,7 @@ "preserve_repositories": { "type": "boolean", "default": false, - "description": "By default, cloud-init will generate a new repositories file ``/etc/apk/repositories`` based on any valid configuration settings specified within a apk_repos section of cloud config. To disable this behavior and preserve the repositories file from the pristine image, set ``preserve_repositories`` to ``true``.\n\n The ``preserve_repositories`` option overrides all other config keys that would alter ``/etc/apk/repositories``." + "description": "By default, cloud-init will generate a new repositories file ``/etc/apk/repositories`` based on any valid configuration settings specified within a apk_repos section of cloud config. To disable this behavior and preserve the repositories file from the pristine image, set ``preserve_repositories`` to ``true``. The ``preserve_repositories`` option overrides all other config keys that would alter ``/etc/apk/repositories``." }, "alpine_repo": { "type": [ diff --git a/doc/module-docs/cc_apk_configure/data.yaml b/doc/module-docs/cc_apk_configure/data.yaml new file mode 100644 index 000000000000..aec5b290baf0 --- /dev/null +++ b/doc/module-docs/cc_apk_configure/data.yaml @@ -0,0 +1,16 @@ +cc_apk_configure: + name: APK Configure + title: Configure apk repositories file + description: | + This module handles configuration of the /etc/apk/repositories file. + + .. note:: + To ensure that apk configuration is valid yaml, any strings + containing special characters, especially ``:`` should be quoted. + examples: + - comment: Keep the existing /etc/apk/repositories file unaltered. + file: ../../module-docs/cc_apk_configure/example1.yaml + - comment: Create repositories file for Alpine v3.12 main and community using default mirror site. + file: ../../module-docs/cc_apk_configure/example2.yaml + - comment: Create repositories file for Alpine Edge main, community, and testing using a specified mirror site and also a local repo. + file: ../../module-docs/cc_apk_configure/example3.yaml diff --git a/doc/module-docs/cc_apk_configure/example1.yaml b/doc/module-docs/cc_apk_configure/example1.yaml new file mode 100644 index 000000000000..b680c9fe0b0f --- /dev/null +++ b/doc/module-docs/cc_apk_configure/example1.yaml @@ -0,0 +1,3 @@ +#cloud-config +apk_repos: + preserve_repositories: true diff --git a/doc/module-docs/cc_apk_configure/example2.yaml b/doc/module-docs/cc_apk_configure/example2.yaml new file mode 100644 index 000000000000..7ab1c58bc31f --- /dev/null +++ b/doc/module-docs/cc_apk_configure/example2.yaml @@ -0,0 +1,5 @@ +#cloud-config +apk_repos: + alpine_repo: + community_enabled: true + version: 'v3.12' diff --git a/doc/module-docs/cc_apk_configure/example3.yaml b/doc/module-docs/cc_apk_configure/example3.yaml new file mode 100644 index 000000000000..d2496f1b0a2f --- /dev/null +++ b/doc/module-docs/cc_apk_configure/example3.yaml @@ -0,0 +1,8 @@ +#cloud-config +apk_repos: + alpine_repo: + base_url: https://some-alpine-mirror/alpine + community_enabled: true + testing_enabled: true + version: edge + local_repo_base_url: https://my-local-server/local-alpine diff --git a/doc/module-docs/cc_apt_pipelining/data.yaml b/doc/module-docs/cc_apt_pipelining/data.yaml new file mode 100644 index 000000000000..416ba0b564fe --- /dev/null +++ b/doc/module-docs/cc_apt_pipelining/data.yaml @@ -0,0 +1,21 @@ +cc_apt_pipelining: + name: Apt Pipelining + title: Configure apt pipelining + description: | + This module configures apt's ``Acquite::http::Pipeline-Depth`` option, + which controls how apt handles HTTP pipelining. It may be useful for + pipelining to be disabled, because some web servers, such as S3 do not + pipeline properly (LP: #948461). + + Value configuration options for this module are: + + * ``os``: (Default) use distro default + * ``false`` disable pipelining altogether + * ````: Manually specify pipeline depth. This is not recommended. + examples: + - comment: "" + file: ../../module-docs/cc_apt_pipelining/example1.yaml + - comment: "" + file: ../../module-docs/cc_apt_pipelining/example2.yaml + - comment: "" + file: ../../module-docs/cc_apt_pipelining/example3.yaml diff --git a/doc/module-docs/cc_apt_pipelining/example1.yaml b/doc/module-docs/cc_apt_pipelining/example1.yaml new file mode 100644 index 000000000000..758cf60f6a51 --- /dev/null +++ b/doc/module-docs/cc_apt_pipelining/example1.yaml @@ -0,0 +1,2 @@ +#cloud-config +apt_pipelining: false diff --git a/doc/module-docs/cc_apt_pipelining/example2.yaml b/doc/module-docs/cc_apt_pipelining/example2.yaml new file mode 100644 index 000000000000..1890fe19634b --- /dev/null +++ b/doc/module-docs/cc_apt_pipelining/example2.yaml @@ -0,0 +1,2 @@ +#cloud-config +apt_pipelining: os diff --git a/doc/module-docs/cc_apt_pipelining/example3.yaml b/doc/module-docs/cc_apt_pipelining/example3.yaml new file mode 100644 index 000000000000..b4677a04c9c3 --- /dev/null +++ b/doc/module-docs/cc_apt_pipelining/example3.yaml @@ -0,0 +1,2 @@ +#cloud-config +apt_pipelining: 3 diff --git a/doc/rtd/reference/modules.rst b/doc/rtd/reference/modules.rst index f26accaf1599..792494f629f6 100644 --- a/doc/rtd/reference/modules.rst +++ b/doc/rtd/reference/modules.rst @@ -19,11 +19,11 @@ date. A 5 year timeline may also be expected for changed keys. .. datatemplate:yaml:: ../../module-docs/cc_ansible/data.yaml :template: modules.tmpl - - -.. automodule:: cloudinit.config.cc_apk_configure +.. datatemplate:yaml:: ../../module-docs/cc_apk_configure/data.yaml + :template: modules.tmpl .. automodule:: cloudinit.config.cc_apt_configure -.. automodule:: cloudinit.config.cc_apt_pipelining +.. datatemplate:yaml:: ../../module-docs/cc_apt_pipelining/data.yaml + :template: modules.tmpl .. automodule:: cloudinit.config.cc_bootcmd .. automodule:: cloudinit.config.cc_byobu .. automodule:: cloudinit.config.cc_ca_certs