Merge ~nrezinorn/cloud-init:fix_systemd_hostname into cloud-init:master

Proposed by Jim Gorz
Status: Work in progress
Proposed branch: ~nrezinorn/cloud-init:fix_systemd_hostname
Merge into: cloud-init:master
Diff against target: 17 lines (+3/-3)
1 file modified
cloudinit/distros/rhel.py (+3/-3)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Needs Fixing
Scott Moser Needs Information
Joshua Harlow (community) Approve
Review via email: mp+306562@code.launchpad.net

Description of the change

cloud-init was not properly running hostnamectl on first boot. this fixes the systemd handling logic and works :)

To post a comment you must log in.
Revision history for this message
Joshua Harlow (harlowja) :
review: Approve
Revision history for this message
Scott Moser (smoser) wrote :

It seems to me that we should not be calling
 ['hostnamectl', 'set-hostname', str(hostname)]
from _write_hostname at all

but rather from _apply_hostname.

Can you please test a change made where we drop the call to hostnamectl here, and instead do it in _apply_hostname ?

review: Needs Information
Revision history for this message
Scott Moser (smoser) wrote :

also, please "set commit message" with a overall change message , and a line at the end with:

LP: #1424710

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

Hi,
I've moved this to work in progress. Please respond to the question above and move back to 'Needs Review'. Thanks.
Scott

Unmerged commits

bd571d6... by Jim Gorz <email address hidden>

fix: hostnamectl occurs every time as expected now

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/distros/rhel.py b/cloudinit/distros/rhel.py
2index 1aa42d7..c4b19d1 100644
3--- a/cloudinit/distros/rhel.py
4+++ b/cloudinit/distros/rhel.py
5@@ -135,9 +135,9 @@ class Distro(distros.Distro):
6 def _write_hostname(self, hostname, out_fn):
7 # systemd will never update previous-hostname for us, so
8 # we need to do it ourselves
9- if self.uses_systemd() and out_fn.endswith('/previous-hostname'):
10- util.write_file(out_fn, hostname)
11- elif self.uses_systemd():
12+ if self.uses_systemd():
13+ if out_fn.endswith('/previous-hostname'):
14+ util.write_file(out_fn, hostname)
15 util.subp(['hostnamectl', 'set-hostname', str(hostname)])
16 else:
17 host_cfg = {

Subscribers

People subscribed via source and target branches