Skip to main content
User data
Last update:

User data

User data — user configuration parameters of the server operating system. Described as scripts in cloud-config format (text files with YAML syntax) or as a bash script. The scripts are automatically Base64 encoded, transferred to the server, and executed using the cloud-init agent when the operating system is first started. The use of user data helps automate the configuration of servers.

Specify user data can be specified during the installation phase of the operating system.

For more information about cloud-config and bash script formats, see the User data formats instructions in the cloud-init documentation.

In scripts, you can pass both individual operating system configuration parameters and entire sequences of parameters. For example:

See other examples in the Cloud config examples cloud-init documentation.

Specify user data

You can only specify user data when installing Linux by autoinstall. The script text is added to the User data field.

Once the automatic installation is complete, the text in the User data field cannot be changed.

The maximum size of a script with data that is not Base64 encoded is 16 KB.

Examples of user data

Set time zone

An example script for setting the Europe/Moscow time zone:

#cloud-config

timezone: Europe/Moscow

Create a directory and upload the files to it

An example script to create a directory and upload a file to it over the network:

#cloud-config

runcmd:
- mkdir /run/newdir
- [ wget, "http://example.com", -O, /run/newdir/index.html ]

Update repositories and install packages

Sample script to install pwgen and pastebinit:

#cloud-config

package_update: true
packages:
- pwgen
- pastebinit

Place the SSH key on the server

Sample script:

#cloud-config

ssh_authorized_keys:
- ssh-rsa AAAAB3N…V7NZ user1@host
- ssh-rsa AAAAB3N…NtHw== user2@server

Customize the configuration file

Sample script for the resolv.conf domain name resolver:

#cloud-config

manage_resolv_conf: true
resolv_conf:
nameservers: ['4.4.4.4.4', '8.8.8.8.8']
searchdomains:
- foo.example.com
- bar.example.com
domain: example.com
options:
rotate: true
timeout: 1