Description
This module is used to ensure that the configuration that is running on a device matches what is required.
It goes through several steps to ensure the system is set up correctly.
Hostname
The robot's hostname is set by SystemConfiguration. Pass the --hostname argument the first time it is run on a robot:
sudo ./systemconfiguration --hostname booster1This writes the hostname to /etc/hostname and only needs to be done once, as the change persists. The new hostname shows up the next time you SSH into the robot.
Filesystem
The system will look through each file in the module/tools/SystemConfiguration/data/system/default directory.
For each of these files it will see if there is an equivalent file in the
module/tools/SystemConfiguration/data/system/$HOSTNAME directory (for example system/booster1) and use that, otherwise it uses the default file.
Using this file it will check that the same file in the root directory is identical to this one, and if not it will copy it across.
This will ensure that all the system configuration files match the files that are in the repository.
The system will only look at files that exist in the module/tools/SystemConfiguration/data/system/default directory.
If you have a file that will override for a specific system, you must provide a default file as well.
SystemConfiguration will not delete files that are not in system/default,
even if they have been previously installed by SystemConfiguration.
After the files are copied, it will go through the list of permissions changes that are in the SystemConfiguration.yaml file and apply them.
This configuration file must list the total permissions as an octal number.
After permissions are set, it will go through the list of symlinks that are in the SystemConfiguration.yaml and ensure they are created.
Checks are made to ensure that the link target exists, and the link doesn't exist.
- If the target doesn't exist, no link is made
- If the link name already exists and is a regular file, the file is renamed to
<link name>.oldand the link is made - If the link name already exists and is not a symlink to the target, the link is removed and the correct link is made
- If the link name already exists and is a symlink to the target, nothing is done
- If the link name doesn't exist, the link is made
Steps
The process is:
- Hostname: If
--hostnameis passed, it is written to/etc/hostname. See above. - Filesystem: See above.
- NetworkManager: Connection files in
/etc/NetworkManager/system-connectionsare set to0600and reloaded withnmcli. The profile named byconnectioninSystemConfiguration.yamlis then brought up, if its.nmconnectionfile exists. - Permissions and Symlinks: See above.
- Packages: The system runs
apt-get update && apt-get upgrade, then installs any package listed underaptinSystemConfiguration.yamlthat isn't already installed. - Systemd: The system will go through the list of units and ensure that they are enabled.
- Locale: If
generate_localeis set in theSystemConfiguration.yamlthenlocale-genis called to ensure that system locales have been generated. - Message Of The Day: The message of the day file is generated with the robot's hostname.
- Booster Robot Info: The
Nickname:line in the Booster robot info file (robot_info_path) is set to<Alias> [NUbots], using the robot's alias from the platform aliases. If there is no alias, the hostname is used. - Hosts: The hosts file is generated with the correct contents.
- Groups: The user is then added to all groups listed in the
SystemConfiguration.yaml, if the user is not currently a member of them. - Bash: The fzf key bindings and completion scripts are sourced in the user's
~/.bashrc. - Python: Python is updated to ensure that it will search for packages in
/usr/local. - Ownership: The user's home directory and
/usr/localare owned by the user so files installed as root stay usable.
Configuration
SystemConfiguration.yaml contains:
| Key | Description |
|---|---|
log_level | Set to DEBUG or lower to see each file being checked |
user | The user on the robot (booster) |
permissions | Files and the octal permissions to set on them |
apt | APT packages that should be installed |
connection | The NetworkManager profile to activate. Must exist in the system folder |
systemd | Systemd units that should be enabled |
groups | Groups the user should be a member of |
links | Symlinks to create, as target: name |
generate_locale | Whether to run locale-gen |
robot_info_path | Path to the Booster robot info file that holds the robot's nickname |
Usage
Install the systemconfiguration role and the toolchain onto the robot, then run it as a superuser:
./b install -t booster1ssh booster@<robot ip>sudo ./systemconfiguration --hostname booster1--hostname can be left off on later runs. This role will ensure that the system configuration on the platform matches the configuration in the repository.