Skip to content

Commit

Permalink
feat: ensure create_hostname_file is added to distro cfg
Browse files Browse the repository at this point in the history
The new create_hostname_file is necessary for the distro to be aware of.
This change adds create_hostname_file to the cfg distro uses when it
runs cc_set_hostname and cc_update_hostname.
  • Loading branch information
catmsred committed Aug 24, 2023
1 parent 2e54b5b commit da58505
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cloudinit/config/cc_set_hostname.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None:
if hostname_fqdn is not None:
cloud.distro.set_option("prefer_fqdn_over_hostname", hostname_fqdn)

# Set create_hostname_file in distro
create_hostname_file = util.get_cfg_option_bool(
cfg, "create_hostname_file", None
)
if create_hostname_file is not None:
cloud.distro.set_option("create_hostname_file", create_hostname_file)

(hostname, fqdn, is_default) = util.get_hostname_fqdn(cfg, cloud)
# Check for previous successful invocation of set_hostname

Expand Down
7 changes: 7 additions & 0 deletions cloudinit/config/cc_update_hostname.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None:
if hostname_fqdn is not None:
cloud.distro.set_option("prefer_fqdn_over_hostname", hostname_fqdn)

# Set create_hostname_file in distro
create_hostname_file = util.get_cfg_option_bool(
cfg, "create_hostname_file", None
)
if create_hostname_file is not None:
cloud.distro.set_option("create_hostname_file", create_hostname_file)

(hostname, fqdn, is_default) = util.get_hostname_fqdn(cfg, cloud)
if is_default and hostname == "localhost":
# https://github.com/systemd/systemd/commit/d39079fcaa05e23540d2b1f0270fa31c22a7e9f1
Expand Down

0 comments on commit da58505

Please sign in to comment.