c36ff1
From 4b84d29211b7b2121afe9045c71ded5381536d8b Mon Sep 17 00:00:00 2001
c36ff1
From: Eduardo Otubo <otubo@redhat.com>
c36ff1
Date: Fri, 7 May 2021 13:36:03 +0200
c36ff1
Subject: Add initial redhat setup
c36ff1
c36ff1
Merged patches (RHEL-9/21.1):
c36ff1
- 5688a1d0 Removing python-nose and python-tox as dependency
c36ff1
- 237d57f9 Removing mock dependency
c36ff1
- d1c2f496 Removing python-jsonschema dependency
c36ff1
- 0d1cd14c Don't override default network configuration
c36ff1
c36ff1
Merged patches (21.1):
c36ff1
- 915d30ad Change gating file to correct rhel version
c36ff1
- 311f318d Removing net-tools dependency
c36ff1
- 74731806 Adding man pages to Red Hat spec file
c36ff1
- 758d333d Removing blocking test from yaml configuration file
c36ff1
- c7e7c59c Changing permission of cloud-init-generator to 755
c36ff1
- 8b85abbb Installing man pages in the correct place with correct permissions
c36ff1
- c6808d8d Fix unit failure of cloud-final.service if NetworkManager was not present.
c36ff1
- 11866ef6 Report full specific version with "cloud-init --version"
c36ff1
c36ff1
Rebase notes (18.5):
c36ff1
- added bash_completition file
c36ff1
- added cloud-id file
c36ff1
c36ff1
Merged patches (20.3):
c36ff1
- 01900d0 changing ds-identify patch from /usr/lib to /usr/libexec
c36ff1
- 7f47ca3 Render the generator from template instead of cp
c36ff1
c36ff1
Merged patches (19.4):
c36ff1
- 4ab5a61 Fix for network configuration not persisting after reboot
c36ff1
- 84cf125 Removing cloud-user from wheel
c36ff1
- 31290ab Adding gating tests for Azure, ESXi and AWS
c36ff1
c36ff1
Merged patches (18.5):
c36ff1
- 2d6b469 add power-state-change module to cloud_final_modules
c36ff1
- 764159f Adding systemd mount options to wait for cloud-init
c36ff1
- da4d99e Adding disk_setup to rhel/cloud.cfg
c36ff1
- f5c6832 Enable cloud-init by default on vmware
c36ff1
c36ff1
Conflicts:
c36ff1
cloudinit/config/cc_chef.py:
c36ff1
 - Updated header documentation text
c36ff1
 - Replacing double quotes by simple quotes
c36ff1
c36ff1
setup.py:
c36ff1
 - Adding missing cmdclass info
c36ff1
c36ff1
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
c36ff1
c36ff1
Changes:
c36ff1
- move redhat to .distro to use new build script structure
c36ff1
- Fixing changelog for RHEL 9
c36ff1
c36ff1
Merged patches (21.1):
c36ff1
- 69bd7f71 DataSourceAzure.py: use hostnamectl to set hostname
c36ff1
- 0407867e Remove race condition between cloud-init and NetworkManager
c36ff1
c36ff1
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
c36ff1
---
c36ff1
 .distro/.gitignore                    |   1 +
c36ff1
 .distro/Makefile                      |  74 +++++
c36ff1
 .distro/Makefile.common               |  30 ++
c36ff1
 .distro/cloud-init-tmpfiles.conf      |   1 +
c36ff1
 .distro/cloud-init.spec.template      | 383 ++++++++++++++++++++++++++
c36ff1
 .distro/gating.yaml                   |   8 +
c36ff1
 .distro/rpmbuild/BUILD/.gitignore     |   3 +
c36ff1
 .distro/rpmbuild/RPMS/.gitignore      |   3 +
c36ff1
 .distro/rpmbuild/SOURCES/.gitignore   |   3 +
c36ff1
 .distro/rpmbuild/SPECS/.gitignore     |   3 +
c36ff1
 .distro/rpmbuild/SRPMS/.gitignore     |   3 +
c36ff1
 .distro/scripts/frh.py                |  27 ++
c36ff1
 .distro/scripts/git-backport-diff     | 327 ++++++++++++++++++++++
