Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/rtd/topics/boot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ scripts until cloud-init is done without having to write your own systemd
units dependency chains. See :ref:`cli_status` for more info.

First Boot Determination
************************
========================

cloud-init has to determine whether or not the current boot is the first boot
of a new instance or not, so that it applies the appropriate configuration. On
Expand Down
8 changes: 0 additions & 8 deletions doc/rtd/topics/docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,6 @@ other pages. For example for the FAQ page this would be:

.. _faq:

Footer
------
The footer should include the textwidth

.. code-block:: rst

.. vi: textwidth=79

Vertical Whitespace
-------------------
One newline between each section helps ensure readability of the documentation
Expand Down
140 changes: 68 additions & 72 deletions doc/rtd/topics/format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,67 @@ User-Data Formats
User data that will be acted upon by cloud-init must be in one of the following
types.

Cloud Config Data
=================

Cloud-config is the simplest way to accomplish some things via user-data. Using
cloud-config syntax, the user can specify certain things in a human friendly
format.

These things include:

- apt upgrade should be run on first boot
- a different apt mirror should be used
- additional apt sources should be added
- certain SSH keys should be imported
- *and many more...*

.. note::
This file must be valid YAML syntax.

See the :ref:`yaml_examples` section for a commented set of examples of
supported cloud config formats.

Begins with: ``#cloud-config`` or ``Content-Type: text/cloud-config`` when
using a MIME archive.

.. note::
New in cloud-init v. 18.4: Cloud config data can also render cloud instance
metadata variables using jinja templating. See
:ref:`instance_metadata` for more information.

User-Data Script
================

Typically used by those who just want to execute a shell script.

Begins with: ``#!`` or ``Content-Type: text/x-shellscript`` when using a MIME
archive.

.. note::
New in cloud-init v. 18.4: User-data scripts can also render cloud instance
metadata variables using jinja templating. See
:ref:`instance_metadata` for more information.

Example
-------

.. code-block:: shell-session

$ cat myscript.sh

#!/bin/sh
echo "Hello World. The time is now $(date -R)!" | tee /root/output.txt

$ euca-run-instances --key mykey --user-data-file myscript.sh ami-a07d95c9

Kernel Command Line
===================

When using the :ref:`datasource_nocloud` datasource, users can pass user data
via the kernel command line parameters. See the :ref:`datasource_nocloud`
datasource documentation for more details.

Gzip Compressed Content
=======================

Expand Down Expand Up @@ -39,7 +100,6 @@ Supported content-types are listed from the cloud-init subcommand make-mime:
x-include-url
x-shellscript


Helper subcommand to generate mime messages
-------------------------------------------

Expand All @@ -57,32 +117,6 @@ to store the multipart message in ``user-data``:

.. _make-mime: https://github.com/canonical/cloud-init/blob/main/cloudinit/cmd/devel/make_mime.py


User-Data Script
================

Typically used by those who just want to execute a shell script.

Begins with: ``#!`` or ``Content-Type: text/x-shellscript`` when using a MIME
archive.

.. note::
New in cloud-init v. 18.4: User-data scripts can also render cloud instance
metadata variables using jinja templating. See
:ref:`instance_metadata` for more information.

Example
-------

.. code-block:: shell-session

$ cat myscript.sh

#!/bin/sh
echo "Hello World. The time is now $(date -R)!" | tee /root/output.txt

$ euca-run-instances --key mykey --user-data-file myscript.sh ami-a07d95c9

Include File
============

Expand All @@ -96,44 +130,6 @@ an error occurs reading a file the remaining files will not be read.
Begins with: ``#include`` or ``Content-Type: text/x-include-url`` when using
a MIME archive.

Cloud Config Data
=================

Cloud-config is the simplest way to accomplish some things via user-data. Using
cloud-config syntax, the user can specify certain things in a human friendly
format.

These things include:

- apt upgrade should be run on first boot
- a different apt mirror should be used
- additional apt sources should be added
- certain SSH keys should be imported
- *and many more...*

.. note::
This file must be valid YAML syntax.

See the :ref:`yaml_examples` section for a commented set of examples of
supported cloud config formats.

Begins with: ``#cloud-config`` or ``Content-Type: text/cloud-config`` when
using a MIME archive.

.. note::
New in cloud-init v. 18.4: Cloud config data can also render cloud instance
metadata variables using jinja templating. See
:ref:`instance_metadata` for more information.

Upstart Job
===========

Content is placed into a file in ``/etc/init``, and will be consumed by upstart
as any other upstart job.

Begins with: ``#upstart-job`` or ``Content-Type: text/upstart-job`` when using
a MIME archive.

Cloud Boothook
==============

Expand Down Expand Up @@ -191,12 +187,14 @@ Example

Also this `blog`_ post offers another example for more advanced usage.

Kernel Command Line
===================
Upstart Job
===========

When using the :ref:`datasource_nocloud` datasource, users can pass user data
via the kernel command line parameters. See the :ref:`datasource_nocloud`
datasource documentation for more details.
Content is placed into a file in ``/etc/init``, and will be consumed by upstart
as any other upstart job.

Begins with: ``#upstart-job`` or ``Content-Type: text/upstart-job`` when using
a MIME archive.

Disabling User-Data
===================
Expand All @@ -208,5 +206,3 @@ cloud-init from processing user-data.

.. [#] See your cloud provider for applicable user-data size limitations...
.. _blog: http://foss-boss.blogspot.com/2011/01/advanced-cloud-init-custom-handlers.html

.. vi: textwidth=79