Skip to content

Commit fe4d5d3

Browse files
committed
Use spacewalk-hostname-rename from uyuni-update-config service
Watch out for UYUNI_HOSTNAME value change before starting services and rename the server if needed. (bsc#1229825) In order to achieve this, the spacewalk-hostname-rename script had to be cleaned up.
1 parent bd2081d commit fe4d5d3

7 files changed

+87
-652
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix spacewalk-hostname-rename with containers (bsc#1229825)

spacewalk/admin/uyuni-update-config

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ from spacewalk.server import rhnSQL
2121

2222
def run_uyuni_configfiles_sync():
2323
if not os.path.isfile("/usr/bin/uyuni-configfiles-sync"):
24-
return
24+
return 0
2525

26+
exitCode = 0
2627
result = subprocess.run(
2728
["/usr/bin/uyuni-configfiles-sync", "sync"],
2829
stdout=subprocess.PIPE,
@@ -39,7 +40,8 @@ def run_uyuni_configfiles_sync():
3940
"Failed to synchronize files to persistent volumes. Aborting!\n"
4041
)
4142
sys.stdout.flush()
42-
sys.exit(1)
43+
exitCode = 1
44+
return exitCode
4345

4446

4547
def move_config_to_db():
@@ -186,14 +188,32 @@ def change_billing_data_service():
186188
sys.stdout.write("billing-data-service sysconfig: changed LISTEN address\n")
187189

188190

191+
def hostname_check():
192+
result = subprocess.run(
193+
["/usr/bin/spacewalk-hostname-rename"],
194+
stdout=subprocess.PIPE,
195+
stderr=subprocess.STDOUT,
196+
encoding="utf-8",
197+
check=False,
198+
)
199+
200+
if result.returncode:
201+
sys.stdout.write("Failed to rename the server\n")
202+
if result.stdout:
203+
sys.stdout.write(f"{result.stdout}\n")
204+
sys.stdout.flush()
205+
return result.returncode
206+
207+
189208
def main():
190-
run_uyuni_configfiles_sync()
209+
exitCode = run_uyuni_configfiles_sync()
191210
init_scc_login()
192211
import_suma_gpg_keyring()
193212
copy_ca()
194213
move_config_to_db()
195214
change_billing_data_service()
196-
215+
exitCode = max(hostname_check(), exitCode)
216+
return exitCode
197217

198218
if __name__ == "__main__":
199219
sys.exit(abs(main() or 0))
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[Unit]
22
Description=Uyuni update config
3-
Before=uyuni-check-database.service tomcat.service apache2.service rhn-search.service taskomatic.service postfix.service
3+
Before=uyuni-check-database.service cobblerd.service tomcat.service apache2.service rhn-search.service taskomatic.service postfix.service
44

55
[Service]
6+
PassEnvironment=UYUNI_HOSTNAME
67
ExecStart=/usr/sbin/uyuni-update-config
78
Type=oneshot
89
RemainAfterExit=yes

0 commit comments

Comments
 (0)