diff options
author | Scott Moser <smoser@brickies.net> | 2016-11-04 13:46:09 -0400 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2016-11-04 13:46:09 -0400 |
commit | b380e16183446f2e39f47a3c0804d2081714acb2 (patch) | |
tree | a5e05b4a22553769d6eaa7e5fa93e3401a758b2b /doc/rtd | |
parent | 882b22e024733e17757fdbe36ba2a3672c6ebe06 (diff) | |
parent | a1cdebdea65ccd827060c823146992bba9debe19 (diff) | |
download | vyos-cloud-init-b380e16183446f2e39f47a3c0804d2081714acb2.tar.gz vyos-cloud-init-b380e16183446f2e39f47a3c0804d2081714acb2.zip |
merge from master at 0.7.8-34-ga1cdebd
Diffstat (limited to 'doc/rtd')
-rw-r--r-- | doc/rtd/conf.py | 2 | ||||
-rw-r--r-- | doc/rtd/index.rst | 1 | ||||
-rw-r--r-- | doc/rtd/topics/datasources.rst | 48 | ||||
-rw-r--r-- | doc/rtd/topics/dir_layout.rst | 4 | ||||
-rw-r--r-- | doc/rtd/topics/examples.rst | 52 | ||||
-rw-r--r-- | doc/rtd/topics/format.rst | 12 | ||||
-rw-r--r-- | doc/rtd/topics/logging.rst | 175 | ||||
-rw-r--r-- | doc/rtd/topics/modules.rst | 297 | ||||
-rw-r--r-- | doc/rtd/topics/moreinfo.rst | 6 |
9 files changed, 254 insertions, 343 deletions
diff --git a/doc/rtd/conf.py b/doc/rtd/conf.py index 8a391f21..66b3b654 100644 --- a/doc/rtd/conf.py +++ b/doc/rtd/conf.py @@ -48,7 +48,7 @@ version = version.version_string() release = version # Set the default Pygments syntax -highlight_language = 'python' +highlight_language = 'yaml' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. diff --git a/doc/rtd/index.rst b/doc/rtd/index.rst index fe04b1a9..f8ff3c9f 100644 --- a/doc/rtd/index.rst +++ b/doc/rtd/index.rst @@ -23,6 +23,7 @@ Summary topics/dir_layout topics/examples topics/datasources + topics/logging topics/modules topics/merging topics/moreinfo diff --git a/doc/rtd/topics/datasources.rst b/doc/rtd/topics/datasources.rst index 0d7d4aca..3a9c808c 100644 --- a/doc/rtd/topics/datasources.rst +++ b/doc/rtd/topics/datasources.rst @@ -1,11 +1,11 @@ .. _datasources: -========= +=========== Datasources -========= ----------- +=========== +---------------------- What is a datasource? ----------- +---------------------- Datasources are sources of configuration data for cloud-init that typically come from the user (aka userdata) or come from the stack that created the configuration @@ -70,9 +70,9 @@ The current interface that a datasource object must provide is the following: def get_package_mirror_info(self) ---------------------------- +--- EC2 ---------------------------- +--- The EC2 datasource is the oldest and most widely used datasource that cloud-init supports. This datasource interacts with a *magic* ip that is provided to the @@ -130,61 +130,61 @@ To see which versions are supported from your cloud provider use the following U ... latest ---------------------------- +------------ Config Drive ---------------------------- +------------ .. include:: ../../sources/configdrive/README.rst ---------------------------- +---------- OpenNebula ---------------------------- +---------- .. include:: ../../sources/opennebula/README.rst ---------------------------- +--------- Alt cloud ---------------------------- +--------- .. include:: ../../sources/altcloud/README.rst ---------------------------- +-------- No cloud ---------------------------- +-------- .. include:: ../../sources/nocloud/README.rst ---------------------------- +---- MAAS ---------------------------- +---- *TODO* For now see: http://maas.ubuntu.com/ ---------------------------- +---------- CloudStack ---------------------------- +---------- .. include:: ../../sources/cloudstack/README.rst ---------------------------- +--- OVF ---------------------------- +--- *TODO* For now see: https://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/files/head:/doc/sources/ovf/ ---------------------------- +--------- OpenStack ---------------------------- +--------- .. include:: ../../sources/openstack/README.rst ---------------------------- +------------- Fallback/None ---------------------------- +------------- This is the fallback datasource when no other datasource can be selected. It is the equivalent of a *empty* datasource in that it provides a empty string as userdata diff --git a/doc/rtd/topics/dir_layout.rst b/doc/rtd/topics/dir_layout.rst index 8815d33d..6dcb22ce 100644 --- a/doc/rtd/topics/dir_layout.rst +++ b/doc/rtd/topics/dir_layout.rst @@ -1,6 +1,6 @@ -========= +================ Directory layout -========= +================ Cloudinits's directory structure is somewhat different from a regular application:: diff --git a/doc/rtd/topics/examples.rst b/doc/rtd/topics/examples.rst index 36508bde..2e6cfa1e 100644 --- a/doc/rtd/topics/examples.rst +++ b/doc/rtd/topics/examples.rst @@ -1,11 +1,11 @@ .. _yaml_examples: -========= +===================== Cloud config examples -========= +===================== Including users and groups ---------------------------- +-------------------------- .. literalinclude:: ../../examples/cloud-config-user-groups.txt :language: yaml @@ -21,21 +21,21 @@ Writing out arbitrary files Adding a yum repository ---------------------------- +----------------------- .. literalinclude:: ../../examples/cloud-config-yum-repo.txt :language: yaml :linenos: Configure an instances trusted CA certificates ------------------------------------------------------- +---------------------------------------------- .. literalinclude:: ../../examples/cloud-config-ca-certs.txt :language: yaml :linenos: Configure an instances resolv.conf ------------------------------------------------------- +---------------------------------- *Note:* when using a config drive and a RHEL like system resolv.conf will also be managed 'automatically' due to the available information @@ -47,28 +47,28 @@ that wish to have different settings use this module. :linenos: Install and run `chef`_ recipes ------------------------------------------------------- +------------------------------- .. literalinclude:: ../../examples/cloud-config-chef.txt :language: yaml :linenos: Setup and run `puppet`_ ------------------------------------------------------- +----------------------- .. literalinclude:: ../../examples/cloud-config-puppet.txt :language: yaml :linenos: Add apt repositories ---------------------------- +-------------------- .. literalinclude:: ../../examples/cloud-config-add-apt-repos.txt :language: yaml :linenos: Run commands on first boot ---------------------------- +-------------------------- .. literalinclude:: ../../examples/cloud-config-boot-cmds.txt :language: yaml @@ -80,21 +80,21 @@ Run commands on first boot Alter the completion message ---------------------------- +---------------------------- .. literalinclude:: ../../examples/cloud-config-final-message.txt :language: yaml :linenos: Install arbitrary packages ---------------------------- +-------------------------- .. literalinclude:: ../../examples/cloud-config-install-packages.txt :language: yaml :linenos: Run apt or yum upgrade ---------------------------- +---------------------- .. literalinclude:: ../../examples/cloud-config-update-packages.txt :language: yaml @@ -108,26 +108,46 @@ Adjust mount points mounted :linenos: Call a url when finished ---------------------------- +------------------------ .. literalinclude:: ../../examples/cloud-config-phone-home.txt :language: yaml :linenos: Reboot/poweroff when finished ---------------------------- +----------------------------- .. literalinclude:: ../../examples/cloud-config-power-state.txt :language: yaml :linenos: Configure instances ssh-keys ---------------------------- +---------------------------- .. literalinclude:: ../../examples/cloud-config-ssh-keys.txt :language: yaml :linenos: +Additional apt configuration +---------------------------- + +.. literalinclude:: ../../examples/cloud-config-apt.txt + :language: yaml + :linenos: + +Disk setup +---------- + +.. literalinclude:: ../../examples/cloud-config-disk-setup.txt + :language: yaml + :linenos: + +Register RedHat Subscription +---------------------------- + +.. literalinclude:: ../../examples/cloud-config-rh_subscription.txt + :language: yaml + :linenos: .. _chef: http://www.opscode.com/chef/ .. _puppet: http://puppetlabs.com/ diff --git a/doc/rtd/topics/format.rst b/doc/rtd/topics/format.rst index eba9533f..1dd92309 100644 --- a/doc/rtd/topics/format.rst +++ b/doc/rtd/topics/format.rst @@ -1,18 +1,18 @@ -========= +======= Formats -========= +======= User data that will be acted upon by cloud-init must be in one of the following types. Gzip Compressed Content ------------------------- +----------------------- Content found to be gzip compressed will be uncompressed. The uncompressed data will then be used as if it were not compressed. This is typically is useful because user-data is limited to ~16384 [#]_ bytes. Mime Multi Part Archive ------------------------- +----------------------- This list of rules is applied to each part of this multi-part file. Using a mime-multi part file, the user can specify more than one type of data. @@ -31,7 +31,7 @@ Supported content-types: - text/cloud-boothook Helper script to generate mime messages -~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: python @@ -59,7 +59,7 @@ Helper script to generate mime messages User-Data Script ------------------------- +---------------- Typically used by those who just want to execute a shell script. diff --git a/doc/rtd/topics/logging.rst b/doc/rtd/topics/logging.rst new file mode 100644 index 00000000..b010aa96 --- /dev/null +++ b/doc/rtd/topics/logging.rst @@ -0,0 +1,175 @@ +======= +Logging +======= +Cloud-init supports both local and remote logging configurable through python's +built-in logging configuration and through the cloud-init rsyslog module. + +Command Output +-------------- +Cloud-init can redirect its stdout and stderr based on config given under the +``output`` config key. The output of any commands run by cloud-init and any +user or vendor scripts provided will also be included here. The ``output`` +key accepts a dictionary for configuration. Output files may be specified +individually for each stage (``init``, ``config``, and ``final``), or a single +key ``all`` may be used to specify output for all stages. + +The output for each stage may be specified as a dictionary of ``output`` and +``error`` keys, for stdout and stderr respectively, as a tuple with stdout +first and stderr second, or as a single string to use for both. The strings +passed to all of these keys are handled by the system shell, so any form of +redirection that can be used in bash is valid, including piping cloud-init's +output to ``tee``, or ``logger``. If only a filename is provided, cloud-init +will append its output to the file as though ``>>`` was specified. + +By default, cloud-init loads its output configuration from +``/etc/cloud/coud.cfg.d/05_logging.cfg``. The default config directs both +stdout and stderr from all cloud-init stages to +``/var/log/cloud-init-output.log``. The default config is given as :: + + output: { all: "| tee -a /var/log/cloud-init-output.log" } + +For a more complex example, the following configuration would output the init +stage to ``/var/log/cloud-init.out`` and ``/var/log/cloud-init.err``, for +stdout and stderr respectively, replacing anything that was previously there. +For the config stage, it would pipe both stdout and stderr through +``tee -a /var/log/cloud-config.log``. For the final stage it would append the +output of stdout and stderr to ``/var/log/cloud-final.out`` and +``/var/log/cloud-final.err`` respectively. :: + + output: + init: + output: "> /var/log/cloud-init.out" + error: "> /var/log/cloud-init.err" + config: "tee -a /var/log/cloud-config.log" + final: + - ">> /var/log/cloud-final.out" + - "/var/log/cloud-final.err" + +Python Logging +-------------- +Cloud-init uses the python logging module, and can accept config for this +module using the standard python fileConfig format. Cloud-init looks for config +for the logging module under the ``logcfg`` key. + +.. note:: + the logging configuration is not yaml, it is python ``fileConfig`` format, + and is passed through directly to the python logging module. please use the + correct syntax for a multi-line string in yaml. + +By default, cloud-init uses the logging configuration provided in +``/etc/cloud/cloud.cfg.d/05_logging.cfg``. The default python logging +configuration writes all cloud-init events with a priority of ``WARNING`` or +higher to console, and writes all events with a level of ``DEBUG`` or higher +to ``/var/log/cloud-init.log`` and via syslog. + +Python's fileConfig format consists of sections with headings in the format +``[title]`` and key value pairs in each section. Configuration for python +logging must contain the sections ``[loggers]``, ``[handlers]``, and +``[formatters]``, which name the entities of their respective types that will +be defined. The section name for each defined logger, handler and formatter +will start with its type, followed by an underscore (``_``) and the name of the +entity. For example, if a logger was specified with the name ``log01``, config +for the logger would be in the section ``[logger_log01]``. + +Logger config entries contain basic logging set up. They may specify a list of +handlers to send logging events to as well as the lowest priority level of +events to handle. A logger named ``root`` must be specified and its +configuration (under ``[logger_root]``) must contain a level and a list of +handlers. A level entry can be any of the following: ``DEBUG``, ``INFO``, +``WARNING``, ``ERROR``, ``CRITICAL``, or ``NOTSET``. For the ``root`` logger +the ``NOTSET`` option will allow all logging events to be recorded. + +Each configured handler must specify a class under the python's ``logging`` +package namespace. A handler may specify a message formatter to use, a priority +level, and arguments for the handler class. Common handlers are +``StreamHandler``, which handles stream redirects (i.e. logging to stderr), +and ``FileHandler`` which outputs to a log file. The logging module also +supports logging over net sockets, over http, via smtp, and additional +complex configurations. For full details about the handlers available for +python logging, please see the documentation for `python logging handlers`_. + +Log messages are formatted using the ``logging.Formatter`` class, which is +configured using ``formatter`` config entities. A default format of +``%(message)s`` is given if no formatter configs are specified. Formatter +config entities accept a format string which supports variable replacements. +These may also accept a ``datefmt`` string which may be used to configure the +timestamp used in the log messages. The format variables ``%(asctime)s``, +``%(levelname)s`` and ``%(message)s`` are commonly used and represent the +timestamp, the priority level of the event and the event message. For +additional information on logging formatters see `python logging formatters`_. + +.. note:: + by default the format string used in the logging formatter are in python's + old style ``%s`` form. the ``str.format()`` and ``string.Template`` styles + can also be used by using ``{`` or ``$`` in place of ``%`` by setting the + ``style`` parameter in formatter config. + +A simple, but functional python logging configuration for cloud-init is below. +It will log all messages of priority ``DEBUG`` or higher both stderr and +``/tmp/my.log`` using a ``StreamHandler`` and a ``FileHandler``, using +the default format string ``%(message)s``:: + + logcfg: | + [loggers] + keys=root,cloudinit + [handlers] + keys=ch,cf + [formatters] + keys= + [logger_root] + level=DEBUG + handlers= + [logger_cloudinit] + level=DEBUG + qualname=cloudinit + handlers=ch,cf + [handler_ch] + class=StreamHandler + level=DEBUG + args=(sys.stderr,) + [handler_cf] + class=FileHandler + level=DEBUG + args=('/tmp/my.log',) + +For additional information about configuring python's logging module, please +see the documentation for `python logging config`_. + +Rsyslog Module +-------------- +Cloud-init's ``cc_rsyslog`` module allows for fully customizable rsyslog +configuration under the ``rsyslog`` config key. The simplest way to +use the rsyslog module is by specifying remote servers under the ``remotes`` +key in ``rsyslog`` config. The ``remotes`` key takes a dictionary where each +key represents the name of an rsyslog server and each value is the +configuration for that server. The format for server config is: + + - optional filter for log messages (defaults to ``*.*``) + - optional leading ``@`` or ``@@``, indicating udp and tcp respectively + (defaults to ``@``, for udp) + - ipv4 or ipv6 hostname or address. ipv6 addresses must be in ``[::1]`` + format, (e.g. ``@[fd00::1]:514``) + - optional port number (defaults to ``514``) + +For example, to send logging to an rsyslog server named ``log_serv`` with +address ``10.0.4.1``, using port number ``514``, over udp, with all log +messages enabled one could use either of the following. + +With all options specified:: + + rsyslog: + remotes: + log_serv: "*.* @10.0.4.1:514" + +With defaults used:: + + rsyslog: + remotes: + log_serv: "10.0.4.1" + + +For more information on rsyslog configuration, see :ref:`cc_rsyslog`. + +.. _python logging config: https://docs.python.org/3/library/logging.config.html#configuration-file-format +.. _python logging handlers: https://docs.python.org/3/library/logging.handlers.html +.. _python logging formatters: https://docs.python.org/3/library/logging.html#formatter-objects diff --git a/doc/rtd/topics/modules.rst b/doc/rtd/topics/modules.rst index 4202338b..57892f2d 100644 --- a/doc/rtd/topics/modules.rst +++ b/doc/rtd/topics/modules.rst @@ -1,342 +1,57 @@ ======= Modules ======= - -Apt Configure -------------- - -**Internal name:** ``cc_apt_configure`` - .. automodule:: cloudinit.config.cc_apt_configure - -Apt Pipelining --------------- - -**Internal name:** ``cc_apt_pipelining`` - .. automodule:: cloudinit.config.cc_apt_pipelining - -Bootcmd -------- - -**Internal name:** ``cc_bootcmd`` - .. automodule:: cloudinit.config.cc_bootcmd - -Byobu ------ - -**Internal name:** ``cc_byobu`` - .. automodule:: cloudinit.config.cc_byobu - -Ca Certs --------- - -**Internal name:** ``cc_ca_certs`` - .. automodule:: cloudinit.config.cc_ca_certs - -Chef ----- - -**Internal name:** ``cc_chef`` - .. automodule:: cloudinit.config.cc_chef - :members: - -Debug ------ - -**Internal name:** ``cc_debug`` - .. automodule:: cloudinit.config.cc_debug - :members: - -Disable Ec2 Metadata --------------------- - -**Internal name:** ``cc_disable_ec2_metadata`` - .. automodule:: cloudinit.config.cc_disable_ec2_metadata - -Disk Setup ----------- - -**Internal name:** ``cc_disk_setup`` - .. automodule:: cloudinit.config.cc_disk_setup - -Emit Upstart ------------- - -**Internal name:** ``cc_emit_upstart`` - .. automodule:: cloudinit.config.cc_emit_upstart - -Final Message -------------- - -**Internal name:** ``cc_final_message`` - +.. automodule:: cloudinit.config.cc_fan .. automodule:: cloudinit.config.cc_final_message - -Foo ---- - -**Internal name:** ``cc_foo`` - .. automodule:: cloudinit.config.cc_foo - -Growpart --------- - -**Internal name:** ``cc_growpart`` - .. automodule:: cloudinit.config.cc_growpart - -Grub Dpkg ---------- - -**Internal name:** ``cc_grub_dpkg`` - .. automodule:: cloudinit.config.cc_grub_dpkg - -Keys To Console ---------------- - -**Internal name:** ``cc_keys_to_console`` - .. automodule:: cloudinit.config.cc_keys_to_console - -Landscape ---------- - -**Internal name:** ``cc_landscape`` - .. automodule:: cloudinit.config.cc_landscape - -Locale ------- - -**Internal name:** ``cc_locale`` - .. automodule:: cloudinit.config.cc_locale - -Mcollective ------------ - -**Internal name:** ``cc_mcollective`` - +.. automodule:: cloudinit.config.cc_lxd .. automodule:: cloudinit.config.cc_mcollective - -Migrator --------- - -**Internal name:** ``cc_migrator`` - .. automodule:: cloudinit.config.cc_migrator - -Mounts ------- - -**Internal name:** ``cc_mounts`` - .. automodule:: cloudinit.config.cc_mounts - -Package Update Upgrade Install ------------------------------- - -**Internal name:** ``cc_package_update_upgrade_install`` - +.. automodule:: cloudinit.config.cc_ntp .. automodule:: cloudinit.config.cc_package_update_upgrade_install - -Phone Home ----------- - -**Internal name:** ``cc_phone_home`` - .. automodule:: cloudinit.config.cc_phone_home - -Power State Change ------------------- - -**Internal name:** ``cc_power_state_change`` - .. automodule:: cloudinit.config.cc_power_state_change - -Puppet ------- - -**Internal name:** ``cc_puppet`` - .. automodule:: cloudinit.config.cc_puppet - -Resizefs --------- - -**Internal name:** ``cc_resizefs`` - .. automodule:: cloudinit.config.cc_resizefs - -Resolv Conf ------------ - -**Internal name:** ``cc_resolv_conf`` - .. automodule:: cloudinit.config.cc_resolv_conf - -Rightscale Userdata -------------------- - -**Internal name:** ``cc_rightscale_userdata`` - +.. automodule:: cloudinit.config.cc_rh_subscription .. automodule:: cloudinit.config.cc_rightscale_userdata - -Rsyslog -------- - -**Internal name:** ``cc_rsyslog`` - .. automodule:: cloudinit.config.cc_rsyslog - -Runcmd ------- - -**Internal name:** ``cc_runcmd`` - .. automodule:: cloudinit.config.cc_runcmd - -Salt Minion ------------ - -**Internal name:** ``cc_salt_minion`` - .. automodule:: cloudinit.config.cc_salt_minion - -Scripts Per Boot ----------------- - -**Internal name:** ``cc_scripts_per_boot`` - .. automodule:: cloudinit.config.cc_scripts_per_boot - -Scripts Per Instance --------------------- - -**Internal name:** ``cc_scripts_per_instance`` - .. automodule:: cloudinit.config.cc_scripts_per_instance - -Scripts Per Once ----------------- - -**Internal name:** ``cc_scripts_per_once`` - .. automodule:: cloudinit.config.cc_scripts_per_once - -Scripts User ------------- - -**Internal name:** ``cc_scripts_user`` - .. automodule:: cloudinit.config.cc_scripts_user - -Scripts Vendor --------------- - -**Internal name:** ``cc_scripts_vendor`` - .. automodule:: cloudinit.config.cc_scripts_vendor - -Seed Random ------------ - -**Internal name:** ``cc_seed_random`` - .. automodule:: cloudinit.config.cc_seed_random - -Set Hostname ------------- - -**Internal name:** ``cc_set_hostname`` - .. automodule:: cloudinit.config.cc_set_hostname - -Set Passwords -------------- - -**Internal name:** ``cc_set_passwords`` - .. automodule:: cloudinit.config.cc_set_passwords - -Ssh ---- - -**Internal name:** ``cc_ssh`` - +.. automodule:: cloudinit.config.cc_snappy +.. automodule:: cloudinit.config.cc_spacewalk .. automodule:: cloudinit.config.cc_ssh - -Ssh Authkey Fingerprints ------------------------- - -**Internal name:** ``cc_ssh_authkey_fingerprints`` - .. automodule:: cloudinit.config.cc_ssh_authkey_fingerprints - -Ssh Import Id -------------- - -**Internal name:** ``cc_ssh_import_id`` - .. automodule:: cloudinit.config.cc_ssh_import_id - -Timezone --------- - -**Internal name:** ``cc_timezone`` - .. automodule:: cloudinit.config.cc_timezone - -Ubuntu Init Switch ------------------- - -**Internal name:** ``cc_ubuntu_init_switch`` - .. automodule:: cloudinit.config.cc_ubuntu_init_switch - :members: - -Update Etc Hosts ----------------- - -**Internal name:** ``cc_update_etc_hosts`` - .. automodule:: cloudinit.config.cc_update_etc_hosts - -Update Hostname ---------------- - -**Internal name:** ``cc_update_hostname`` - .. automodule:: cloudinit.config.cc_update_hostname - -Users Groups ------------- - -**Internal name:** ``cc_users_groups`` - .. automodule:: cloudinit.config.cc_users_groups - -Write Files ------------ - -**Internal name:** ``cc_write_files`` - .. automodule:: cloudinit.config.cc_write_files - -Yum Add Repo ------------- - -**Internal name:** ``cc_yum_add_repo`` - .. automodule:: cloudinit.config.cc_yum_add_repo diff --git a/doc/rtd/topics/moreinfo.rst b/doc/rtd/topics/moreinfo.rst index 19e96af0..b34cb7dc 100644 --- a/doc/rtd/topics/moreinfo.rst +++ b/doc/rtd/topics/moreinfo.rst @@ -1,9 +1,9 @@ -========= +================ More information -========= +================ Useful external references -------------------------- +-------------------------- - `The beauty of cloudinit`_ - `Introduction to cloud-init`_ (video) |