sailesh1993 / rpms / cloud-init

Forked from rpms/cloud-init a year ago
Clone
f6265e
From 9969cf3eaa23398816d140b319b3277465aa4bb8 Mon Sep 17 00:00:00 2001
f6265e
From: Eduardo Otubo <otubo@redhat.com>
f6265e
Date: Fri, 6 Sep 2019 12:12:11 +0200
f6265e
Subject: [PATCH] Fix for network configuration not persisting after reboot
f6265e
f6265e
RH-Author: Eduardo Otubo <otubo@redhat.com>
f6265e
Message-id: <20190906121211.23172-1-otubo@redhat.com>
f6265e
Patchwork-id: 90300
f6265e
O-Subject: [RHEL-7.8/RHEL-8.1.0 cloud-init PATCH] Fix for network configuration not persisting after reboot
f6265e
Bugzilla: 1593010
f6265e
RH-Acked-by: Mohammed Gamal <mgamal@redhat.com>
f6265e
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
f6265e
f6265e
The reasons the configuration does not persist after reboot includes
f6265e
different aspects and they're all fixed on this patch:
f6265e
f6265e
  1) The rpm package doesn't include the systemd-generator and
f6265e
ds-identify. The systemd-generator is called early in the boot process
f6265e
that calls ds-identify to check if there's any Data Source available in
f6265e
the current boot. In the current use case, the Data Source is removed
f6265e
from the VM on the second boot, this means cloud-init should disable
f6265e
itself in order to keep the configuration it did in the first boot.
f6265e
f6265e
  2) Even after adding those scripts, cloud-init was still being
f6265e
executed and the configurations were being lost. The reason for this is
f6265e
that the cloud-init systemd units had a wrong dependency
f6265e
f6265e
     WantedBy: multi-user.target
f6265e
f6265e
     Which would start them every time no matter the return of
f6265e
ds-identify. The fix is to replace the dependency by the systemd unit to
f6265e
cloud-init.target, which is the main cloud-init target enabled - or in
f6265e
this case, disabled by ds-identify. The file cloud-init.target was also
f6265e
missing on rpm package.
f6265e
f6265e
After adding both scripts, the main cloud-init systemd target and
f6265e
adjusting the systemd dependencies the configuration persists after
f6265e
reboots and shutdowns.
f6265e
f6265e
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
f6265e
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
f6265e
---
f6265e
 redhat/cloud-init.spec.template       | 15 +++++++++++++++
f6265e
 rhel/systemd/cloud-config.service     |  2 +-
f6265e
 rhel/systemd/cloud-final.service      |  2 +-
f6265e
 rhel/systemd/cloud-init-local.service |  2 +-
f6265e
 rhel/systemd/cloud-init.service       |  2 +-
f6265e
 rhel/systemd/cloud-init.target        |  7 +++++++
f6265e
 6 files changed, 26 insertions(+), 4 deletions(-)
f6265e
 create mode 100644 rhel/systemd/cloud-init.target
f6265e
f6265e
diff --git a/rhel/systemd/cloud-config.service b/rhel/systemd/cloud-config.service
f6265e
index 12ca9df..f3dcd4b 100644
f6265e
--- a/rhel/systemd/cloud-config.service
f6265e
+++ b/rhel/systemd/cloud-config.service
f6265e
@@ -15,4 +15,4 @@ TimeoutSec=0
f6265e
 StandardOutput=journal+console
f6265e
 
f6265e
 [Install]
f6265e
-WantedBy=multi-user.target
f6265e
+WantedBy=cloud-init.target
f6265e
diff --git a/rhel/systemd/cloud-final.service b/rhel/systemd/cloud-final.service
f6265e
index 32a83d8..739b7e3 100644
f6265e
--- a/rhel/systemd/cloud-final.service
f6265e
+++ b/rhel/systemd/cloud-final.service
f6265e
@@ -16,4 +16,4 @@ KillMode=process
f6265e
 StandardOutput=journal+console
f6265e
 
f6265e
 [Install]
f6265e
-WantedBy=multi-user.target
f6265e
+WantedBy=cloud-init.target
f6265e
diff --git a/rhel/systemd/cloud-init-local.service b/rhel/systemd/cloud-init-local.service
f6265e
index 656eddb..8f9f6c9 100644
f6265e
--- a/rhel/systemd/cloud-init-local.service
f6265e
+++ b/rhel/systemd/cloud-init-local.service
f6265e
@@ -28,4 +28,4 @@ TimeoutSec=0
f6265e
 StandardOutput=journal+console
f6265e
 
f6265e
 [Install]
f6265e
-WantedBy=multi-user.target
f6265e
+WantedBy=cloud-init.target
f6265e
diff --git a/rhel/systemd/cloud-init.service b/rhel/systemd/cloud-init.service
f6265e
index 68fc5f1..d0023a0 100644
f6265e
--- a/rhel/systemd/cloud-init.service
f6265e
+++ b/rhel/systemd/cloud-init.service
f6265e
@@ -22,4 +22,4 @@ TimeoutSec=0
f6265e
 StandardOutput=journal+console
f6265e
 
f6265e
 [Install]
f6265e
-WantedBy=multi-user.target
f6265e
+WantedBy=cloud-init.target
f6265e
diff --git a/rhel/systemd/cloud-init.target b/rhel/systemd/cloud-init.target
f6265e
new file mode 100644
f6265e
index 0000000..083c3b6
f6265e
--- /dev/null
f6265e
+++ b/rhel/systemd/cloud-init.target
f6265e
@@ -0,0 +1,7 @@
f6265e
+# cloud-init target is enabled by cloud-init-generator
f6265e
+# To disable it you can either:
f6265e
+#  a.) boot with kernel cmdline of 'cloud-init=disabled'
f6265e
+#  b.) touch a file /etc/cloud/cloud-init.disabled
f6265e
+[Unit]
f6265e
+Description=Cloud-init target
f6265e
+After=multi-user.target
f6265e
-- 
f6265e
1.8.3.1
f6265e