Setup lab's computers

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

  1. 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=0
    

    The directory /var/cache/ansible has to be writable by the user executing Ansible.

  2. 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.

  3. Generate a SSH private and public key with ssh-keygen and put the public key into files/id_key.pub;

  4. Boot the computers by selecting the “UEFI PXE” or “NIC” IPv4 boot option (might require to press F12 for boot selection). If this option is not available, it might be required to enable some “UEFI Network stack” option in the BIOS.

  5. 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.

  6. 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.leases
    

    and 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-11
    
  7. Then add the hostnames to Ansible inventory:

    [servers]
    tp-server
    [computers]
    tp-10
    tp-11
    

    Note that you can define groups.

  8. Adjust the content of the playbook setup-computers.yml to 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"
    
  9. 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/hosts or to ~/.ssh/config.

  • To check that DHCP command are received and files are served through TFTP by dnsmaq:

    journalctl -u dnsmasq -f
    
  • To check that nginx are serving the files:

    tail -f /var/log/nginx/access.log
    

Documentation

The playbook setup-computers.yml uses the following roles:

Details

The main steps done automatically by the Ansible roles are detailed in a “manual” way: