Cloud-Config
Cloud-config (cloud-init) is a tool that handles the early initialization of cloud instances. Combined with LXD or Incus profiles, it is a powerful way to provision and configure machines automatically.
You can read the full cloud-init documentation here.
Creating a Cloud-Config File in LXDMosaic
LXDMosaic maintains a history of your cloud-config files. Each entry stores:
- A namespace for organizing configs
- Details about the target image this config is designed for
- A full copy of the config content as entered in the editor
This is not a version control system — it simply preserves previous versions of your configs.
Namespace
Cloud-configs support one level of namespacing to help organize them logically. For example:
webservers/My_Clients_Sitewebservers/My_Personal_Sitedatabase/My_Clients_Sitedatabase/My_Personal_Site
Namespacing makes it easier to browse configs and allows CLI tools to interpret different categories.
Target Image
Cloud-config files can target various operating systems, so LXDMosaic associates each config with a specific image. At present, only Ubuntu images include cloud-init by default.
Linking a config to an image has two benefits:
- Reduces form fields when deploying the config or using it in deployments.
- Future CLI tools can infer the correct image automatically.
Config Content
The official cloud-init documentation covers the full range of available directives. Below is an example cloud-config shipped with LXDMosaic:
#cloud-config
# Apply system updates
package_update: true
package_upgrade: true
# Install packages
packages:
- nodejs
- npm
runcmd:
- git clone https://github.com/turtle0x1/nodeExample /root/nodeExample
- cd /root/nodeExample && npm install
- npm -g install pm2
- pm2 start /root/nodeExample/index.js
- pm2 startup
- pm2 save