Skip to content

Repo to Server

You'll put everything your server needs into a git repository and a playbook, build a second copy of the server from the repo alone, and watch it put a hand-edit back.

About

A rebuild document tells a person what to do, and a repo tells the machine, which can't skip a step or misremember a flag. Ansible is the usual tool because it runs from your laptop over SSH with nothing installed on the server, and a plain shell script in the repo counts too as long as it can run twice without breaking anything. Packages, users, SSH settings, the firewall, the cron jobs and every compose file go in. A disk image or a snapshot doesn't count, because it copies your mistakes along with everything else, and a password committed in plain text fails the badge on the spot. Expect the first playbook to take a weekend and the second run to teach you what the first one quietly broke.

At a glance

Per requirement
35 XP
Completion bonus
300 XP
Requirements
6
Takes
Two or three weekends
Skill level
Advanced (years of practice)
Cost
Free
Supplies
You need some
Where
At home
Other people
On your own
Locked for now
Earn two more Uncommon badges in Homelab & Hardware to open this one. Log in to see how far along you are.

Requirements

  1. 1
    Start a repo with an inventory and a playbook that installs your packages and your user. The inventory lists your machines by the short names from your ssh config. The first playbook installs the packages you'd reach for on any box, creates your user with your public key, and sets the timezone. Run it against one machine. Take a screenshot of the repo's file tree next to the play recap with its ok and changed counts. Photo
  2. 2
    Move every compose file and service setting into the repo, with the secrets kept out. Copy each compose file and the config files it mounts into the repo, and have the playbook put them where they live. Passwords and API keys go in an encrypted vault file or an untracked .env with a committed example that shows the names and not the values. Run git log -p once to check nothing secret ever went in, because deleting it in a later commit doesn't remove it from history. Take a screenshot of the repo tree with the vault or the .env.example in it and a .gitignore that names the real one. Photo
  3. 3
    Run the whole playbook twice in a row and show the second run changes nothing. This is the part nobody tells beginners. A good playbook describes a state rather than a list of actions, so the second run finds nothing to do. If it reports changes, a task is doing something like appending a line or restarting a service every time, and you fix that task until the recap reads changed=0. Take a screenshot of the recap from both runs. Photo
  4. 4
    Build a fresh machine from the repo alone, with a clock running. A new VM on the hypervisor, a Pi with a freshly flashed card or the laptop in the drawer all work. Flash it with only your SSH key and a hostname, add it to the inventory, and run the playbook with nothing done by hand. Film from the first ssh into the blank box to a service answering in a browser, with the time visible at both ends. Under half an hour is normal and under ten minutes is common. Video
  5. 5
    Change one thing in the repo and roll it out to both machines with one command. Add a service, change a port or bump an image tag, commit it, and run the playbook against the whole inventory. Take a screenshot of the commit next to both machines showing the change. Photo
  6. 6
    Edit a config file by hand on the server, run the playbook, and watch it put the file back. This is drift, and it's how every documented server slowly stops matching its document. Change one line in a file the repo manages, run the playbook, and the recap shows one change and the file is back. Then write the README a stranger would need: what to install on the laptop, the one command, and where the secrets live. Film the hand-edit being undone, and post a screenshot of the README with it. Video