c36ff1
 .distro/scripts/git-compile-check     | 215 +++++++++++++++
c36ff1
 .distro/scripts/process-patches.sh    |  88 ++++++
c36ff1
 .distro/scripts/tarball_checksum.sh   |   3 +
c36ff1
 .gitignore                            |   1 +
c36ff1
 cloudinit/config/cc_chef.py           |  67 ++++-
c36ff1
 cloudinit/settings.py                 |   7 +-
c36ff1
 cloudinit/sources/DataSourceAzure.py  |   2 +-
c36ff1
 requirements.txt                      |   3 -
c36ff1
 rhel/README.rhel                      |   5 +
c36ff1
 rhel/cloud-init-tmpfiles.conf         |   1 +
c36ff1
 rhel/cloud.cfg                        |  69 +++++
c36ff1
 rhel/systemd/cloud-config.service     |  18 ++
c36ff1
 rhel/systemd/cloud-config.target      |  11 +
c36ff1
 rhel/systemd/cloud-final.service      |  24 ++
c36ff1
 rhel/systemd/cloud-init-local.service |  31 +++
c36ff1
 rhel/systemd/cloud-init.service       |  26 ++
c36ff1
 rhel/systemd/cloud-init.target        |   7 +
c36ff1
 setup.py                              |  23 +-
c36ff1
 tools/read-version                    |  28 +-
c36ff1
 32 files changed, 1441 insertions(+), 54 deletions(-)
c36ff1
 create mode 100644 .distro/.gitignore
c36ff1
 create mode 100644 .distro/Makefile
c36ff1
 create mode 100644 .distro/Makefile.common
c36ff1
 create mode 100644 .distro/cloud-init-tmpfiles.conf
c36ff1
 create mode 100644 .distro/cloud-init.spec.template
c36ff1
 create mode 100644 .distro/gating.yaml
c36ff1
 create mode 100644 .distro/rpmbuild/BUILD/.gitignore
c36ff1
 create mode 100644 .distro/rpmbuild/RPMS/.gitignore
c36ff1
 create mode 100644 .distro/rpmbuild/SOURCES/.gitignore
c36ff1
 create mode 100644 .distro/rpmbuild/SPECS/.gitignore
c36ff1
 create mode 100644 .distro/rpmbuild/SRPMS/.gitignore
c36ff1
 create mode 100755 .distro/scripts/frh.py
c36ff1
 create mode 100755 .distro/scripts/git-backport-diff
c36ff1
 create mode 100755 .distro/scripts/git-compile-check
c36ff1
 create mode 100755 .distro/scripts/process-patches.sh
c36ff1
 create mode 100755 .distro/scripts/tarball_checksum.sh
c36ff1
 create mode 100644 rhel/README.rhel
c36ff1
 create mode 100644 rhel/cloud-init-tmpfiles.conf
c36ff1
 create mode 100644 rhel/cloud.cfg
c36ff1
 create mode 100644 rhel/systemd/cloud-config.service
c36ff1
 create mode 100644 rhel/systemd/cloud-config.target
c36ff1
 create mode 100644 rhel/systemd/cloud-final.service
c36ff1
 create mode 100644 rhel/systemd/cloud-init-local.service
c36ff1
 create mode 100644 rhel/systemd/cloud-init.service
c36ff1
 create mode 100644 rhel/systemd/cloud-init.target
c36ff1
c36ff1
diff --git a/cloudinit/config/cc_chef.py b/cloudinit/config/cc_chef.py
c36ff1
index aaf71366..97ef649a 100644
c36ff1
--- a/cloudinit/config/cc_chef.py
c36ff1
+++ b/cloudinit/config/cc_chef.py
c36ff1
@@ -6,7 +6,70 @@
c36ff1
 #
c36ff1
 # This file is part of cloud-init. See LICENSE file for license information.
c36ff1
 
