sailesh1993 / rpms / cloud-init

Forked from rpms/cloud-init a year ago
Clone
604c1f
From d43f0d93386f123892451d923c2b3c6fe7130c39 Mon Sep 17 00:00:00 2001
604c1f
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
604c1f
Date: Thu, 19 May 2022 11:38:22 +0200
604c1f
Subject: [PATCH 4/4] Remove rhel specific files
604c1f
604c1f
RH-Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
604c1f
RH-MergeRequest: 65: Align rhel custom files with upstream (#1431)
604c1f
RH-Commit: [2/2] 5e31f0bcb500682e7746ccbd2e628c2ef339d6c6
604c1f
RH-Bugzilla: 2082071
604c1f
RH-Acked-by: Mohamed Gamal Morsy <mmorsy@redhat.com>
604c1f
RH-Acked-by: Eduardo Otubo <otubo@redhat.com>
604c1f
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
604c1f
604c1f
Remove all files in rhel/ directory and related commands that copy
604c1f
and replace them with the generated ones.
604c1f
604c1f
Also adjust setup.py, align it with upstream:
604c1f
- by default, after rhel 8.3 ds-identify is in /usr/libexec, so no need to move it manually
604c1f
- bash-completions work also in /usr/share, as upstream
604c1f
- udev also works in /lib/udev
604c1f
604c1f
Also remove rhel/README since it is outdated (chef is used in cloud.cfg) and cloud-init-tmpfiles.conf,
604c1f
as it exists also in .distro.
604c1f
604c1f
X-downstream-only: yes
604c1f
604c1f
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
604c1f
---
604c1f
 redhat/cloud-init.spec.template       | 21 ++------
604c1f
 rhel/README.rhel                      |  5 --
604c1f
 rhel/cloud-init-tmpfiles.conf         |  1 -
604c1f
 rhel/cloud.cfg                        | 69 ---------------------------
604c1f
 rhel/systemd/cloud-config.service     | 18 -------
604c1f
 rhel/systemd/cloud-config.target      | 11 -----
604c1f
 rhel/systemd/cloud-final.service      | 24 ----------
604c1f
 rhel/systemd/cloud-init-local.service | 31 ------------
604c1f
 rhel/systemd/cloud-init.service       | 26 ----------
604c1f
 rhel/systemd/cloud-init.target        |  7 ---
604c1f
 setup.py                              | 28 ++++++++++-
604c1f
 11 files changed, 31 insertions(+), 210 deletions(-)
604c1f
 delete mode 100644 rhel/README.rhel
604c1f
 delete mode 100644 rhel/cloud-init-tmpfiles.conf
604c1f
 delete mode 100644 rhel/cloud.cfg
604c1f
 delete mode 100644 rhel/systemd/cloud-config.service
604c1f
 delete mode 100644 rhel/systemd/cloud-config.target
604c1f
 delete mode 100644 rhel/systemd/cloud-final.service
604c1f
 delete mode 100644 rhel/systemd/cloud-init-local.service
604c1f
 delete mode 100644 rhel/systemd/cloud-init.service
604c1f
 delete mode 100644 rhel/systemd/cloud-init.target
604c1f
604c1f
 
604c1f
diff --git a/rhel/README.rhel b/rhel/README.rhel
604c1f
deleted file mode 100644
604c1f
index aa29630d..00000000
604c1f
--- a/rhel/README.rhel
604c1f
+++ /dev/null
604c1f
@@ -1,5 +0,0 @@
604c1f
-The following cloud-init modules are currently unsupported on this OS:
604c1f
- - apt_update_upgrade ('apt_update', 'apt_upgrade', 'apt_mirror', 'apt_preserve_sources_list', 'apt_old_mirror', 'apt_sources', 'debconf_selections', 'packages' options)
604c1f
- - byobu ('byobu_by_default' option)
604c1f
- - chef
604c1f
- - grub_dpkg
604c1f
diff --git a/rhel/cloud-init-tmpfiles.conf b/rhel/cloud-init-tmpfiles.conf
604c1f
deleted file mode 100644
604c1f
index 0c6d2a3b..00000000
604c1f
--- a/rhel/cloud-init-tmpfiles.conf
604c1f
+++ /dev/null
604c1f
@@ -1 +0,0 @@
604c1f
-d /run/cloud-init 0700 root root - -
604c1f
diff --git a/rhel/cloud.cfg b/rhel/cloud.cfg
604c1f
deleted file mode 100644
604c1f
index cbee197a..00000000
604c1f
--- a/rhel/cloud.cfg
604c1f
+++ /dev/null
604c1f
@@ -1,69 +0,0 @@
604c1f
-users:
604c1f
- - default
604c1f
-
604c1f
-disable_root: 1
604c1f
-ssh_pwauth:   0
604c1f
-
604c1f
-mount_default_fields: [~, ~, 'auto', 'defaults,nofail,x-systemd.requires=cloud-init.service', '0', '2']
604c1f
-resize_rootfs_tmp: /dev
604c1f
-ssh_deletekeys:   1
604c1f
-ssh_genkeytypes:  ['rsa', 'ecdsa', 'ed25519']
604c1f
-syslog_fix_perms: ~
604c1f
-disable_vmware_customization: false
604c1f
-
604c1f
-cloud_init_modules:
604c1f
- - disk_setup
604c1f
- - migrator
604c1f
- - bootcmd
604c1f
- - write-files
604c1f
- - growpart
604c1f
- - resizefs
604c1f
- - set_hostname
604c1f
- - update_hostname
604c1f
- - update_etc_hosts
604c1f
- - rsyslog
604c1f
- - users-groups
604c1f
- - ssh
604c1f
-
604c1f
-cloud_config_modules:
604c1f
- - mounts
604c1f
- - locale
604c1f
- - set-passwords
604c1f
- - rh_subscription
604c1f
- - yum-add-repo
604c1f
- - package-update-upgrade-install
604c1f
- - timezone
604c1f
- - puppet
604c1f
- - chef
604c1f
- - salt-minion
604c1f
- - mcollective
604c1f
- - disable-ec2-metadata
604c1f
- - runcmd
604c1f
-
604c1f
-cloud_final_modules:
604c1f
- - rightscale_userdata
604c1f
- - scripts-per-once
604c1f
- - scripts-per-boot
604c1f
- - scripts-per-instance
604c1f
- - scripts-user
604c1f
- - ssh-authkey-fingerprints
604c1f
- - keys-to-console
604c1f
- - phone-home
604c1f
- - final-message
604c1f
- - power-state-change
604c1f
-
604c1f
-system_info:
604c1f
-  default_user:
604c1f
-    name: cloud-user
604c1f
-    lock_passwd: true
604c1f
-    gecos: Cloud User
604c1f
-    groups: [adm, systemd-journal]
604c1f
-    sudo: ["ALL=(ALL) NOPASSWD:ALL"]
604c1f
-    shell: /bin/bash
604c1f
-  distro: rhel
604c1f
-  paths:
604c1f
-    cloud_dir: /var/lib/cloud
604c1f
-    templates_dir: /etc/cloud/templates
604c1f
-  ssh_svcname: sshd
604c1f
-
604c1f
-# vim:syntax=yaml
604c1f
diff --git a/rhel/systemd/cloud-config.service b/rhel/systemd/cloud-config.service
604c1f
deleted file mode 100644
604c1f
index f3dcd4be..00000000
604c1f
--- a/rhel/systemd/cloud-config.service
604c1f
+++ /dev/null
604c1f
@@ -1,18 +0,0 @@
604c1f
-[Unit]
604c1f
-Description=Apply the settings specified in cloud-config
604c1f
-After=network-online.target cloud-config.target
604c1f
-Wants=network-online.target cloud-config.target
604c1f
-ConditionPathExists=!/etc/cloud/cloud-init.disabled
604c1f
-ConditionKernelCommandLine=!cloud-init=disabled
604c1f
-
604c1f
-[Service]
604c1f
-Type=oneshot
604c1f
-ExecStart=/usr/bin/cloud-init modules --mode=config
604c1f
-RemainAfterExit=yes
604c1f
-TimeoutSec=0
604c1f
-
604c1f
-# Output needs to appear in instance console output
604c1f
-StandardOutput=journal+console
604c1f
-
604c1f
-[Install]
604c1f
-WantedBy=cloud-init.target
604c1f
diff --git a/rhel/systemd/cloud-config.target b/rhel/systemd/cloud-config.target
604c1f
deleted file mode 100644
604c1f
index ae9b7d02..00000000
604c1f
--- a/rhel/systemd/cloud-config.target
604c1f
+++ /dev/null
604c1f
@@ -1,11 +0,0 @@
604c1f
-# cloud-init normally emits a "cloud-config" upstart event to inform third
604c1f
-# parties that cloud-config is available, which does us no good when we're
604c1f
-# using systemd.  cloud-config.target serves as this synchronization point
604c1f
-# instead.  Services that would "start on cloud-config" with upstart can
604c1f
-# instead use "After=cloud-config.target" and "Wants=cloud-config.target"
604c1f
-# as appropriate.
604c1f
-
604c1f
-[Unit]
604c1f
-Description=Cloud-config availability
604c1f
-Wants=cloud-init-local.service cloud-init.service
604c1f
-After=cloud-init-local.service cloud-init.service
604c1f
diff --git a/rhel/systemd/cloud-final.service b/rhel/systemd/cloud-final.service
604c1f
deleted file mode 100644
604c1f
index e281c0cf..00000000
604c1f
--- a/rhel/systemd/cloud-final.service
604c1f
+++ /dev/null
604c1f
@@ -1,24 +0,0 @@
604c1f
-[Unit]
604c1f
-Description=Execute cloud user/final scripts
604c1f
-After=network-online.target cloud-config.service rc-local.service
604c1f
-Wants=network-online.target cloud-config.service
604c1f
-ConditionPathExists=!/etc/cloud/cloud-init.disabled
604c1f
-ConditionKernelCommandLine=!cloud-init=disabled
604c1f
-
604c1f
-[Service]
604c1f
-Type=oneshot
604c1f
-ExecStart=/usr/bin/cloud-init modules --mode=final
604c1f
-RemainAfterExit=yes
604c1f
-TimeoutSec=0
604c1f
-KillMode=process
604c1f
-# Restart NetworkManager if it is present and running.
604c1f
-ExecStartPost=/bin/sh -c 'u=NetworkManager.service; \
604c1f
- out=$(systemctl show --property=SubState $u) || exit; \
604c1f
- [ "$out" = "SubState=running" ] || exit 0; \
604c1f
- systemctl reload-or-try-restart $u'
604c1f
-
604c1f
-# Output needs to appear in instance console output
604c1f
-StandardOutput=journal+console
604c1f
-
604c1f
-[Install]
604c1f
-WantedBy=cloud-init.target
604c1f
diff --git a/rhel/systemd/cloud-init-local.service b/rhel/systemd/cloud-init-local.service
604c1f
deleted file mode 100644
604c1f
index 8f9f6c9f..00000000
604c1f
--- a/rhel/systemd/cloud-init-local.service
604c1f
+++ /dev/null
604c1f
@@ -1,31 +0,0 @@
604c1f
-[Unit]
604c1f
-Description=Initial cloud-init job (pre-networking)
604c1f
-DefaultDependencies=no
604c1f
-Wants=network-pre.target
604c1f
-After=systemd-remount-fs.service
604c1f
-Requires=dbus.socket
604c1f
-After=dbus.socket
604c1f
-Before=NetworkManager.service network.service
604c1f
-Before=network-pre.target
604c1f
-Before=shutdown.target
604c1f
-Before=firewalld.target
604c1f
-Conflicts=shutdown.target
604c1f
-RequiresMountsFor=/var/lib/cloud
604c1f
-ConditionPathExists=!/etc/cloud/cloud-init.disabled
604c1f
-ConditionKernelCommandLine=!cloud-init=disabled
604c1f
-
604c1f
-[Service]
604c1f
-Type=oneshot
604c1f
-ExecStartPre=/bin/mkdir -p /run/cloud-init
604c1f
-ExecStartPre=/sbin/restorecon /run/cloud-init
604c1f
-ExecStartPre=/usr/bin/touch /run/cloud-init/enabled
604c1f
-ExecStart=/usr/bin/cloud-init init --local
604c1f
-ExecStart=/bin/touch /run/cloud-init/network-config-ready
604c1f
-RemainAfterExit=yes
604c1f
-TimeoutSec=0
604c1f
-
604c1f
-# Output needs to appear in instance console output
604c1f
-StandardOutput=journal+console
604c1f
-
604c1f
-[Install]
604c1f
-WantedBy=cloud-init.target
604c1f
diff --git a/rhel/systemd/cloud-init.service b/rhel/systemd/cloud-init.service
604c1f
deleted file mode 100644
604c1f
index 0b3d796d..00000000
604c1f
--- a/rhel/systemd/cloud-init.service
604c1f
+++ /dev/null
604c1f
@@ -1,26 +0,0 @@
604c1f
-[Unit]
604c1f
-Description=Initial cloud-init job (metadata service crawler)
604c1f
-Wants=cloud-init-local.service
604c1f
-Wants=sshd-keygen.service
604c1f
-Wants=sshd.service
604c1f
-After=cloud-init-local.service
604c1f
-After=NetworkManager.service network.service
604c1f
-After=NetworkManager-wait-online.service
604c1f
-Before=network-online.target
604c1f
-Before=sshd-keygen.service
604c1f
-Before=sshd.service
604c1f
-Before=systemd-user-sessions.service
604c1f
-ConditionPathExists=!/etc/cloud/cloud-init.disabled
604c1f
-ConditionKernelCommandLine=!cloud-init=disabled
604c1f
-
604c1f
-[Service]
604c1f
-Type=oneshot
604c1f
-ExecStart=/usr/bin/cloud-init init
604c1f
-RemainAfterExit=yes
604c1f
-TimeoutSec=0
604c1f
-
604c1f
-# Output needs to appear in instance console output
604c1f
-StandardOutput=journal+console
604c1f
-
604c1f
-[Install]
604c1f
-WantedBy=cloud-init.target
604c1f
diff --git a/rhel/systemd/cloud-init.target b/rhel/systemd/cloud-init.target
604c1f
deleted file mode 100644
604c1f
index 083c3b6f..00000000
604c1f
--- a/rhel/systemd/cloud-init.target
604c1f
+++ /dev/null
604c1f
@@ -1,7 +0,0 @@
604c1f
-# cloud-init target is enabled by cloud-init-generator
604c1f
-# To disable it you can either:
604c1f
-#  a.) boot with kernel cmdline of 'cloud-init=disabled'
604c1f
-#  b.) touch a file /etc/cloud/cloud-init.disabled
604c1f
-[Unit]
604c1f
-Description=Cloud-init target
604c1f
-After=multi-user.target
604c1f
diff --git a/setup.py b/setup.py
604c1f
index 3c377eaa..a9132d2c 100755
604c1f
--- a/setup.py
604c1f
+++ b/setup.py
604c1f
@@ -139,6 +139,21 @@ INITSYS_FILES = {
604c1f
     "sysvinit_deb": [f for f in glob("sysvinit/debian/*") if is_f(f)],
604c1f
     "sysvinit_openrc": [f for f in glob("sysvinit/gentoo/*") if is_f(f)],
604c1f
     "sysvinit_suse": [f for f in glob("sysvinit/suse/*") if is_f(f)],
604c1f
+    "systemd": [
604c1f
+        render_tmpl(f)
604c1f
+        for f in (
604c1f
+            glob("systemd/*.tmpl")
604c1f
+            + glob("systemd/*.service")
604c1f
+            + glob("systemd/*.socket")
604c1f
+            + glob("systemd/*.target")
604c1f
+        )
604c1f
+        if (is_f(f) and not is_generator(f))
604c1f
+    ],
604c1f
+    "systemd.generators": [
604c1f
+        render_tmpl(f, mode=0o755)
604c1f
+        for f in glob("systemd/*")
604c1f
+        if is_f(f) and is_generator(f)
604c1f
+    ],
604c1f
     "upstart": [f for f in glob("upstart/*") if is_f(f)],
604c1f
 }
604c1f
 INITSYS_ROOTS = {
604c1f
@@ -148,6 +163,10 @@ INITSYS_ROOTS = {
604c1f
     "sysvinit_deb": "etc/init.d",
604c1f
     "sysvinit_openrc": "etc/init.d",
604c1f
     "sysvinit_suse": "etc/init.d",
604c1f
+    "systemd": pkg_config_read("systemd", "systemdsystemunitdir"),
604c1f
+    "systemd.generators": pkg_config_read(
604c1f
+        "systemd", "systemdsystemgeneratordir"
604c1f
+    ),
604c1f
     "upstart": "etc/init/",
604c1f
 }
604c1f
 INITSYS_TYPES = sorted([f.partition(".")[0] for f in INITSYS_ROOTS.keys()])
604c1f
@@ -262,13 +281,15 @@ data_files = [
604c1f
     (
604c1f
         USR_LIB_EXEC + "/cloud-init",
604c1f
         [
604c1f
+            "tools/ds-identify",
604c1f
             "tools/hook-hotplug",
604c1f
             "tools/uncloud-init",
604c1f
             "tools/write-ssh-key-fingerprints",
604c1f
         ],
604c1f
     ),
604c1f
     (
604c1f
-        ETC + "/bash_completion.d", ["bash_completion/cloud-init"],
604c1f
+        USR + "/share/bash-completion/completions",
604c1f
+        ["bash_completion/cloud-init"],
604c1f
     ),
604c1f
     (USR + "/share/doc/cloud-init", [f for f in glob("doc/*") if is_f(f)]),
604c1f
     (
604c1f
@@ -287,7 +308,8 @@ if not platform.system().endswith("BSD"):
604c1f
                 ETC + "/NetworkManager/dispatcher.d/",
604c1f
                 ["tools/hook-network-manager"],
604c1f
             ),
604c1f
-            ("/usr/lib/udev/rules.d", [f for f in glob("udev/*.rules")]),
604c1f
+            (ETC + "/dhcp/dhclient-exit-hooks.d/", ["tools/hook-dhclient"]),
604c1f
+            (LIB + "/udev/rules.d", [f for f in glob("udev/*.rules")]),
604c1f
             (
604c1f
                 ETC + "/systemd/system/sshd-keygen@.service.d/",
604c1f
                 ["systemd/disable-sshd-keygen-if-cloud-init-active.conf"],
604c1f
@@ -317,6 +339,8 @@ setuptools.setup(
604c1f
     scripts=["tools/cloud-init-per"],
604c1f
     license="Dual-licensed under GPLv3 or Apache 2.0",
604c1f
     data_files=data_files,
604c1f
+    install_requires=requirements,
604c1f
+    cmdclass=cmdclass,
604c1f
     entry_points={
604c1f
         "console_scripts": [
604c1f
             "cloud-init = cloudinit.cmd.main:main",
604c1f
-- 
604c1f
2.35.3
604c1f