sailesh1993 / rpms / cloud-init

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