File: debug_user_data.rst

package info (click to toggle)
cloud-init 25.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,412 kB
  • sloc: python: 135,894; sh: 3,883; makefile: 141; javascript: 30; xml: 22
file content (56 lines) | stat: -rw-r--r-- 1,816 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
.. _check_user_data_cloud_config:

How to validate user-data cloud config
======================================

The two most common issues with cloud config user-data are:

1. Incorrectly formatted YAML
2. The first line does not start with ``#cloud-config``

Static user-data validation
---------------------------

Cloud-init is capable of validating cloud config user-data directly from
its datasource (i.e. on a running cloud instance). To do this, you can run:

.. code-block:: shell-session

   sudo cloud-init schema --system --annotate

Or, to test YAML in a specific file:

.. code-block:: shell-session

   cloud-init schema -c test.yml --annotate

Example output:

.. code-block:: shell-session

    $ cloud-init schema --config-file=test.yaml --annotate
    #cloud-config
    users:
      - name: holmanb        # E1,E2,E3
        gecos: Brett Holman
        primary_group: holmanb
        lock_passwd: false
        invalid_key: true

    # Errors: -------------
    # E1: Additional properties are not allowed ('invalid_key' was unexpected)
    # E2: {'name': 'holmanb', 'gecos': 'Brett Holman', 'primary_group': 'holmanb', 'lock_passwd': False, 'invalid_key': True} is not of type 'array'
    # E3: {'name': 'holmanb', 'gecos': 'Brett Holman', 'primary_group': 'holmanb', 'lock_passwd': False, 'invalid_key': True} is not of type 'string'

Debugging
---------

If your user-data cloud config is correct according to the `cloud-init schema`
command, but you are still having issues, then please refer to our
:ref:`debugging guide<how_to_debug>`.

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
.. _validation service: https://github.com/aciba90/cloud-config-validator