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