Cloud-Init file to create jumphost

ตัวอย่าง file cloud-init สำหรับสร้าง jumphost โดยใช้ rocky linux os

file นี้จะทำการสร้าง user nutanix ติดตั้ง docker, kubectl และ code server เพื่อให้สามารถใช้ shell ผ่าน vscode

Shell
#cloud-config
ssh_pwauth: true
users:
- name: nutanix
passwd: nutanix/4u
groups: users,wheel
shell: /bin/bash
lock-passwd: false
sudo: ['ALL=(ALL) NOPASSWD:ALL']
chpasswd:
list: |
nutanix:nutanix/4u
root:nutanix/4u
expire: False
runcmd:
- echo "Configuring SSH..."
# Ensure PasswordAuthentication is enabled
- sed -i '/^PasswordAuthentication/d' /etc/ssh/sshd_config # Delete existing line
- echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config # Add new line
# Ensure PermitRootLogin is set to yes
- sed -i '/^PermitRootLogin/d' /etc/ssh/sshd_config # Delete existing line
- echo "PermitRootLogin yes" >> /etc/ssh/sshd_config # Add new line
# Restart SSH Service
- systemctl restart sshd
- echo "SSH configuration updated and service restarted."
- '[ ! -f "/etc/yum.repos.d/nutanix_rocky9.repo" ] || mv -f /etc/yum.repos.d/nutanix_rocky9.repo /etc/yum.repos.d/nutanix_rocky9.repo.disabled'
- dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
- dnf -y install git docker-ce docker-ce-cli containerd.io
- systemctl --now enable docker
- usermod -aG docker nutanix
- 'curl -Lo /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl'
- chmod +x /usr/local/bin/kubectl
- 'curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash'
- 'su - nutanix -c "curl -fsSL https://raw.githubusercontent.com/pkhamdee/nkp-tools/main/install-tools.sh | bash"'
- eject

สำหรับ https://raw.githubusercontent.com/pkhamdee/nkp-tools/main/install-tools.sh จะเป็นการ deploy code server เพื่อใช้ linux terminal และจัดการไฟล์ผ่านทาง vscode ได้