c36ff1
-"""Chef: module that configures, starts and installs chef."""
c36ff1
+"""
c36ff1
+Chef
c36ff1
+----
c36ff1
+**Summary:** module that configures, starts and installs chef.
c36ff1
+
c36ff1
+This module enables chef to be installed (from packages or
c36ff1
+from gems, or from omnibus). Before this occurs chef configurations are
c36ff1
+written to disk (validation.pem, client.pem, firstboot.json, client.rb),
c36ff1
+and needed chef folders/directories are created (/etc/chef and /var/log/chef
c36ff1
+and so-on). Then once installing proceeds correctly if configured chef will
c36ff1
+be started (in daemon mode or in non-daemon mode) and then once that has
c36ff1
+finished (if ran in non-daemon mode this will be when chef finishes
c36ff1
+converging, if ran in daemon mode then no further actions are possible since
c36ff1
+chef will have forked into its own process) then a post run function can
c36ff1
+run that can do finishing activities (such as removing the validation pem
c36ff1
+file).
c36ff1
+
c36ff1
+**Internal name:** ``cc_chef``
c36ff1
+
c36ff1
+**Module frequency:** per always
c36ff1
+
c36ff1
+**Supported distros:** all
c36ff1
+
c36ff1
+**Config keys**::
c36ff1
+
c36ff1
+    chef:
c36ff1
+       directories: (defaulting to /etc/chef, /var/log/chef, /var/lib/chef,
c36ff1
+                     /var/cache/chef, /var/backups/chef, /run/chef)
c36ff1
+       validation_cert: (optional string to be written to file validation_key)
c36ff1
+                        special value 'system' means set use existing file
c36ff1
+       validation_key: (optional the path for validation_cert. default
c36ff1
+                        /etc/chef/validation.pem)
c36ff1
+       firstboot_path: (path to write run_list and initial_attributes keys that
c36ff1
+                        should also be present in this configuration, defaults
c36ff1
+                        to /etc/chef/firstboot.json)
c36ff1
+       exec: boolean to run or not run chef (defaults to false, unless
c36ff1
+                                             a gem installed is requested
c36ff1
+                                             where this will then default
c36ff1
+                                             to true)
c36ff1
+
c36ff1
+    chef.rb template keys (if falsey, then will be skipped and not
c36ff1
+                           written to /etc/chef/client.rb)
c36ff1
+
c36ff1
+    chef:
c36ff1
+      client_key:
c36ff1
+      encrypted_data_bag_secret:
c36ff1
+      environment:
c36ff1
+      file_backup_path:
c36ff1
+      file_cache_path:
c36ff1
+      json_attribs:
c36ff1
+      log_level:
c36ff1
+      log_location:
c36ff1
+      node_name:
c36ff1
+      omnibus_url:
c36ff1
+      omnibus_url_retries:
c36ff1
+      omnibus_version:
c36ff1
+      pid_file:
c36ff1
+      server_url:
c36ff1
+      show_time:
c36ff1
+      ssl_verify_mode:
c36ff1
+      validation_cert:
c36ff1
+      validation_key:
c36ff1
+      validation_name:
c36ff1
+"""
c36ff1
 
c36ff1
 import itertools
c36ff1
 import json
c36ff1
@@ -31,7 +94,7 @@ CHEF_DIRS = tuple([
c36ff1
     '/var/lib/chef',
c36ff1
     '/var/cache/chef',
c36ff1
     '/var/backups/chef',
c36ff1
-    '/var/run/chef',
c36ff1
+    '/run/chef',
c36ff1
 ])
