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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
.. _datasource_openstack:
OpenStack
*********
This datasource supports reading data from the
`OpenStack Instance Metadata Service`_.
Discovery
=========
To determine whether a platform looks like it may be OpenStack, ``cloud-init``
checks the following environment attributes as a potential OpenStack platform:
* May be OpenStack **if**:
* ``non-x86 cpu architecture``: because DMI data is buggy on some arches.
* Is OpenStack **if** x86 architecture and **ANY** of the following:
* ``/proc/1/environ``: ``Nova-lxd`` contains
``product_name=OpenStack Nova``.
* ``DMI product_name``: Either ``Openstack Nova`` or ``OpenStack Compute``.
* ``DMI chassis_asset_tag`` is ``HUAWEICLOUD``, ``OpenTelekomCloud``,
``SAP CCloud VM``, ``Samsung Cloud Platform``,
``OpenStack Nova`` (since 19.2) or ``OpenStack Compute`` (since 19.2).
Configuration
=============
The following configuration can be set for the datasource in system
configuration (in :file:`/etc/cloud/cloud.cfg` or
:file:`/etc/cloud/cloud.cfg.d/`).
The settings that may be configured are as follows:
``metadata_urls``
-----------------
This list of URLs will be searched for an OpenStack IMDS (instance
metadata service). The first entry that successfully returns a 200 response
for ``<url>/openstack`` will be selected.
Default: ['http://169.254.169.254'])
``max_wait``
------------
The maximum amount of clock time (in seconds) that should be spent searching
``metadata_urls``. A value less than zero will result in only one request
being made, to the first in the list.
Default: -1
``timeout``
-----------
The timeout value provided to ``urlopen`` for each individual http request.
This is used both when selecting a ``metadata_url`` and when crawling the
instance metadata service.
Default: 10
``retries``
-----------
The number of retries that should be attempted for an http request. This
value is used only after ``metadata_url`` is selected.
Default: 5
``apply_network_config``
------------------------
A boolean specifying whether to configure the network for the instance based
on :file:`network_data.json` provided by the IMDS. When False,
only configure DHCP on the primary NIC for this instance.
Default: True
Example configuration
=====================
An example configuration with the default values is provided below:
.. code-block:: yaml
datasource:
OpenStack:
metadata_urls: ["http://169.254.169.254"]
max_wait: -1
timeout: 10
retries: 5
apply_network_config: True
Vendor-data
===========
The OpenStack IMDS can be configured to serve up vendor-data,
which is available to all instances for consumption. OpenStack vendor-data is
generally a JSON object.
``Cloud-init`` will look for configuration in the ``cloud-init`` attribute
of the vendor-data JSON object. ``Cloud-init`` processes this configuration
using the same handlers as user-data, so any formats that work for user-data
should work for vendor-data.
For example, configuring the following as vendor-data in OpenStack would
upgrade packages and install ``htop`` on all instances:
.. code-block:: json
{"cloud-init": "#cloud-config\npackage_upgrade: True\npackages:\n - htop"}
For more general information about how ``cloud-init`` handles vendor-data,
including how it can be disabled by users on instances, see our
:ref:`explanation topic<vendor-data>`.
OpenStack can also be configured to provide "dynamic vendor-data"
which is provided by the DynamicJSON provider and appears under a
different IMDS path, :file:`/vendor_data2.json`.
``Cloud-init`` will look for a ``cloud-init`` at the :file:`vendor_data2`
path; if found, settings are applied after (and, hence, overriding) the
settings from static vendor-data. Both sets of vendor-data can be overridden
by user-data.
.. _datasource_ironic:
OpenStack Ironic Bare Metal
===========================
During boot, cloud-init typically has to identify which platform it is running
on. Since OpenStack Ironic Bare Metal doesn't provide a method for cloud-init
to discover that it is running on Ironic, extra user configuration is required.
Cloud-init provides two methods to do this:
Method 1: Configuration file
----------------------------
Explicitly set ``datasource_list`` to only ``openstack``, such as:
.. code-block:: yaml
datasource_list: ["openstack"]
Method 2: Kernel command line
-----------------------------
Set the kernel command line to configure
:ref:`datasource override <kernel_datasource_override>`.
Example using Ubuntu + GRUB2:
.. code-block::
$ echo 'ds=openstack' >> /etc/default/grub
$ grub-mkconfig -o /boot/efi/EFI/ubuntu/grub.cfg
.. _OpenStack Instance Metadata Service: https://docs.openstack.org/nova/latest/admin/metadata-service.html
|