Skip to content

Commit

Permalink
chore(doc): migrate cc modules i through r to templates (canonical#5313)
Browse files Browse the repository at this point in the history
Modules migrated:
install_hotplug, keyboard, _keys_to_console, landscape, locale, lxd,
cc_mcollective, cc_mounts, ntp, package_update_upgrade_install,
phone_home, power_state_change, puppet, resizefs, resolv_conf,
rh_subscription
  • Loading branch information
blackboxsw committed Jun 19, 2024
1 parent 0976b43 commit f9352b9
Show file tree
Hide file tree
Showing 69 changed files with 841 additions and 961 deletions.
42 changes: 2 additions & 40 deletions cloudinit/config/cc_install_hotplug.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,23 @@
"""Install hotplug udev rules if supported and enabled"""
import logging
import os
from textwrap import dedent

from cloudinit import stages, subp, 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.distros import ALL_DISTROS
from cloudinit.event import EventScope, EventType
from cloudinit.settings import PER_INSTANCE
from cloudinit.sources import DataSource

meta: MetaSchema = {
"id": "cc_install_hotplug",
"name": "Install Hotplug",
"title": "Install hotplug udev rules if supported and enabled",
"description": dedent(
"""\
This module will install the udev rules to enable hotplug if
supported by the datasource and enabled in the userdata. The udev
rules will be installed as
``/etc/udev/rules.d/90-cloud-init-hook-hotplug.rules``.
When hotplug is enabled, newly added network devices will be added
to the system by cloud-init. After udev detects the event,
cloud-init will refresh the instance metadata from the datasource,
detect the device in the updated metadata, then apply the updated
network configuration.
Currently supported datasources: Openstack, EC2
"""
),
"distros": [ALL_DISTROS],
"frequency": PER_INSTANCE,
"examples": [
dedent(
"""\
# Enable hotplug of network devices
updates:
network:
when: ["hotplug"]
"""
),
dedent(
"""\
# Enable network hotplug alongside boot event
updates:
network:
when: ["boot", "hotplug"]
"""
),
],
"activate_by_schema_keys": [],
}
} # type: ignore

__doc__ = get_meta_doc(meta)
LOG = logging.getLogger(__name__)


Expand Down
38 changes: 2 additions & 36 deletions cloudinit/config/cc_keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
"""keyboard: set keyboard layout"""

import logging
from textwrap import dedent

from cloudinit import distros
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

# FIXME: setting keyboard layout should be supported by all OSes.
Expand All @@ -27,45 +26,12 @@

meta: MetaSchema = {
"id": "cc_keyboard",
"name": "Keyboard",
"title": "Set keyboard layout",
"description": "Handle keyboard configuration.",
"distros": supported_distros,
"examples": [
dedent(
"""\
# Set keyboard layout to "us"
keyboard:
layout: us
"""
),
dedent(
"""\
# Set specific keyboard layout, model, variant, options
keyboard:
layout: de
model: pc105
variant: nodeadkeys
options: compose:rwin
"""
),
dedent(
"""\
# For Alpine Linux set specific keyboard layout and variant,
# as used by setup-keymap. Model and options are ignored.
keyboard:
layout: gb
variant: gb-extd
"""
),
],
"frequency": PER_INSTANCE,
"activate_by_schema_keys": ["keyboard"],
}
} # type: ignore


__doc__ = get_meta_doc(meta)

LOG = logging.getLogger(__name__)


Expand Down
47 changes: 3 additions & 44 deletions cloudinit/config/cc_keys_to_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,63 +10,22 @@

import logging
import os
from textwrap import dedent

from cloudinit import subp, 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

# This is a tool that cloud init provides
HELPER_TOOL_TPL = "%s/cloud-init/write-ssh-key-fingerprints"

distros = ["all"]

