Last active
November 10, 2024 16:37
-
-
Save ironwolphern/3ce44b7a966480bae25a156ded5895ce to your computer and use it in GitHub Desktop.
This config is for vm Ubuntu with cloud-init in Proxmox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cloud-config | |
hostname: docker | |
fqdn: docker.example.com | |
manage_etc_hosts: true | |
# Users and Groups | |
users: | |
- name: usuario | |
sudo: ALL=(ALL) NOPASSWD:ALL | |
groups: adm, sudo | |
home: /home/usuario | |
shell: /bin/bash | |
lock_passwd: true | |
uid: 1000 | |
ssh-authorized-keys: | |
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0WGP1EZfreNQSJWjV/Fant... | |
# Package Management | |
package_reboot_if_required: true | |
package_update: true | |
package_upgrade: true | |
packages: | |
- vim | |
- net-tools | |
- curl | |
- wget | |
- lolcat | |
- figlet | |
- git | |
- jq | |
- cron | |
- default-jre | |
- qemu-guest-agent | |
- ca-certificates | |
# Custom Files | |
write_files: | |
- path: /etc/update-motd.d/01-custom-logo | |
permissions: '0755' | |
content: | | |
#!/bin/bash | |
# This script print a banner with logo and system information. | |
# Need two packages: figlet and lolcat | |
# Fix: for lolcat to work properly, you have to move the binary from /usr/games/lolcat to /usr/bin/lolcat | |
# Colors | |
GREEN='\033[0;32m' | |
BLUE='\033[0;34m' | |
YELLOW='\033[0;33m' | |
NC='\033[0m' | |
LOGO='Example' | |
MESSAGE='Example message' | |
# Banner | |
figlet -w 70 -f slant -c "${LOGO}" | lolcat -f | |
printf " Welcome to ${LOGO}'s %s Server" "$(hostname -s)" | lolcat -f | |
echo | |
echo | |
# Sysrem Information | |
printf " ${YELLOW}System Information at:${NC} ${GREEN}%s${NC}\n" "$(date)" | |
echo | |
printf "${YELLOW}System Load:\t${NC}${BLUE}%s${NC}\t\t${YELLOW}Processes:\t${BLUE}%s${NC}\n" "$(cat /proc/loadavg | awk '{print $1, $2, $3}')" "$(ps aux --no-headings | wc -l)" | |
printf "${YELLOW}Memory Usage:\t${NC}${BLUE}%s${NC}\t${YELLOW}IP Address:\t${BLUE}%s${NC}\n" "$(free -m | awk 'NR==2{printf "%s/%sMB (%.2f%%)\n", $3,$2,$3*100/$2 }')" "$(hostname -I | awk '{print $1}')" | |
printf "${YELLOW}Disk Usage:\t${NC}${BLUE}%s${NC}\t\t${YELLOW}System Uptime:\t${BLUE}%s${NC}\n" "$(df -h / | awk 'NR==2{printf "%s/%s (%s)\n", $3,$2,$5}')" "$(uptime -p)" | |
# Banner 2 | |
echo | |
echo " ${LOGO} - ${MESSAGE}" | lolcat -f | |
echo | |
# Run Commands | |
runcmd: | |
- mv /usr/games/lolcat /usr/bin/lolcat | |
- chmod -x /etc/update-motd.d/* | |
- chmod +x /etc/update-motd.d/01-custom-logo | |
- sed -i 's/#Banner none/Banner none/g' /etc/ssh/sshd_config | |
- sed -i 's/#PrintLastLog yes/PrintLastLog no/g' /etc/ssh/sshd_config | |
- sed -i 's/session optional pam_motd.so noupdate/# session optional pam_motd.so noupdate/g' /etc/pam.d/login | |
- systemctl restart ssh | |
- systemctl start qemu-guest-agent | |
- apt-get install -y unattended-upgrades | |
- dpkg-reconfigure -f noninteractive unattended-upgrades | |
- timedatectl set-timezone Europe/Madrid | |
- install -m 0755 -d /etc/apt/keyrings | |
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc | |
- chmod a+r /etc/apt/keyrings/docker.asc | |
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null | |
- apt-get update | |
- apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | |
- groupadd docker | |
- usermod -aG docker devops | |
- systemctl enable docker.service | |
- systemctl enable containerd.service |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2 | |
ethernets: | |
ens18: | |
dhcp4: true | |
dhcp6: false | |
optional: true | |
# Configuración estática (comentada) | |
# addresses: | |
# - 192.168.1.100/24 | |
# gateway4: 192.168.1.1 | |
# nameservers: | |
# search: [example.com] | |
# addresses: [8.8.8.8, 8.8.4.4] | |
# routes: | |
# - to: 0.0.0.0/0 | |
# via: 10.23.2.1 | |
# metric: 3 | |
# ens19: | |
# dhcp4: false | |
# dhcp6: false | |
# optional: true | |
# addresses: | |
# - 10.0.0.10/24 | |
# Ejemplo de configuración de bonding | |
# bonds: | |
# bond0: | |
# interfaces: [ens18, ens19] | |
# addresses: [192.168.1.100/24] | |
# gateway4: 192.168.1.1 | |
# nameservers: | |
# addresses: [8.8.8.8, 8.8.4.4] | |
# parameters: | |
# mode: active-backup | |
# primary: ens18 | |
# Ejemplo de configuración de VLAN | |
# vlans: | |
# vlan15: | |
# id: 15 | |
# link: ens18 | |
# addresses: [10.0.15.10/24] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment