Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions config/cloud.cfg.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ disable_root: true

{% if variant in ["almalinux", "alpine", "amazon", "centos", "cloudlinux", "eurolinux",
"fedora", "miraclelinux", "openEuler", "rhel", "rocky", "virtuozzo"] %}
{% if variant == "rhel" %}
mount_default_fields: [~, ~, 'auto', 'defaults,nofail,x-systemd.requires=cloud-init.service,_netdev', '0', '2']
{% else %}
mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2']
{% endif %}
{% if variant == "amazon" %}
resize_rootfs: noblock
{% endif %}
Expand Down Expand Up @@ -66,6 +70,14 @@ network:
config: disabled
{% endif %}

{% if variant == "rhel" %}
# Default redhat settings:
ssh_deletekeys: true
ssh_genkeytypes: ['rsa', 'ecdsa', 'ed25519']
syslog_fix_perms: ~
disable_vmware_customization: false
{% endif %}

# The modules that run in the 'init' stage
cloud_init_modules:
- migrator
Expand Down Expand Up @@ -107,10 +119,15 @@ cloud_config_modules:
{% endif %}
{% if variant not in ["photon"] %}
- ssh-import-id
{% if variant not in ["rhel"] %}
- keyboard
Comment thread
esposem marked this conversation as resolved.
{% endif %}
- locale
{% endif %}
- set-passwords
{% if variant in ["rhel"] %}
- rh_subscription
{% endif %}
{% if variant in ["rhel", "fedora", "photon"] %}
{% if variant not in ["photon"] %}
- spacewalk
Expand Down Expand Up @@ -239,6 +256,10 @@ system_info:
name: ec2-user
lock_passwd: True
gecos: EC2 Default User
{% elif variant == "rhel" %}
name: cloud-user
lock_passwd: true
gecos: Cloud User
{% else %}
name: {{ variant }}
lock_passwd: True
Expand All @@ -254,6 +275,8 @@ system_info:
groups: [adm, sudo]
{% elif variant == "arch" %}
groups: [wheel, users]
{% elif variant == "rhel" %}
groups: [adm, systemd-journal]
{% else %}
groups: [wheel, adm, systemd-journal]
{% endif %}
Expand Down
4 changes: 4 additions & 0 deletions systemd/cloud-config.service.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Description=Apply the settings specified in cloud-config
After=network-online.target cloud-config.target
After=snapd.seeded.service
Comment thread
esposem marked this conversation as resolved.
Wants=network-online.target cloud-config.target
{% if variant == "rhel" %}
ConditionPathExists=!/etc/cloud/cloud-init.disabled
ConditionKernelCommandLine=!cloud-init=disabled
Comment thread
esposem marked this conversation as resolved.
{% endif %}

[Service]
Type=oneshot
Expand Down
13 changes: 13 additions & 0 deletions systemd/cloud-final.service.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ After=multi-user.target
Before=apt-daily.service
{% endif %}
Wants=network-online.target cloud-config.service
{% if variant == "rhel" %}
ConditionPathExists=!/etc/cloud/cloud-init.disabled
ConditionKernelCommandLine=!cloud-init=disabled
{% endif %}


[Service]
Expand All @@ -15,7 +19,16 @@ ExecStart=/usr/bin/cloud-init modules --mode=final
RemainAfterExit=yes
TimeoutSec=0
KillMode=process
{% if variant == "rhel" %}
# Restart NetworkManager if it is present and running.
ExecStartPost=/bin/sh -c 'u=NetworkManager.service; \
out=$(systemctl show --property=SubState $u) || exit; \
[ "$out" = "SubState=running" ] || exit 0; \
systemctl reload-or-try-restart $u'
Comment thread
esposem marked this conversation as resolved.
{% else %}
TasksMax=infinity
{% endif %}


# Output needs to appear in instance console output
StandardOutput=journal+console
Expand Down
22 changes: 21 additions & 1 deletion systemd/cloud-init-local.service.tmpl
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
## template:jinja
[Unit]
Description=Initial cloud-init job (pre-networking)
{% if variant in ["ubuntu", "unknown", "debian"] %}
{% if variant in ["ubuntu", "unknown", "debian", "rhel" ] %}
DefaultDependencies=no
{% endif %}
Wants=network-pre.target
After=hv_kvp_daemon.service
Comment thread
esposem marked this conversation as resolved.
After=systemd-remount-fs.service
{% if variant == "rhel" %}
Requires=dbus.socket
After=dbus.socket
{% endif %}
Before=NetworkManager.service
{% if variant == "rhel" %}
Before=network.service
{% endif %}
Before=network-pre.target
Before=shutdown.target
{% if variant == "rhel" %}
Before=firewalld.target
Conflicts=shutdown.target
{% endif %}
{% if variant in ["ubuntu", "unknown", "debian"] %}
Before=sysinit.target
Conflicts=shutdown.target
{% endif %}
RequiresMountsFor=/var/lib/cloud
{% if variant == "rhel" %}
ConditionPathExists=!/etc/cloud/cloud-init.disabled
ConditionKernelCommandLine=!cloud-init=disabled
{% endif %}

[Service]
Type=oneshot
{% if variant == "rhel" %}
ExecStartPre=/bin/mkdir -p /run/cloud-init
ExecStartPre=/sbin/restorecon /run/cloud-init
ExecStartPre=/usr/bin/touch /run/cloud-init/enabled
{% endif %}
ExecStart=/usr/bin/cloud-init init --local
RemainAfterExit=yes
TimeoutSec=0
Expand Down
6 changes: 5 additions & 1 deletion systemd/cloud-init.service.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## template:jinja
[Unit]
Description=Initial cloud-init job (metadata service crawler)
{% if variant not in ["photon"] %}
{% if variant not in ["photon", "rhel"] %}
DefaultDependencies=no
{% endif %}
Wants=cloud-init-local.service
Expand Down Expand Up @@ -36,6 +36,10 @@ Before=shutdown.target
Conflicts=shutdown.target
{% endif %}
Before=systemd-user-sessions.service
{% if variant == "rhel" %}
ConditionPathExists=!/etc/cloud/cloud-init.disabled
ConditionKernelCommandLine=!cloud-init=disabled
{% endif %}

[Service]
Type=oneshot
Expand Down
1 change: 1 addition & 0 deletions tests/unittests/test_render_cloudcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def test_variant_sets_default_user_in_cloud_cfg(self, variant, tmpdir):
default_user_exceptions = {
"amazon": "ec2-user",
"debian": "ubuntu",
"rhel": "cloud-user",
"unknown": "ubuntu",
}
default_user = system_cfg["system_info"]["default_user"]["name"]
Expand Down