-
Notifications
You must be signed in to change notification settings - Fork 881
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate content out of FAQ page (SD-1187) (#4205)
Extracted several short topics out of the FAQ and created individual "how-to" pages. Now what's left in the FAQ is mostly troubleshooting content.
- Loading branch information
Showing
5 changed files
with
173 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
How to debug user data | ||
====================== | ||
|
||
Two of the most common issues with cloud config user data are: | ||
|
||
1. Incorrectly formatted YAML | ||
2. The first line does not contain ``#cloud-config`` | ||
|
||
Static user data validation | ||
--------------------------- | ||
|
||
To verify your cloud config is valid YAML you can use `validate-yaml.py`_. | ||
|
||
To ensure the keys and values in your user data are correct, you can run: | ||
|
||
.. code-block:: shell-session | ||
sudo cloud-init schema --system --annotate | ||
Or, to test YAML in a file: | ||
|
||
.. code-block:: shell-session | ||
cloud-init schema -c test.yml --annotate | ||
Log analysis | ||
------------ | ||
|
||
If you can log into your system, the best way to debug your system is to | ||
check the contents of the log files :file:`/var/log/cloud-init.log` and | ||
:file:`/var/log/cloud-init-output.log` for warnings, errors, and | ||
tracebacks. Tracebacks are always reportable bugs. | ||
|
||
To report any bugs you find, :ref:`refer to this guide <reporting_bugs>`. | ||
|
||
.. LINKS | ||
.. _validate-yaml.py: https://github.com/canonical/cloud-init/blob/main/tools/validate-yaml.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
How to identify the datasource I'm using | ||
======================================== | ||
|
||
To correctly set up an instance, ``cloud-init`` must correctly identify the | ||
cloud it is on. Therefore, knowing which datasource is being used on an | ||
instance launch can aid in debugging. | ||
|
||
To find out which datasource is being used run the :command:`cloud-id` command: | ||
|
||
.. code-block:: bash | ||
cloud-id | ||
This will tell you which datasource is being used -- for example: | ||
|
||
.. code-block:: | ||
nocloud | ||
If the ``cloud-id`` is not what is expected, then running the | ||
:file:`ds-identify` script in debug mode and providing that in a bug report can | ||
aid in resolving any issues: | ||
|
||
.. code-block:: bash | ||
sudo DEBUG_LEVEL=2 DI_LOG=stderr /usr/lib/cloud-init/ds-identify --force | ||
The ``force`` parameter allows the command to be run again since the instance | ||
has already launched. The other options increase the verbosity of logging and | ||
outputs the logs to :file:`STDERR`. | ||
|
||
How can I re-run datasource detection and ``cloud-init``? | ||
--------------------------------------------------------- | ||
|
||
If you are developing a new datasource or working on debugging an issue it | ||
may be useful to re-run datasource detection and the initial setup of | ||
``cloud-init``. | ||
|
||
.. warning:: | ||
|
||
**Do not run the following commands on production systems.** | ||
|
||
These commands will re-run ``cloud-init`` as if this were first boot of a | ||
system. At the very least, this will cycle SSH host keys but may do | ||
substantially more. | ||
|
||
To re-run datasource detection, you must first force :file:`ds-identify` to | ||
re-run, then clean up any logs, and finally, re-run ``cloud-init``: | ||
|
||
.. code-block:: bash | ||
sudo DI_LOG=stderr /usr/lib/cloud-init/ds-identify --force | ||
sudo cloud-init clean --logs | ||
sudo cloud-init init --local | ||
sudo cloud-init init |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
How to find files | ||
***************** | ||
|
||
Cloud-init log files | ||
==================== | ||
|
||
``Cloud-init`` uses two files to log to: | ||
|
||
- :file:`/var/log/cloud-init-output.log`: | ||
Captures the output from each stage of ``cloud-init`` when it runs. | ||
- :file:`/var/log/cloud-init.log`: | ||
Very detailed log with debugging output, describing each action taken. | ||
- :file:`/run/cloud-init`: | ||
Contains logs about how ``cloud-init`` enabled or disabled itself, as well as | ||
what platforms/datasources were detected. These logs are most useful when | ||
trying to determine what ``cloud-init`` did or did not run. | ||
|
||
Be aware that each time a system boots, new logs are appended to the files in | ||
:file:`/var/log`. Therefore, the files may contain information from more | ||
than one boot. | ||
|
||
When reviewing these logs, look for errors or Python tracebacks. | ||
|
||
Configuration files | ||
=================== | ||
|
||
``Cloud-init`` configuration files are provided in two places: | ||
|
||
- :file:`/etc/cloud/cloud.cfg` | ||
- :file:`/etc/cloud/cloud.cfg.d/*.cfg` | ||
|
||
These files can define the modules that run during instance initialisation, | ||
the datasources to evaluate on boot, as well as other settings. | ||
|
||
See the :ref:`configuration sources explanation<configuration>` and | ||
:ref:`configuration reference<base_config_reference>` pages for more details. | ||
|
||
Data files | ||
========== | ||
|
||
Inside the :file:`/var/lib/cloud/` directory there are two important | ||
subdirectories: | ||
|
||
:file:`instance` | ||
---------------- | ||
|
||
The :file:`/var/lib/cloud/instance` directory is a symbolic link that points | ||
to the most recently used :file:`instance-id` directory. This folder contains | ||
the information ``cloud-init`` received from datasources, including vendor and | ||
user data. This can help to determine that the correct data was passed. | ||
|
||
It also contains the :file:`datasource` file that contains the full information | ||
about which datasource was identified and used to set up the system. | ||
|
||
Finally, the :file:`boot-finished` file is the last thing that | ||
``cloud-init`` creates. | ||
|
||
:file:`data` | ||
------------ | ||
|
||
The :file:`/var/lib/cloud/data` directory contain information related to the | ||
previous boot: | ||
|
||
* :file:`instance-id`: | ||
ID of the instance as discovered by ``cloud-init``. Changing this file has | ||
no effect. | ||
* :file:`result.json`: | ||
JSON file showing both the datasource used to set up the instance, and | ||
whether any errors occurred. | ||
* :file:`status.json`: | ||
JSON file showing the datasource used, a breakdown of all four modules, | ||
whether any errors occurred, and the start and stop times. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters