Home

Awesome

Example Ansible-based setup for a 6th gen. Thinkpad X1 Carbon

Summary

This repository contains an Ansible playbook and set of roles for configuring a Void Linux installation on a 6th Gen. ThinkPad X1 Carbon laptop. It's extracted from my private ansible_config repo, which I also use to configure several other systems. Hopefully it's useful as an example of using Ansible to configure personal stuff, and/or documentation for configuring Linux for this particular laptop.

Note that I don't cover installing Void itself -- I didn't really need to do anything special to get things working, though. I had to disable Secure Boot in the BIOS, used a USB flash drive to install, and had an USB ethernet adapter on hand. That was about it. (It should be possible to install over wifi, but I haven't tried.)

What's Ansible?

Ansible is a configuration management tool, similar to Chef, Puppet, or Salt. It reads info about how to configure system(s), then generates scripts which connect over ssh and figure out whether anything needs to change. Then, the scripts report back, and optionally make the changes.

Rather than saying "install this, then add this line to its config file", the config is framed as "this should be present; the config file should contain this line". That way, steps that have already completed can be skipped, and small updates can be applied quickly.

Because Ansible is pushing scripts, rather than waiting for an agent on every system to pull and apply updates, it scales down nicely to personal use cases.

I wrote a couple blog posts about using Ansible at a previous job:

While Ansible has had several interface changes since then (for example, the sudo setting is now named become, and no longer specific to sudo), it's usually pretty good about suggesting replacements for deprecated keywords, and those posts should still be conceptually accurate.

Contents

Also several optional things, which are controlled by flags/options in host_vars, and disabled by default:

There are a couple things that would normally be configured via dotfiles in my git homedir -- I've put relevant files in dotfiles/ instead.

Setup Instructions

This will prompt for the sudo password once, upfront, and then begin installing stuff. (-K is --ask-become-pass, where "become" is Ansible's wrapper for use sudo, doas, and similar tools).

(Note: Ansible will pipe messages through cowsay, once present.)

Misc. Ansible Notes

Ansible functionality is grouped into modules, like file, copy, git, lineinfile, and OS-specific packaging modules like xbps, apt, and openbsd_pkg. ansible-doc <modname> will print interface notes for a particular module, and ansible-doc -l will list the available modules.

Rather than using several .yml files in the base directory, the config is gathered into several subdirectories, called roles. For more info, see the Asible docs for 'role'.

If anything fails, then ansible-playbook can be re-run with a --start "task name" argument to resume at a particular task, and --step can be used to pause and prompt after each step.

--list-tasks will list all the tasks in the playbook.

The Laptop

This laptop works really well with Linux. Suspend didn't work by default, but that's fixed in roles/laptop/tasks/hardware.yml, and everything else has been straightforward to set up.

I strongly prefer its keyboard to any of the newer Apple laptops' keyboards (particularly the touchbar models), and it has a trackpoint & three mouse buttons. It's noticeably lighter than a MacBook Pro, without feeling fragile.

Various forums recommended disabling the external microSD / SIM card port in BIOS. (Apparently it uses an unusually high amount of power when idle, and the SIM card isn't supported anyway.) powertop can be used to identify other things that are disproportionately impacting battery life.

There's other info about hardware support at the Arch wiki.