Set hostname and FQDN

For a full list of keys, refer to the set hostname module schema.

Example 1

1#cloud-config
2preserve_hostname: true

Example 2

1#cloud-config
2hostname: myhost
3create_hostname_file: true
4fqdn: myhost.example.com
5prefer_fqdn_over_hostname: true

Example 3

On a machine without an /etc/hostname file, don’t create it.

In most clouds, this will result in a DHCP-configured hostname provided by the cloud.

1#cloud-config
2create_hostname_file: false