sailesh1993 / rpms / cloud-init

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