meta: MetaSchema = {
"id": "cc_keys_to_console",
"name": "Keys to Console",
"title": "Control which SSH host keys may be written to console",
"description": (
"For security reasons it may be desirable not to write SSH host keys"
" and their fingerprints to the console. To avoid either being written"
" to the console the ``emit_keys_to_console`` config key under the"
" main ``ssh`` config key can be used. To avoid the fingerprint of"
" types of SSH host keys being written to console the"
" ``ssh_fp_console_blacklist`` config key can be used. By default,"
" all types of keys will have their fingerprints written to console."
" To avoid host keys of a key type being written to console the"
"``ssh_key_console_blacklist`` config key can be used. By default"
" all supported host keys are written to console."
),
"distros": distros,
"examples": [
dedent(
"""\
# Do not print any SSH keys to system console
ssh:
emit_keys_to_console: false
"""
),
dedent(
"""\
# Do not print certain ssh key types to console
ssh_key_console_blacklist: [rsa]
"""
),
dedent(
"""\
# Do not print specific ssh key fingerprints to console
ssh_fp_console_blacklist:
- E25451E0221B5773DEBFF178ECDACB160995AA89
- FE76292D55E8B28EE6DB2B34B2D8A784F8C0AAB0
"""
),
],
"distros": ["all"],
"frequency": PER_INSTANCE,
"activate_by_schema_keys": [],
}
__doc__ = get_meta_doc(meta)
} # type: ignore

LOG = logging.getLogger(__name__)

Expand Down
78 changes: 3 additions & 75 deletions cloudinit/config/cc_landscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@

import logging
from itertools import chain
from textwrap import dedent

from configobj import ConfigObj

from cloudinit import subp, type_utils, 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

LSC_CLIENT_CFG_FILE = "/etc/landscape/client.conf"
Expand All @@ -33,84 +32,13 @@
}
}

MODULE_DESCRIPTION = """\
This module installs and configures ``landscape-client``. The landscape client
will only be installed if the key ``landscape`` is present in config. Landscape
client configuration is given under the ``client`` key under the main
``landscape`` config key. The config parameters are not interpreted by
cloud-init, but rather are converted into a ConfigObj formatted file and
written out to the `[client]` section in ``/etc/landscape/client.conf``.
The following default client config is provided, but can be overridden::
landscape:
client:
log_level: "info"
url: "https://landscape.canonical.com/message-system"
ping_url: "http://landscape.canoncial.com/ping"
data_path: "/var/lib/landscape/client"
.. note::
see landscape documentation for client config keys
.. note::
if ``tags`` is defined, its contents should be a string delimited with
``,`` rather than a list
"""
distros = ["ubuntu"]

meta: MetaSchema = {
"id": "cc_landscape",
"name": "Landscape",
"title": "Install and configure landscape client",
"description": MODULE_DESCRIPTION,
"distros": distros,
"examples": [
dedent(
"""\
# To discover additional supported client keys, run
# man landscape-config.
landscape:
client:
url: "https://landscape.canonical.com/message-system"
ping_url: "http://landscape.canonical.com/ping"
data_path: "/var/lib/landscape/client"
http_proxy: "http://my.proxy.com/foobar"
https_proxy: "https://my.proxy.com/foobar"
tags: "server,cloud"
computer_title: "footitle"
registration_key: "fookey"
account_name: "fooaccount"
"""
),
dedent(
"""\
# Minimum viable config requires account_name and computer_title
landscape:
client:
computer_title: kiosk 1
account_name: Joe's Biz
"""
),
dedent(
"""\
# To install landscape-client from a PPA, specify apt.sources
apt:
sources:
trunk-testing-ppa:
source: ppa:landscape/self-hosted-beta
landscape:
client:
account_name: myaccount
computer_title: himom
"""
),
],
"distros": ["ubuntu"],
"frequency": PER_INSTANCE,
"activate_by_schema_keys": ["landscape"],
}
} # type: ignore

__doc__ = get_meta_doc(meta)
LOG = logging.getLogger(__name__)


Expand Down
32 changes: 3 additions & 29 deletions cloudinit/config/cc_locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,20 @@
"""Locale: set system locale"""

import logging
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.config.schema import MetaSchema
from cloudinit.settings import PER_INSTANCE

distros = ["all"]

meta: MetaSchema = {
"id": "cc_locale",
"name": "Locale",
"title": "Set system locale",
"description": dedent(
"""\
Configure the system locale and apply it system wide. By default use
the locale specified by the datasource."""
),
"distros": distros,
"examples": [
dedent(
"""\
# Set the locale to ar_AE
locale: ar_AE
"""
),
dedent(
"""\
# Set the locale to fr_CA in /etc/alternate_path/locale
locale: fr_CA
locale_configfile: /etc/alternate_path/locale
"""
),
],
"distros": ["all"],
"frequency": PER_INSTANCE,
"activate_by_schema_keys": [],
}
} # type: ignore

__doc__ = get_meta_doc(meta)
LOG = logging.getLogger(__name__)


Expand Down
Loading

0 comments on commit f9352b9

Please sign in to comment.