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