diff --git a/cloudinit/config/cc_set_hostname.py b/cloudinit/config/cc_set_hostname.py index 2327a2c7cac9..daa0f88d8cd9 100644 --- a/cloudinit/config/cc_set_hostname.py +++ b/cloudinit/config/cc_set_hostname.py @@ -60,10 +60,19 @@ dedent( """\ hostname: myhost + ceate_hostname_file: true fqdn: myhost.example.com prefer_fqdn_over_hostname: true """ ), + dedent( + """\ + # On a machine without an ``/etc/hostname`` file, don't create it + # In most clouds, this will results in a DHCP configured hostname + # provided by the cloud + create_hostname_file: false + """ + ), ], "activate_by_schema_keys": [], } diff --git a/cloudinit/config/cc_update_hostname.py b/cloudinit/config/cc_update_hostname.py index 177b9db4cb7b..0b14abd43595 100644 --- a/cloudinit/config/cc_update_hostname.py +++ b/cloudinit/config/cc_update_hostname.py @@ -65,6 +65,7 @@ fqdn: external.fqdn.me hostname: myhost prefer_fqdn_over_hostname: true + create_hostname_file: true """ ), dedent( @@ -74,6 +75,14 @@ prefer_fqdn_over_hostname: false """ ), + dedent( + """\ + # On a machine without an ``/etc/hostname`` file, don't create it + # In most clouds, this will results in a DHCP configured hostname + # provided by the cloud + create_hostname_file: false + """ + ), ], "frequency": PER_ALWAYS, "activate_by_schema_keys": [],