2023-09-25 17:57:38 +08:00
|
|
|
#cloud-config
|
|
|
|
# CLOUD_IMG: This file was created/modified by the Cloud Image build process
|
|
|
|
# https://cloudinit.readthedocs.io/en/22.1_a/
|
2023-09-29 07:00:30 +08:00
|
|
|
datasource_list: [ NoCloud, None ]
|
2023-09-25 17:57:38 +08:00
|
|
|
|
|
|
|
# configure localization
|
|
|
|
locale: en_US.UTF-8
|
|
|
|
|
|
|
|
# configure timezone
|
|
|
|
timezone: TimeZone
|
|
|
|
|
|
|
|
# configure root user
|
2023-09-28 19:01:01 +08:00
|
|
|
disable_root: false
|
|
|
|
ssh_pwauth: true
|
2023-09-25 17:57:38 +08:00
|
|
|
users:
|
|
|
|
- name: root
|
|
|
|
lock_passwd: false
|
|
|
|
shell: /bin/bash
|
|
|
|
|
|
|
|
chpasswd:
|
|
|
|
expire: false
|
|
|
|
list: |
|
|
|
|
root:tmpWORD
|
|
|
|
users:
|
|
|
|
- name: root
|
|
|
|
password: tmpWORD
|
|
|
|
type: text
|
|
|
|
|
|
|
|
# Despite cloud-init 22.1-9 supports version 2 of network configurations but the "renderers:" doesn't support "network-manager".
|
|
|
|
# https://cloudinit.readthedocs.io/en/22.1_a/topics/network-config.html#network-output-policy
|
|
|
|
system_info:
|
|
|
|
network:
|
|
|
|
renderers: ['sysconfig']
|
|
|
|
|
|
|
|
# The gateway of network for cloud-init 22.1-9 must be "gateway4"(for IPv4) or "gateway6"(for IPv6).
|
|
|
|
network:
|
|
|
|
version: 2
|
|
|
|
ethernets:
|
|
|
|
networkAdapter:
|
|
|
|
dhcp4: false
|
|
|
|
addresses: [IPv4/ipPrefix]
|
|
|
|
gateway4: GATE
|
|
|
|
nameservers:
|
|
|
|
addresses: [ipDNS1, ipDNS2]
|
|
|
|
|
|
|
|
# later commands
|
2023-10-01 00:06:13 +08:00
|
|
|
# Enable sshd service.
|
2023-09-25 17:57:38 +08:00
|
|
|
# Stop and disable kdump service.
|
|
|
|
# Set hostname.
|
2023-09-26 21:17:06 +08:00
|
|
|
# Allocate 512MB swap to provent yum dead.
|
2023-09-28 23:25:29 +08:00
|
|
|
# Add new ssh port for firewalld.
|
|
|
|
# Install epel repository and some common components.
|
|
|
|
# Refresh dependents of systemctl.
|
2023-09-26 21:17:06 +08:00
|
|
|
# Update grub2.
|
2023-09-25 17:57:38 +08:00
|
|
|
# Delete cloud-init config file itself and disable it permanently after first execution.
|
|
|
|
runcmd:
|
|
|
|
- systemctl enable sshd
|
|
|
|
- systemctl restart sshd
|
|
|
|
- systemctl stop kdump
|
|
|
|
- systemctl disable kdump
|
|
|
|
- hostnamectl set-hostname HostName
|
2023-09-26 21:16:33 +08:00
|
|
|
- fallocate -l 512M /swapspace
|
|
|
|
- chmod 600 /swapspace
|
|
|
|
- mkswap /swapspace
|
|
|
|
- swapon /swapspace
|
|
|
|
- echo '/swapspace none swap sw 0 0' >> /etc/fstab
|
2023-09-28 23:25:29 +08:00
|
|
|
- sed -i '6i \ \ <port port="sshPORT" protocol="tcp"/>' /etc/firewalld/zones/public.xml
|
|
|
|
- sed -i '7i \ \ <port port="sshPORT" protocol="udp"/>' /etc/firewalld/zones/public.xml
|
|
|
|
- dnf install curl dnsutils epel-release file lrzsz net-tools vim wget -y
|
|
|
|
- systemctl daemon-reload
|
2023-10-06 16:56:46 +08:00
|
|
|
- grub2-mkconfig -o $(readlink -f /etc/grub2-efi.cfg)
|
2023-09-25 17:57:38 +08:00
|
|
|
- rm -rf /etc/cloud/cloud.cfg.d/99-fake_cloud.cfg
|
|
|
|
- touch /etc/cloud/cloud-init.disabled
|