c36ff1
 REQUIRED_CHEF_DIRS = tuple([
c36ff1
     '/etc/chef',
c36ff1
diff --git a/cloudinit/settings.py b/cloudinit/settings.py
c36ff1
index 91e1bfe7..e690c0fd 100644
c36ff1
--- a/cloudinit/settings.py
c36ff1
+++ b/cloudinit/settings.py
c36ff1
@@ -47,13 +47,16 @@ CFG_BUILTIN = {
c36ff1
     ],
c36ff1
     'def_log_file': '/var/log/cloud-init.log',
c36ff1
     'log_cfgs': [],
c36ff1
-    'syslog_fix_perms': ['syslog:adm', 'root:adm', 'root:wheel', 'root:root'],
c36ff1
+    'mount_default_fields': [None, None, 'auto', 'defaults,nofail', '0', '2'],
c36ff1
+    'ssh_deletekeys': False,
c36ff1
+    'ssh_genkeytypes': [],
c36ff1
+    'syslog_fix_perms': [],
c36ff1
     'system_info': {
c36ff1
         'paths': {
c36ff1
             'cloud_dir': '/var/lib/cloud',
c36ff1
             'templates_dir': '/etc/cloud/templates/',
c36ff1
         },
c36ff1
-        'distro': 'ubuntu',
c36ff1
+        'distro': 'rhel',
c36ff1
         'network': {'renderers': None},
c36ff1
     },
c36ff1
     'vendor_data': {'enabled': True, 'prefix': []},
c36ff1
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
c36ff1
index cee630f7..553b5a7e 100755
c36ff1
--- a/cloudinit/sources/DataSourceAzure.py
c36ff1
+++ b/cloudinit/sources/DataSourceAzure.py
c36ff1
@@ -296,7 +296,7 @@ def get_hostname(hostname_command='hostname'):
c36ff1
 
c36ff1
 
c36ff1
 def set_hostname(hostname, hostname_command='hostname'):
c36ff1
-    subp.subp([hostname_command, hostname])
c36ff1
+    util.subp(['hostnamectl', 'set-hostname', str(hostname)])
c36ff1
 
c36ff1
 
c36ff1
 @azure_ds_telemetry_reporter
c36ff1
diff --git a/requirements.txt b/requirements.txt
c36ff1
index 5817da3b..5b8becd7 100644
c36ff1
--- a/requirements.txt
c36ff1
+++ b/requirements.txt
c36ff1
@@ -29,6 +29,3 @@ requests
c36ff1
 
c36ff1
 # For patching pieces of cloud-config together
c36ff1
 jsonpatch
c36ff1
-
c36ff1
-# For validating cloud-config sections per schema definitions
c36ff1
-jsonschema
c36ff1
diff --git a/rhel/README.rhel b/rhel/README.rhel
c36ff1
new file mode 100644
c36ff1
index 00000000..aa29630d
c36ff1
--- /dev/null
c36ff1
+++ b/rhel/README.rhel
c36ff1
@@ -0,0 +1,5 @@
c36ff1
+The following cloud-init modules are currently unsupported on this OS:
c36ff1
+ - apt_update_upgrade ('apt_update', 'apt_upgrade', 'apt_mirror', 'apt_preserve_sources_list', 'apt_old_mirror', 'apt_sources', 'debconf_selections', 'packages' options)
c36ff1
+ - byobu ('byobu_by_default' option)
c36ff1
+ - chef
c36ff1
+ - grub_dpkg
c36ff1
diff --git a/rhel/cloud-init-tmpfiles.conf b/rhel/cloud-init-tmpfiles.conf
c36ff1
new file mode 100644
c36ff1
index 00000000..0c6d2a3b
c36ff1
--- /dev/null
c36ff1
+++ b/rhel/cloud-init-tmpfiles.conf
c36ff1
@@ -0,0 +1 @@
c36ff1
+d /run/cloud-init 0700 root root - -
c36ff1
diff --git a/rhel/cloud.cfg b/rhel/cloud.cfg
c36ff1
new file mode 100644
c36ff1
index 00000000..9ecba215
c36ff1
--- /dev/null
c36ff1
+++ b/rhel/cloud.cfg
c36ff1
@@ -0,0 +1,69 @@
c36ff1
+users:
c36ff1
+ - default
c36ff1
+
c36ff1
+disable_root: 1
c36ff1
+ssh_pwauth:   0
c36ff1
+
c36ff1
+mount_default_fields: [~, ~, 'auto', 'defaults,nofail,x-systemd.requires=cloud-init.service', '0', '2']
c36ff1
+resize_rootfs_tmp: /dev
c36ff1
+ssh_deletekeys:   1
c36ff1
+ssh_genkeytypes:  ~
c36ff1
+syslog_fix_perms: ~
c36ff1
+disable_vmware_customization: false
c36ff1
+
c36ff1
+cloud_init_modules:
c36ff1
+ - disk_setup
c36ff1
+ - migrator
c36ff1
+ - bootcmd
c36ff1
+ - write-files
c36ff1
+ - growpart
c36ff1
+ - resizefs
c36ff1
+ - set_hostname
c36ff1
+ - update_hostname
c36ff1
+ - update_etc_hosts
c36ff1
+ - rsyslog
c36ff1
+ - users-groups
c36ff1
+ - ssh
c36ff1
+
c36ff1
+cloud_config_modules:
c36ff1
+ - mounts
c36ff1
+ - locale
c36ff1
+ - set-passwords
c36ff1
+ - rh_subscription
c36ff1
+ - yum-add-repo
c36ff1
+ - package-update-upgrade-install
c36ff1
+ - timezone
c36ff1
+ - puppet
c36ff1
+ - chef
c36ff1
+ - salt-minion
c36ff1
+ - mcollective
c36ff1
+ - disable-ec2-metadata
c36ff1
+ - runcmd
c36ff1
+
c36ff1
+cloud_final_modules:
c36ff1
+ - rightscale_userdata
c36ff1
+ - scripts-per-once
c36ff1
+ - scripts-per-boot
c36ff1
+ - scripts-per-instance
c36ff1
+ - scripts-user
c36ff1
+ - ssh-authkey-fingerprints
c36ff1
+ - keys-to-console
c36ff1
+ - phone-home
c36ff1
+ - final-message
c36ff1
+ - power-state-change
c36ff1
+
c36ff1
+system_info:
c36ff1
+  default_user:
c36ff1
+    name: cloud-user
c36ff1
+    lock_passwd: true
c36ff1
+    gecos: Cloud User
c36ff1
+    groups: [adm, systemd-journal]
c36ff1
+    sudo: ["ALL=(ALL) NOPASSWD:ALL"]
c36ff1
+    shell: /bin/bash
c36ff1
+  distro: rhel
c36ff1
+  paths:
c36ff1
+    cloud_dir: /var/lib/cloud
c36ff1
+    templates_dir: /etc/cloud/templates
c36ff1
+  ssh_svcname: sshd
c36ff1
+
c36ff1
+# vim:syntax=yaml
c36ff1
diff --git a/rhel/systemd/cloud-config.service b/rhel/systemd/cloud-config.service
c36ff1
new file mode 100644
c36ff1
index 00000000..f3dcd4be
c36ff1
--- /dev/null
c36ff1
+++ b/rhel/systemd/cloud-config.service
c36ff1
@@ -0,0 +1,18 @@
c36ff1
+[Unit]
c36ff1
+Description=Apply the settings specified in cloud-config
c36ff1
+After=network-online.target cloud-config.target
c36ff1
+Wants=network-online.target cloud-config.target
c36ff1
+ConditionPathExists=!/etc/cloud/cloud-init.disabled
c36ff1
+ConditionKernelCommandLine=!cloud-init=disabled
c36ff1
+
c36ff1
+[Service]
c36ff1
+Type=oneshot
c36ff1
+ExecStart=/usr/bin/cloud-init modules --mode=config
c36ff1
+RemainAfterExit=yes
c36ff1
+TimeoutSec=0
c36ff1
+
c36ff1
+# Output needs to appear in instance console output
c36ff1
+StandardOutput=journal+console
c36ff1
+
c36ff1
+[Install]
c36ff1
+WantedBy=cloud-init.target
c36ff1
diff --git a/rhel/systemd/cloud-config.target b/rhel/systemd/cloud-config.target
c36ff1
new file mode 100644
c36ff1
index 00000000..ae9b7d02
c36ff1
--- /dev/null
c36ff1
+++ b/rhel/systemd/cloud-config.target
c36ff1
@@ -0,0 +1,11 @@
c36ff1
+# cloud-init normally emits a "cloud-config" upstart event to inform third
c36ff1
+# parties that cloud-config is available, which does us no good when we're
c36ff1
+# using systemd.  cloud-config.target serves as this synchronization point
c36ff1
+# instead.  Services that would "start on cloud-config" with upstart can
c36ff1
+# instead use "After=cloud-config.target" and "Wants=cloud-config.target"
c36ff1
+# as appropriate.
c36ff1
+
c36ff1
+[Unit]
c36ff1
+Description=Cloud-config availability
c36ff1
+Wants=cloud-init-local.service cloud-init.service
c36ff1
+After=cloud-init-local.service cloud-init.service
c36ff1
diff --git a/rhel/systemd/cloud-final.service b/rhel/systemd/cloud-final.service
c36ff1
new file mode 100644
c36ff1
index 00000000..e281c0cf
c36ff1
--- /dev/null
c36ff1
+++ b/rhel/systemd/cloud-final.service
c36ff1
@@ -0,0 +1,24 @@
c36ff1
+[Unit]
c36ff1
+Description=Execute cloud user/final scripts
c36ff1
+After=network-online.target cloud-config.service rc-local.service
c36ff1
+Wants=network-online.target cloud-config.service
c36ff1
+ConditionPathExists=!/etc/cloud/cloud-init.disabled
c36ff1
+ConditionKernelCommandLine=!cloud-init=disabled
c36ff1
+
c36ff1
+[Service]
c36ff1
+Type=oneshot
c36ff1
+ExecStart=/usr/bin/cloud-init modules --mode=final
c36ff1
+RemainAfterExit=yes
c36ff1
+TimeoutSec=0
c36ff1
+KillMode=process
c36ff1
+# Restart NetworkManager if it is present and running.
c36ff1
+ExecStartPost=/bin/sh -c 'u=NetworkManager.service; \
c36ff1
+ out=$(systemctl show --property=SubState $u) || exit; \
c36ff1
+ [ "$out" = "SubState=running" ] || exit 0; \
c36ff1
+ systemctl reload-or-try-restart $u'
c36ff1
+
c36ff1
+# Output needs to appear in instance console output
c36ff1
+StandardOutput=journal+console
c36ff1
+
c36ff1
+[Install]
c36ff1
+WantedBy=cloud-init.target
c36ff1
diff --git a/rhel/systemd/cloud-init-local.service b/rhel/systemd/cloud-init-local.service
c36ff1
new file mode 100644
c36ff1
index 00000000..8f9f6c9f
c36ff1
--- /dev/null
c36ff1
+++ b/rhel/systemd/cloud-init-local.service
c36ff1
@@ -0,0 +1,31 @@
c36ff1
+[Unit]
c36ff1
+Description=Initial cloud-init job (pre-networking)
c36ff1
+DefaultDependencies=no
c36ff1
+Wants=network-pre.target
c36ff1
+After=systemd-remount-fs.service
c36ff1
+Requires=dbus.socket
c36ff1
+After=dbus.socket
c36ff1
+Before=NetworkManager.service network.service
c36ff1
+Before=network-pre.target
c36ff1
+Before=shutdown.target
c36ff1
+Before=firewalld.target
c36ff1
+Conflicts=shutdown.target
c36ff1
+RequiresMountsFor=/var/lib/cloud
c36ff1
+ConditionPathExists=!/etc/cloud/cloud-init.disabled
c36ff1
+ConditionKernelCommandLine=!cloud-init=disabled
c36ff1
+
c36ff1
+[Service]
c36ff1
+Type=oneshot
c36ff1
+ExecStartPre=/bin/mkdir -p /run/cloud-init
c36ff1
+ExecStartPre=/sbin/restorecon /run/cloud-init
c36ff1
+ExecStartPre=/usr/bin/touch /run/cloud-init/enabled
c36ff1
+ExecStart=/usr/bin/cloud-init init --local
c36ff1
+ExecStart=/bin/touch /run/cloud-init/network-config-ready
c36ff1
+RemainAfterExit=yes
c36ff1
+TimeoutSec=0
c36ff1
+
c36ff1
+# Output needs to appear in instance console output
c36ff1
+StandardOutput=journal+console
c36ff1
+
c36ff1
+[Install]
c36ff1
+WantedBy=cloud-init.target
c36ff1
diff --git a/rhel/systemd/cloud-init.service b/rhel/systemd/cloud-init.service
c36ff1
new file mode 100644
c36ff1
index 00000000..0b3d796d
c36ff1
--- /dev/null
c36ff1
+++ b/rhel/systemd/cloud-init.service
c36ff1
@@ -0,0 +1,26 @@
c36ff1
+[Unit]
c36ff1
+Description=Initial cloud-init job (metadata service crawler)
c36ff1
+Wants=cloud-init-local.service
c36ff1
+Wants=sshd-keygen.service
c36ff1
+Wants=sshd.service
c36ff1
+After=cloud-init-local.service
c36ff1
+After=NetworkManager.service network.service
c36ff1
+After=NetworkManager-wait-online.service
c36ff1
+Before=network-online.target
c36ff1
+Before=sshd-keygen.service
c36ff1
+Before=sshd.service
c36ff1
+Before=systemd-user-sessions.service
c36ff1
+ConditionPathExists=!/etc/cloud/cloud-init.disabled
c36ff1
+ConditionKernelCommandLine=!cloud-init=disabled
c36ff1
+
c36ff1
+[Service]
c36ff1
+Type=oneshot
c36ff1
+ExecStart=/usr/bin/cloud-init init
c36ff1
+RemainAfterExit=yes
c36ff1
+TimeoutSec=0
c36ff1
+
c36ff1
+# Output needs to appear in instance console output
c36ff1
+StandardOutput=journal+console
c36ff1
+
c36ff1
+[Install]
c36ff1
+WantedBy=cloud-init.target
c36ff1
diff --git a/rhel/systemd/cloud-init.target b/rhel/systemd/cloud-init.target
c36ff1
new file mode 100644
c36ff1
index 00000000..083c3b6f
c36ff1
--- /dev/null
c36ff1
+++ b/rhel/systemd/cloud-init.target
c36ff1
@@ -0,0 +1,7 @@
c36ff1
+# cloud-init target is enabled by cloud-init-generator
c36ff1
+# To disable it you can either:
c36ff1
+#  a.) boot with kernel cmdline of 'cloud-init=disabled'
c36ff1
+#  b.) touch a file /etc/cloud/cloud-init.disabled
c36ff1
+[Unit]
c36ff1
+Description=Cloud-init target
c36ff1
+After=multi-user.target
c36ff1
diff --git a/setup.py b/setup.py
c36ff1
index cbacf48e..d5cd01a4 100755
c36ff1
--- a/setup.py
c36ff1
+++ b/setup.py
c36ff1
@@ -125,14 +125,6 @@ INITSYS_FILES = {
c36ff1
     'sysvinit_deb': [f for f in glob('sysvinit/debian/*') if is_f(f)],
c36ff1
     'sysvinit_openrc': [f for f in glob('sysvinit/gentoo/*') if is_f(f)],
c36ff1
     'sysvinit_suse': [f for f in glob('sysvinit/suse/*') if is_f(f)],
c36ff1
-    'systemd': [render_tmpl(f)
c36ff1
-                for f in (glob('systemd/*.tmpl') +
c36ff1
-                          glob('systemd/*.service') +
c36ff1
-                          glob('systemd/*.target'))
c36ff1
-                if (is_f(f) and not is_generator(f))],
c36ff1
-    'systemd.generators': [
c36ff1
-        render_tmpl(f, mode=0o755)
c36ff1
-        for f in glob('systemd/*') if is_f(f) and is_generator(f)],
c36ff1
     'upstart': [f for f in glob('upstart/*') if is_f(f)],
c36ff1
 }
c36ff1
 INITSYS_ROOTS = {
c36ff1
@@ -142,9 +134,6 @@ INITSYS_ROOTS = {
c36ff1
     'sysvinit_deb': 'etc/init.d',
c36ff1
     'sysvinit_openrc': 'etc/init.d',
c36ff1
     'sysvinit_suse': 'etc/init.d',
c36ff1
-    'systemd': pkg_config_read('systemd', 'systemdsystemunitdir'),
c36ff1
-    'systemd.generators': pkg_config_read('systemd',
c36ff1
-                                          'systemdsystemgeneratordir'),
c36ff1
     'upstart': 'etc/init/',
c36ff1
 }
c36ff1
 INITSYS_TYPES = sorted([f.partition(".")[0] for f in INITSYS_ROOTS.keys()])
c36ff1
@@ -245,14 +234,11 @@ if not in_virtualenv():
c36ff1
         INITSYS_ROOTS[k] = "/" + INITSYS_ROOTS[k]
c36ff1
 
c36ff1
 data_files = [
c36ff1
-    (ETC + '/cloud', [render_tmpl("config/cloud.cfg.tmpl")]),
c36ff1
+    (ETC + '/bash_completion.d', ['bash_completion/cloud-init']),
c36ff1
     (ETC + '/cloud/cloud.cfg.d', glob('config/cloud.cfg.d/*')),
c36ff1
     (ETC + '/cloud/templates', glob('templates/*')),
c36ff1
-    (USR_LIB_EXEC + '/cloud-init', ['tools/ds-identify',
c36ff1
-                                    'tools/uncloud-init',
c36ff1
+    (USR_LIB_EXEC + '/cloud-init', ['tools/uncloud-init',
c36ff1
                                     'tools/write-ssh-key-fingerprints']),
c36ff1
-    (USR + '/share/bash-completion/completions',
c36ff1
-     ['bash_completion/cloud-init']),
c36ff1
     (USR + '/share/doc/cloud-init', [f for f in glob('doc/*') if is_f(f)]),
c36ff1
     (USR + '/share/doc/cloud-init/examples',
c36ff1
         [f for f in glob('doc/examples/*') if is_f(f)]),
c36ff1
@@ -263,8 +249,7 @@ if not platform.system().endswith('BSD'):
c36ff1
     data_files.extend([
c36ff1
         (ETC + '/NetworkManager/dispatcher.d/',
c36ff1
          ['tools/hook-network-manager']),
c36ff1
-        (ETC + '/dhcp/dhclient-exit-hooks.d/', ['tools/hook-dhclient']),
c36ff1
-        (LIB + '/udev/rules.d', [f for f in glob('udev/*.rules')])
c36ff1
+        ('/usr/lib/udev/rules.d', [f for f in glob('udev/*.rules')])
c36ff1
     ])
c36ff1
 # Use a subclass for install that handles
c36ff1
 # adding on the right init system configuration files
c36ff1
@@ -286,8 +271,6 @@ setuptools.setup(
c36ff1
     scripts=['tools/cloud-init-per'],
c36ff1
     license='Dual-licensed under GPLv3 or Apache 2.0',
c36ff1
     data_files=data_files,
c36ff1
-    install_requires=requirements,
c36ff1
-    cmdclass=cmdclass,
c36ff1
     entry_points={
c36ff1
         'console_scripts': [
c36ff1
             'cloud-init = cloudinit.cmd.main:main',
c36ff1
diff --git a/tools/read-version b/tools/read-version
c36ff1
index 02c90643..79755f78 100755
c36ff1
--- a/tools/read-version
c36ff1
+++ b/tools/read-version
c36ff1
@@ -71,32 +71,8 @@ version_long = None
c36ff1
 is_release_branch_ci = (
c36ff1
     os.environ.get("TRAVIS_PULL_REQUEST_BRANCH", "").startswith("upstream/")
c36ff1
 )
c36ff1
-if is_gitdir(_tdir) and which("git") and not is_release_branch_ci:
c36ff1
-    flags = []
c36ff1
-    if use_tags:
c36ff1
-        flags = ['--tags']
c36ff1
-    cmd = ['git', 'describe', '--abbrev=8', '--match=[0-9]*'] + flags
c36ff1
-
c36ff1
-    try:
c36ff1
-        version = tiny_p(cmd).strip()
c36ff1
-    except RuntimeError:
c36ff1
-        version = None
c36ff1
-
c36ff1
-    if version is None or not version.startswith(src_version):
c36ff1
-        sys.stderr.write("git describe version (%s) differs from "
c36ff1
-                         "cloudinit.version (%s)\n" % (version, src_version))
c36ff1
-        sys.stderr.write(
c36ff1
-            "Please get the latest upstream tags.\n"
c36ff1
-            "As an example, this can be done with the following:\n"
c36ff1
-            "$ git remote add upstream https://git.launchpad.net/cloud-init\n"
c36ff1
-            "$ git fetch upstream --tags\n"
c36ff1
-        )
c36ff1
-        sys.exit(1)
c36ff1
-
c36ff1
-    version_long = tiny_p(cmd + ["--long"]).strip()
c36ff1
-else:
c36ff1
-    version = src_version
c36ff1
-    version_long = None
c36ff1
+version = src_version
c36ff1
+version_long = None
c36ff1
 
c36ff1
 # version is X.Y.Z[+xxx.gHASH]
c36ff1
 # version_long is None or X.Y.Z-xxx-gHASH
c36ff1
-- 
c36ff1
2.27.0
c36ff1