sailesh1993 / rpms / cloud-init

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