## template:jinja
[Unit]
# https://docs.cloud-init.io/en/latest/explanation/boot.html
Description=Cloud-init: Local Stage (pre-network)
{% if variant in ["almalinux", "cloudlinux", "ubuntu", "unknown", "debian", "rhel"] %}
DefaultDependencies=no
{% endif %}
Wants=network-pre.target
After=hv_kvp_daemon.service
Before=network-pre.target
Before=shutdown.target
{% if variant in ["almalinux", "cloudlinux", "rhel"] %}
Before=firewalld.target
{% endif %}
{% if variant in ["ubuntu", "unknown", "debian"] %}
Before=sysinit.target
{% endif %}
Conflicts=shutdown.target
ConditionPathExists=!/etc/cloud/cloud-init.disabled
ConditionKernelCommandLine=!cloud-init=disabled
ConditionEnvironment=!KERNEL_CMDLINE=cloud-init=disabled

[Service]
Type=oneshot
{% if variant in ["almalinux", "cloudlinux", "rhel"] %}
ExecStartPre=/sbin/restorecon /run/cloud-init
{% endif %}
# This service is a shim which preserves systemd ordering while allowing a
# single Python process to run cloud-init's logic. This works by communicating
# with the cloud-init process over a unix socket to tell the process that this
# stage can start, and then wait on a return socket until the cloud-init
# process has completed this stage. The output from the return socket is piped
# into a shell so that the process can send a completion message (defaults to
# "done", otherwise includes an error message) and an exit code to systemd.
ExecStart=sh -c 'echo "start" | nc -Uu -W1 /run/cloud-init/share/local.sock -s /run/cloud-init/share/local-return.sock | sh'
RemainAfterExit=yes
TimeoutSec=0

# Output needs to appear in instance console output
StandardOutput=journal+console

[Install]
WantedBy=cloud-init.target
