Skip to content

Commit

Permalink
doc apt/apk
Browse files Browse the repository at this point in the history
  • Loading branch information
blackboxsw committed May 9, 2024
1 parent c3ed704 commit 5efafc2
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 83 deletions.
54 changes: 3 additions & 51 deletions cloudinit/config/cc_apk_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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:
"""
Expand Down
30 changes: 3 additions & 27 deletions cloudinit/config/cc_apt_pipelining.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
* ``<number>``: 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")
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/config/schemas/schema-cloud-config-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
16 changes: 16 additions & 0 deletions doc/module-docs/cc_apk_configure/data.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions doc/module-docs/cc_apk_configure/example1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#cloud-config
apk_repos:
preserve_repositories: true
5 changes: 5 additions & 0 deletions doc/module-docs/cc_apk_configure/example2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#cloud-config
apk_repos:
alpine_repo:
community_enabled: true
version: 'v3.12'
8 changes: 8 additions & 0 deletions doc/module-docs/cc_apk_configure/example3.yaml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions doc/module-docs/cc_apt_pipelining/data.yaml
Original file line number Diff line number Diff line change
@@ -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
* ``<number>``: 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
2 changes: 2 additions & 0 deletions doc/module-docs/cc_apt_pipelining/example1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#cloud-config
apt_pipelining: false
2 changes: 2 additions & 0 deletions doc/module-docs/cc_apt_pipelining/example2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#cloud-config
apt_pipelining: os
2 changes: 2 additions & 0 deletions doc/module-docs/cc_apt_pipelining/example3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#cloud-config
apt_pipelining: 3
8 changes: 4 additions & 4 deletions doc/rtd/reference/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5efafc2

Please sign in to comment.