Skip to main content
User data in the cloud server
Last update:

User data in the cloud server

User data — user configuration parameters of the server operating system. With the help of user data you can automate server configuration. User parameters are 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 by the cloud-init agent when the operating system is first started.

Learn more about cloud-config and bash script formats in the User data formats instruction of the cloud-init documentation.

You can specify user data can be specified when creating a cloud server. In scripts, you can pass parameters to configure the operating system and scripts. For example:

See more examples in the Cloud config examples documentation cloud-init instructions.

Specify user data

You can only specify user data when creating a cloud server:

  • in the control panel — at step 4 of additional settings you can insert a script in the User data field, upload a file in txt, gz, sh or MIME-archive formats. The maximum size of a script with non-Base64 encoded data is 16 KB;
  • through OpenStack CLI and Terraform — only scripts with Base64 encoded data.

Once the server is created, you cannot change the script.

Examples of user data

Create a directory and upload 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 SSH keys 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', '8.8.8.8']
searchdomains:
- foo.example.com
- bar.example.com
domain: example.com
options:
rotate: true
timeout: 1