Your team keeps writing the same server bootstrap steps by hand. How would you automate first-boot configuration for new cloud VMs?
AdvancedScenarioScheduling, automation and scripting
Answer
Situation read → Use cloud-init plus config management, and bake images.
What I'd do →
#cloud-config
users:
- name: ops
groups: wheel
ssh_authorized_keys: [ "ssh-ed25519 AAAA... ops" ]
package_update: true
packages: [chrony, auditd, amazon-cloudwatch-agent]
runcmd:
- [ systemctl, enable, --now, chronyd ]
- [ sh, -c, "curl -fsSL https://config.internal/bootstrap.sh | bash" ]
Bake the slow parts into a golden image with Packer; let cloud-init do only host-specific bits.
Why → Faster boot, consistent results, fewer moving parts at scale.
Interview tip → Check cloud-init status --long and /var/log/cloud-init-output.log when it goes wrong.
More on Scheduling, automation and scripting
A database dump must run every night at 1:30 AM. How do you schedule it with cron so it is reliable?BeginnerConvert that nightly cron job to a systemd timer. Why would you?IntermediateA cron job runs every 5 minutes, but sometimes takes 8 minutes and two copies overlap, corrupting data. How do you prevent that?BeginnerYou have 300 servers running the same cron job at midnight, and they hammer a shared API. How do you fix it?IntermediateA job must run on the last day of every month. Cron has no "last day" field. What do you do?IntermediateYou inherited a server and need to know every scheduled job on it. Where do you look?Beginner