Ubuntu Server 2.1: PXE, autoinstall and cloud-init
Writing and checking a cloud-init user-data file and an autoinstall file.
Booting a new VM from the files, and the chapter's PXE task, need more than one VM and aren't part of this lab: try them on your own VMs once the files pass here.
Before you start
The lab makes the directory /root/cloud for your two files. This VM
came from a cloud image, so cloud-init is already installed.
Tasks
- Write
/root/cloud/user-datathat creates a userdeploywith your SSH public key and sudo rights, installshtop, and writes the textbuilt by cloud-initto/etc/motd. Check it:sudo cloud-init schema -c /root/cloud/user-datasays "Valid schema". - Write an autoinstall file
/root/cloud/autoinstall.yamlfor a server nameddb1with a userdbadmin(password hash made withopenssl passwd -6), SSH installed with password logins off, the LVM layout, and the packagepostgresql.sudo cloud-init schema -caccepts it, it starts with#cloud-config, everything is underautoinstall:withversion: 1, and the password is a$6$hash.
Hints
#cloud-configon the first line;users:withname,groups: [sudo]orsudo: "ALL=(ALL) NOPASSWD:ALL",shell,ssh_authorized_keys;packages:;write_files:withpathandcontent.ssh-keygenif you have no key yet;cat ~/.ssh/id_ed25519.pub.autoinstall:withversion: 1,identity:(hostname,username,password),ssh:(install-server,allow-pw),storage:layout:name: lvm,packages:. Quote the hash: it contains$.