summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Holman <brett.holman@canonical.com>2023-04-17 13:27:31 -0600
committerGitHub <noreply@github.com>2023-04-17 13:27:31 -0600
commit34e8c914df666c937e48f5d1c3add0bd47e4e7eb (patch)
tree2207a2b255910c746f5660635e30f3b287bff8e1
parent44ab4f4a18a325b6a2c915d7796bf00da5917c7b (diff)
downloadcloud-init-git-34e8c914df666c937e48f5d1c3add0bd47e4e7eb.tar.gz
Standardize disabling cloud-init on non-systemd (#2112)
Some distros support disabling cloud-init using the kernel argument cloud-init=disabled. Standardize it across non-systemd distros. Skip NetBSD, which doesn't support passing external arguments to the kernel. Also add support for disabling cloud-init using /etc/cloud/cloud-init.disabled to non-systemd distros.
-rw-r--r--systemd/cloud-init-hotplugd.service2
-rw-r--r--sysvinit/debian/cloud-config8
-rw-r--r--sysvinit/debian/cloud-final8
-rwxr-xr-xsysvinit/debian/cloud-init8
-rw-r--r--sysvinit/debian/cloud-init-local7
-rwxr-xr-xsysvinit/freebsd/cloudconfig10
-rwxr-xr-xsysvinit/freebsd/cloudfinal8
-rwxr-xr-xsysvinit/freebsd/cloudinit10
-rwxr-xr-xsysvinit/freebsd/cloudinitlocal10
-rwxr-xr-xsysvinit/gentoo/cloud-config8
-rwxr-xr-xsysvinit/gentoo/cloud-final8
-rwxr-xr-xsysvinit/gentoo/cloud-init8
-rwxr-xr-xsysvinit/gentoo/cloud-init-local9
-rwxr-xr-xsysvinit/netbsd/cloudconfig3
-rwxr-xr-xsysvinit/netbsd/cloudfinal3
-rwxr-xr-xsysvinit/netbsd/cloudinit3
-rwxr-xr-xsysvinit/netbsd/cloudinitlocal3
17 files changed, 105 insertions, 11 deletions
diff --git a/systemd/cloud-init-hotplugd.service b/systemd/cloud-init-hotplugd.service
index 10962d54..598c647b 100644
--- a/systemd/cloud-init-hotplugd.service
+++ b/systemd/cloud-init-hotplugd.service
@@ -13,6 +13,8 @@
Description=cloud-init hotplug hook daemon
After=cloud-init-hotplugd.socket
Requires=cloud-init-hotplugd.socket
+ConditionPathExists=!/etc/cloud/cloud-init.disabled
+ConditionKernelCommandLine=!cloud-init=disabled
[Service]
Type=simple
diff --git a/sysvinit/debian/cloud-config b/sysvinit/debian/cloud-config
index 53322748..f3565b33 100644
--- a/sysvinit/debian/cloud-config
+++ b/sysvinit/debian/cloud-config
@@ -45,6 +45,14 @@ fi
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
+ if grep -q 'cloud-init=disabled' /proc/cmdline; then
+ log_daemon_msg "$NAME is disabled via /proc/cmdline."
+ exit 0
+ elif test -e /etc/cloud/cloud-init.disabled; then
+ log_daemon_msg "$NAME is disabled via cloud-init.disabled file"
+ exit 0
+ fi
+
$DAEMON ${DAEMON_ARGS}
case "$?" in
0|1) log_end_msg 0 ;;
diff --git a/sysvinit/debian/cloud-final b/sysvinit/debian/cloud-final
index 55afc8b0..222fedd6 100644
--- a/sysvinit/debian/cloud-final
+++ b/sysvinit/debian/cloud-final
@@ -47,6 +47,14 @@ fi
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
+ if grep -q 'cloud-init=disabled' /proc/cmdline; then
+ log_daemon_msg "$NAME is disabled via /proc/cmdline."
+ exit 0
+ elif test -e /etc/cloud/cloud-init.disabled; then
+ log_daemon_msg "$NAME is disabled via cloud-init.disabled."
+ exit 0
+ fi
+
$DAEMON ${DAEMON_ARGS}
case "$?" in
0|1) log_end_msg 0 ;;
diff --git a/sysvinit/debian/cloud-init b/sysvinit/debian/cloud-init
index 48fa0423..5ed7b970 100755
--- a/sysvinit/debian/cloud-init
+++ b/sysvinit/debian/cloud-init
@@ -45,6 +45,14 @@ fi
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
+ if grep -q 'cloud-init=disabled' /proc/cmdline; then
+ log_daemon_msg "$NAME is disabled via /proc/cmdline."
+ exit 0
+ elif test -e /etc/cloud/cloud-init.disabled; then
+ log_daemon_msg "$NAME is disabled via cloud-init.disabled file."
+ exit 0
+ fi
+
$DAEMON ${DAEMON_ARGS}
case "$?" in
0|1) log_end_msg 0 ;;
diff --git a/sysvinit/debian/cloud-init-local b/sysvinit/debian/cloud-init-local
index 802ee8e9..6f49180f 100644
--- a/sysvinit/debian/cloud-init-local
+++ b/sysvinit/debian/cloud-init-local
@@ -44,6 +44,13 @@ fi
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
+ if grep -q 'cloud-init=disabled' /proc/cmdline; then
+ log_daemon_msg "$NAME is disabled via /proc/cmdline."
+ exit 0
+ elif test -e /etc/cloud/cloud-init.disabled; then
+ log_daemon_msg "$NAME is disabled via cloud-init.disabled"
+ exit 0
+ fi
$DAEMON ${DAEMON_ARGS}
case "$?" in
0|1) log_end_msg 0 ;;
diff --git a/sysvinit/freebsd/cloudconfig b/sysvinit/freebsd/cloudconfig
index 13c47280..bb4ec979 100755
--- a/sysvinit/freebsd/cloudconfig
+++ b/sysvinit/freebsd/cloudconfig
@@ -17,8 +17,14 @@ start_cmd="cloudconfig_start"
cloudconfig_start()
{
- echo "${command} starting"
- ${command} modules --mode config
+ echo "${command} starting"
+ if kenv -q kernel_options | grep -q 'cloud-init=disabled'; then
+ warn "cloud-init is disabled via kernel_options."
+ elif test -e /etc/cloud/cloud-init.disabled; then
+ warn "cloud-init is disabled via cloud-init.disabled file."
+ else
+ ${command} modules --mode config
+ fi
}
load_rc_config 'cloudinit'
diff --git a/sysvinit/freebsd/cloudfinal b/sysvinit/freebsd/cloudfinal
index 76a584ec..0a61c11d 100755
--- a/sysvinit/freebsd/cloudfinal
+++ b/sysvinit/freebsd/cloudfinal
@@ -18,7 +18,13 @@ start_cmd="cloudfinal_start"
cloudfinal_start()
{
echo -n "${command} starting"
- ${command} modules --mode final
+ if kenv -q kernel_options | grep -q 'cloud-init=disabled'; then
+ warn "cloud-init is disabled via kernel_options."
+ elif test -e /etc/cloud/cloud-init.disabled; then
+ warn "cloud-init is disabled via cloud-init.disabled file."
+ else
+ ${command} modules --mode final
+ fi
}
load_rc_config 'cloudinit'
diff --git a/sysvinit/freebsd/cloudinit b/sysvinit/freebsd/cloudinit
index 679adf5d..2e5a82b2 100755
--- a/sysvinit/freebsd/cloudinit
+++ b/sysvinit/freebsd/cloudinit
@@ -17,8 +17,14 @@ start_cmd="cloudinit_start"
cloudinit_start()
{
- echo -n "${command} starting"
- ${command} init
+ echo -n "${command} starting"
+ if kenv -q kernel_options | grep -q 'cloud-init=disabled'; then
+ warn "cloud-init is disabled via kernel_options."
+ elif test -e /etc/cloud/cloud-init.disabled; then
+ warn "cloud-init is disabled via cloud-init.disabled file."
+ else
+ ${command} init
+ fi
}
load_rc_config 'cloudinit'
diff --git a/sysvinit/freebsd/cloudinitlocal b/sysvinit/freebsd/cloudinitlocal
index d6c3579e..87d8ee16 100755
--- a/sysvinit/freebsd/cloudinitlocal
+++ b/sysvinit/freebsd/cloudinitlocal
@@ -17,8 +17,14 @@ start_cmd="cloudlocal_start"
cloudlocal_start()
{
- echo -n "${command} starting"
- ${command} init --local
+ echo -n "${command} starting"
+ if kenv -q kernel_options | grep -q 'cloud-init=disabled'; then
+ warn "cloud-init is disabled via kernel_options."
+ elif test -e /etc/cloud/cloud-init.disabled; then
+ warn "cloud-init is disabled via cloud-init.disabled file."
+ else
+ ${command} init --local
+ fi
}
load_rc_config 'cloudinit'
diff --git a/sysvinit/gentoo/cloud-config b/sysvinit/gentoo/cloud-config
index 5618472b..a5188676 100755
--- a/sysvinit/gentoo/cloud-config
+++ b/sysvinit/gentoo/cloud-config
@@ -8,6 +8,12 @@ depend() {
}
start() {
- cloud-init modules --mode config
+ if grep -q 'cloud-init=disabled' /proc/cmdline; then
+ ewarn "$RC_SVCNAME is disabled via /proc/cmdline."
+ elif test -e /etc/cloud/cloud-init.disabled; then
+ ewarn "$RC_SVCNAME is disabled via cloud-init.disabled file"
+ else
+ cloud-init modules --mode config
+ fi
eend 0
}
diff --git a/sysvinit/gentoo/cloud-final b/sysvinit/gentoo/cloud-final
index a9bf01fb..087e47a6 100755
--- a/sysvinit/gentoo/cloud-final
+++ b/sysvinit/gentoo/cloud-final
@@ -6,6 +6,12 @@ depend() {
}
start() {
- cloud-init modules --mode final
+ if grep -q 'cloud-init=disabled' /proc/cmdline; then
+ ewarn "$RC_SVCNAME is disabled via /proc/cmdline."
+ elif test -e /etc/cloud/cloud-init.disabled; then
+ ewarn "$RC_SVCNAME is disabled via cloud-init.disabled file"
+ else
+ cloud-init modules --mode final
+ fi
eend 0
}
diff --git a/sysvinit/gentoo/cloud-init b/sysvinit/gentoo/cloud-init
index 531a715d..7f88237e 100755
--- a/sysvinit/gentoo/cloud-init
+++ b/sysvinit/gentoo/cloud-init
@@ -8,6 +8,12 @@ depend() {
}
start() {
- cloud-init init
+ if grep -q 'cloud-init=disabled' /proc/cmdline; then
+ ewarn "$RC_SVCNAME is disabled via /proc/cmdline."
+ elif test -e /etc/cloud/cloud-init.disabled; then
+ ewarn "$RC_SVCNAME is disabled via cloud-init.disabled file"
+ else
+ cloud-init init
+ fi
eend 0
}
diff --git a/sysvinit/gentoo/cloud-init-local b/sysvinit/gentoo/cloud-init-local
index 0f8cf65c..4ea92b46 100755
--- a/sysvinit/gentoo/cloud-init-local
+++ b/sysvinit/gentoo/cloud-init-local
@@ -8,6 +8,13 @@ depend() {
}
start() {
- cloud-init init --local
+ if grep -q 'cloud-init=disabled' /proc/cmdline; then
+ ewarn "$RC_SVCNAME is disabled via /proc/cmdline."
+ elif test -e /etc/cloud/cloud-init.disabled; then
+ ewarn "$RC_SVCNAME is disabled via cloud-init.disabled file"
+ else
+ cloud-init init --local
+ fi
+
eend 0
}
diff --git a/sysvinit/netbsd/cloudconfig b/sysvinit/netbsd/cloudconfig
index 5cd7eb31..afc78ef3 100755
--- a/sysvinit/netbsd/cloudconfig
+++ b/sysvinit/netbsd/cloudconfig
@@ -10,6 +10,9 @@ name="cloudinit"
start_cmd="start_cloud_init"
start_cloud_init()
{
+ test -e /etc/cloud/cloud-init.disabled \
+ && warn "cloud-init disabled by cloud-init.disabled file" \
+ && exit 0
/usr/pkg/bin/cloud-init modules --mode config
}
diff --git a/sysvinit/netbsd/cloudfinal b/sysvinit/netbsd/cloudfinal
index 72f3e472..82e1f1c2 100755
--- a/sysvinit/netbsd/cloudfinal
+++ b/sysvinit/netbsd/cloudfinal
@@ -9,6 +9,9 @@ name="cloudinit"
start_cmd="start_cloud_init"
start_cloud_init()
{
+ test -e /etc/cloud/cloud-init.disabled \
+ && warn "cloud-init disabled by cloud-init.disabled file" \
+ && exit 0
/usr/pkg/bin/cloud-init modules --mode final
}
diff --git a/sysvinit/netbsd/cloudinit b/sysvinit/netbsd/cloudinit
index 266afc2a..8330953a 100755
--- a/sysvinit/netbsd/cloudinit
+++ b/sysvinit/netbsd/cloudinit
@@ -9,6 +9,9 @@ name="cloudinit"
start_cmd="start_cloud_init"
start_cloud_init()
{
+ test -e /etc/cloud/cloud-init.disabled \
+ && warn "cloud-init disabled by cloud-init.disabled file" \
+ && exit 0
/usr/pkg/bin/cloud-init init
}
diff --git a/sysvinit/netbsd/cloudinitlocal b/sysvinit/netbsd/cloudinitlocal
index 1f30e70b..3a8ddcf1 100755
--- a/sysvinit/netbsd/cloudinitlocal
+++ b/sysvinit/netbsd/cloudinitlocal
@@ -11,6 +11,9 @@ name="cloudinitlocal"
start_cmd="start_cloud_init_local"
start_cloud_init_local()
{
+ test -e /etc/cloud/cloud-init.disabled \
+ && warn "cloud-init disabled by cloud-init.disabled file" \
+ && exit 0
/usr/pkg/bin/cloud-init init -l
}