From 158592eacfc983495f87f3a19c704c82afe5657b Mon Sep 17 00:00:00 2001 From: Aleksandr Berkuta Date: Mon, 19 May 2025 16:49:44 +0300 Subject: [PATCH 1/2] Add documentation for the user-data modules --- user-data-modules.md | 60 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 user-data-modules.md diff --git a/user-data-modules.md b/user-data-modules.md new file mode 100644 index 0000000..8569c0e --- /dev/null +++ b/user-data-modules.md @@ -0,0 +1,60 @@ +# Modules That Tiny-Cloud Supports + +The `user-data` file is used to configure Alpine linux state at the boot time. It supports a variety of modules that can be used to install packages, configure users and groups, and more. Tiny-cloud supports following modules: + +```yaml +apk: + cache: # path to apk cache where /etc/apk/cache link follows + repositories: # defines resulted url https://dl-cdn.alpinelinux.org/alpine/edge/community + - base_url: # The base usr of the repository ( https://dl-cdn.alpinelinux.org/alpine ) + version: # (optional) examples: [ 3.16 | 3.21 | edge ] if not set will be retrieved from the system + repos: # + - community + +user: # Sets default user + name: # + +users: # + # first one become default user + - name: + homedir: + shell: + primary_group: + gecos: # description for the user + system: # [ true | false ] create a system user + no_create_home: # [ true | false ] do not create home directory for the user. Default: false + lock_passwd: # reset password of the user + ssh_authorized_keys: # + groups: # + - wheel + - power + doas: # content of the /etc/doas.d/ doas file + +ssh_authorized_keys: # public key to be authorized as default user + +write_files: # Writes content of the file to the system. Can be used to define configuration files. + - path: # destination path of the file (required) + permissions: # file mode (default 0644) + owner: # owner:group of the file (default root:root) + encoding: # provided endoding of the file [gzip|gz|gz+base64|gzip+base64|gz+b64|gzip+b64|base64|b64|text/plain] (default text/plain) + append: # if "true", then content will be added to the end of the file + content: | # (required) + here is multiline + content of your file + +ntp: + enabled: # checks for [ yes | true ]. Otherwise do not enables ntp service + ntp_client: # [ ntpd | chrony | openntpd ] (default: chrony) + +package_update: # if "true" runs `apk update` + +package_upgrade: # if "true" runs `apk upgrade` + +packages: # + - curl + - bash + +groups: # + - wheel + - admin +``` From abd60792ae75f1aa4250c1e03f36ea4fd908e2e9 Mon Sep 17 00:00:00 2001 From: Aleksandr Berkuta Date: Thu, 29 May 2025 15:12:04 +0300 Subject: [PATCH 2/2] Describe different user-data file formats --- user-data-modules.md => user-data-file.md | 55 ++++++++++++++++++----- 1 file changed, 44 insertions(+), 11 deletions(-) rename user-data-modules.md => user-data-file.md (54%) diff --git a/user-data-modules.md b/user-data-file.md similarity index 54% rename from user-data-modules.md rename to user-data-file.md index 8569c0e..eba0e9a 100644 --- a/user-data-modules.md +++ b/user-data-file.md @@ -1,8 +1,22 @@ -# Modules That Tiny-Cloud Supports +# User Data -The `user-data` file is used to configure Alpine linux state at the boot time. It supports a variety of modules that can be used to install packages, configure users and groups, and more. Tiny-cloud supports following modules: +User-data file is loaded during early stage. Location of this file defined by kernel paramter: `ds=;s=`. For example for nocloud provider: `ds=nocloud;s=http://my.miniserve.instance/tinycloud/` tiny cloud will search for a file with name "user-data" at http://my.miniserve.instance/tinycloud/ resource. + +Tiny-Cloud currently supports several user-data types and you could use ONE of them: + +- alpine-config +- cloud-config +- script + +The `user-data` file is used to configure Alpine Linux state at the boot time. It supports a variety of modules that can be used to install packages, configure users and groups, and more. + +## Alpine-Config Data Type + +Alpine config Must have `#alpine-config` as fist line in the file. +Rest of the file is a yaml which describes several alpine-spesific configuration paramters: ```yaml +#alpine-config apk: cache: # path to apk cache where /etc/apk/cache link follows repositories: # defines resulted url https://dl-cdn.alpinelinux.org/alpine/edge/community @@ -11,9 +25,22 @@ apk: repos: # - community -user: # Sets default user +autoinstall: # [ true | false] install alpine on the biggest empty disk found in the system +``` + +## Cloud-Config Data Type + +Alpine config Must have `#cloud-config` as fist line in the file. + +```yaml +#cloud-config +user: # sets default user name: # +groups: # groups for default user + - wheel + - admin + users: # # first one become default user - name: @@ -25,10 +52,9 @@ users: # no_create_home: # [ true | false ] do not create home directory for the user. Default: false lock_passwd: # reset password of the user ssh_authorized_keys: # - groups: # - - wheel - - power - doas: # content of the /etc/doas.d/ doas file + groups: wheel,power # comma-separated list of groups for the user + doas: # content of the /etc/doas.d/.conf doas file + - ssh_authorized_keys: # public key to be authorized as default user @@ -53,8 +79,15 @@ package_upgrade: # if "true" runs `apk upgrade` packages: # - curl - bash - -groups: # - - wheel - - admin +``` + +## Script Data Type + +Scipt user-data could be used to run arbitrary user script at the system init. User-data file must have script executor specific shebang, started with `#!` +For example shell script: + +```shell +#!/bin/sh + +echo "running custom script at init time" ```