This page describes how to install Ubuntu 20.04 Desktop automatically using the netboot server and configure the computers using the Ansible collection ufrmath.computer_labs.
More precisely, the playbook setup-computers.yml is used.
Quick way
In order to allow Wake on LAN to work properly, Ansible cache need to be stored forever. This can be done with the following configuration file:
[defaults] fact_caching = jsonfile fact_caching_connection=/var/cache/ansible fact_caching_timeout=0The directory
/var/cache/ansiblehas to be writable by the user executing Ansible.Define environment in:
ansible_user: admin proxy_env: http_proxy: 'http://proxy.example.com:3128' https_proxy: 'http://proxy.example.com:3128' no_proxy: 'localhost,127.0.0.0/8,::1,tp-server'proxy settings be optional.
Generate a SSH private and public key with
ssh-keygenand put the public key intofiles/id_key.pub;Boot the computers by selecting the “UEFI PXE” or “NIC” IPv4 boot option (might require to press
F12for boot selection). If this option is not available, it might be required to enable some “UEFI Network stack” option in the BIOS.After a few seconds, the computer should display a grub menu, with automatic selection of
Install Ubuntu. Then Ubuntu is automatically installed from netboot server and then restarted once the installation is finished.During the installation, you might want to see which computer has which MAC address by inspecting the DHCP leases on the server:
tail -f /var/lib/misc/dnsmasq.leasesand adjust the following file on the server to assign deterministic IP later:
00:01:02:03:04:10,10.0.2.10,tp-10 00:01:02:03:04:e1,10.0.2.11,tp-11Then add the hostnames to Ansible inventory:
[servers] tp-server [computers] tp-10 tp-11Note that you can define groups.
Adjust the content of the playbook
setup-computers.ymlto your need:- name: Setup and customize just after Debian preseed finished the install hosts: computers gather_facts: no force_handlers: yes collections: - ufrmath.computer_labs roles: - role: setup_custom ntp_server: ntp.example.com ip_server: 10.0.2.2 custom_repository: "deb http://tp-server/ubuntu/ focal-tp main" vars: ansible_ssh_pass: test ansible_become_pass: test - role: setup_guest - role: patch_systemd delegate_build_to: tp-server - role: setup_nfs_ldap domain: "math.example.com" ldap_uri: "ldap://ldap.math.example.com, ldap://ldap2.math.example.com" ldap_search_base: "dc=math,dc=example,dc=com" nfs_server: "nfs.math.example.com" nfs_home_path: "/users/home" when: "'debug' not in group_names" - role: setup_bios bios_password: test bios_settings: 'WakeOnLan': 'LanOnly' 'DeepSleepCtrl': 'Disabled' 'UsbEmu': 'Disabled' 'BluetoothDevice': 'Disabled' 'SecureBoot': 'Enabled' - role: setup_printer printer_name: location printer_ip: 10.0.2.3 when: "'location' in group_names"Run the playbook to setup the computers:
ansible-playbook -i hosts setup-computers.yml
Troubleshooting
Ensure that the computer boot in UEFI mode;
It might be required that Secure boot is disabled;
In case hostnames are not properly resoled on the computer running Ansible, you might want to add the IPs to
/etc/hostsor to~/.ssh/config.To check that DHCP command are received and files are served through TFTP by dnsmaq:
journalctl -u dnsmasq -fTo check that nginx are serving the files:
tail -f /var/log/nginx/access.log
Documentation
The playbook setup-computers.yml uses the following roles:
ufrmath.computer_labs.setup_customto configure and customize the computers (adding proxy, theme, custom repository,…);ufrmath.computer_labs.setup_guestto add guest user support in GDM;ufrmath.computer_labs.patch_systemdto patch systemd to allow numerical login;ufrmath.computer_labs.setup_nfs_ldapto LDAP authentication and NFS for home directories;ufrmath.computer_labs.setup_biosto configure BIOS settings;ufrmath.computer_labs.setup_printerto add printers.
Details
The main steps done automatically by the Ansible roles are detailed in a “manual” way: