Open Source

Ten Linux Servers, One File, and a Rollout That Stops

#Conn3x#Open Source#Ansible#Linux#OpenTofu#Configuration Management
James Conway10 min read

TL;DR: We put ten Linux servers, five Ubuntu and five Rocky, behind one Ansible inventory and one Conn3x circuit. Then we rolled a change out two at a time, broke one server on purpose, and watched the rollout stop at that server with six others untouched. -limit sent a change to the web group first, conn3x run asked all ten a question in under a fifth of a second, and conn3x drift named the two servers someone had fixed by hand. It's a seven-minute video. This is the same run, written down, with the files.

Watch the video

Video: How to Manage 10 Linux Servers With One Configuration, 7 minutes 19 seconds Play video
7:19, from the Conn3x channel. Nothing loads from YouTube until you press play.

One Server Is Easy

Ten is where the questions start

Configure one server and you’ll get it right, because you’re watching it. Ten is different. Which ones are in which group? What does the web group need that the app group doesn’t? Before anything changes, what’s going to change, and where? And the one that keeps people up: if the change is bad, does it stop at two servers or take all ten with it?

Then there’s the question nobody asks until it bites. Somebody SSHes into a box at 3 a.m. and fixes something by hand. Will you ever find out?

That’s the list the video works through, in order, with real runs on Conn3x v0.31.0 recorded on 24 November. I’ve since checked every file and command below against v0.49.0, the current release, and they all still work as written.

The Fleet

Ten containers that behave like servers

The ten servers were Podman containers on my Mac: web01 to web05 on Ubuntu 24.04, app01 to app05 on Rocky Linux 10. Each one runs systemd and sshd, so Conn3x reaches it over SSH exactly as it would a server in a rack. Every container got a fresh host key, and a known_hosts file pins all ten, so nothing gets trusted just because it answered.

There’s one catch worth saying up front. With no network between Conn3x and the hosts, the timings below are faster than you’ll see across a real network. I come back to what that costs at the end.

Before any of it, we downloaded the release and checked it with cosign: the release workflow signed the checksum list, and the archive matched it.

The Inventory You Already Have

If you've used Ansible, you've seen this file

It’s an Ansible inventory, unchanged. Two groups, five hosts each:

[web]
web01 ansible_port=2201
web02 ansible_port=2202
web03 ansible_port=2203
web04 ansible_port=2204
web05 ansible_port=2205

[app]
app01 ansible_port=2206
app02 ansible_port=2207
app03 ansible_port=2208
app04 ansible_port=2209
app05 ansible_port=2210

[all:vars]
ansible_host=127.0.0.1
ansible_user=root

The group_vars say what each group gets. Look at cron_package, because it’s the reason this works across two distributions: the same package is called cron on Ubuntu and cronie on Rocky.

# group_vars/all.yml
tier: stable

# group_vars/web.yml
role: web
port: 8080
cron_package: cron

# group_vars/app.yml
role: app
port: 9090
cron_package: cronie

# host_vars/web01.yml
tier: canary

The order is Ansible’s: all first, then the group, then the host, so the host wins. That’s how web01 becomes the canary without anyone writing an if.

One Circuit for All Ten

No second list of hosts to keep in step

Here’s the whole circuit, as it was for the first apply:

circuit "fleet" {
  hosts = provider::conn3x::inventory("${path.module}/inventory.ini", "all")

  strategy     = "per_host"
  batch_size   = 2
  max_failures = 0

  ssh {
    private_key_file = "id_ed25519"
    known_hosts_file = "known_hosts"
  }

  step "cron" {
    package {
      name = each.value.vars.cron_package
    }
  }

  step "motd" {
    file {
      path    = "/etc/motd"
      content = "${each.key}: ${each.value.vars.role} server, ${each.value.vars.tier}. Managed by Conn3x.\n"
    }
  }

  step "config_dir" {
    directory {
      path = "/etc/fleet"
    }
  }

  step "config" {
    file {
      path    = "/etc/fleet/app.conf"
      content = "role = ${each.value.vars.role}\nport = ${each.value.vars.port}\n"
    }
  }
}

The hosts come straight out of the inventory through the inventory function, so there isn’t a second list to forget to update. Every step reads the host’s own vars through each.value.vars: the cron package by its local name, a message of the day with the host’s role and tier, and a config file with its port.

What turns this into a rollout is the three lines at the top. per_host lets each server run its own chain of steps. batch_size = 2 rolls out two hosts at a time. max_failures = 0 means the first failure stops it.

Why does per_host matter? Without it, a circuit runs in lockstep, and no host starts a step until every host has finished the one before. That’s the default, and it’s why batches need per_host.

One thing you’ll see the first time you run conn3x init: it ends with Warning: This configuration's state isn't encrypted. That’s deliberate, because Conn3x state holds what it reads from your servers as well as the cloud. For ten throwaway containers on your own machine it’s fine to leave off. For real servers, turn on state encryption.

The Plan Names Every Host

If a server's missing, you can see that too

conn3x plan came back with 40 things to add: four steps on each of ten hosts, and every line names its host. Count them by host and you get four each. No host hides behind a group name. If a server’s in the plan, it’s on the screen, and if it isn’t, that’s on the screen too.

Break One on Purpose

The leftover nobody notices until a deploy trips on it

To give the rollout a reason to stop, we ran touch /etc/fleet on app03 before the first apply. That leaves a file exactly where the config directory needs to go. It’s the kind of leftover you’d never spot until a deploy tripped over it.

Then conn3x apply. Ten hosts at two a time is five batches, in name order.

The first batch, app01 and app02, went through. The second reached app03 and found a file where the directory should be. That’s one failure against a limit of zero, so no more batches started.

Two details here are worth slowing down for. Before giving up, Conn3x plans that batch’s hosts again to see which ones still have work left, and only those count as failed. And app04, in the same batch as app03, finished, because each host runs its own chain. The other six were never touched.

It took 8.6 seconds, and the problem stopped at one server.

We removed the file and applied again. This time only seven hosts had work left, so it ran four batches. app01, app02 and app04 weren’t in any of them: they were done, and state knew it. All four batches applied in 19 seconds.

Tuning the Rollout

Two at a time suits ten. It won't suit two hundred

batch_size can be a percentage too, such as "20%" of the hosts that change. So can max_failures, and it’s counted over the whole rollout. Ansible’s max_fail_percentage counts per batch.

For a one-off, -batch-size and -max-failures on conn3x apply override the circuit without you having to edit it.

Quick Checks Across All Ten

Some jobs don't belong in a circuit

Which OS is each box running, right now? conn3x run reads the same inventory and asks all ten:

conn3x run -i inventory.ini -private-key-file id_ed25519 -known-hosts-file known_hosts \
  all -m facts -a 'filter=os_id,os_version'

Five on Rocky, five on Ubuntu, in under a fifth of a second. A plain command works too:

conn3x run -i inventory.ini -private-key-file id_ed25519 -known-hosts-file known_hosts \
  all -a 'cat /etc/motd'

There’s every message of the day, and there’s the canary on web01. A command always reports changed, since Conn3x can’t know what it did. None of this touches state.

One Group First

Let the web servers go first

Now a change for everyone: a patch window in the message of the day. One line in the circuit:

-      content = "${each.key}: ${each.value.vars.role} server, ${each.value.vars.tier}. Managed by Conn3x.\n"
+      content = "${each.key}: ${each.value.vars.role} server, ${each.value.vars.tier}. Managed by Conn3x. Patches: Sunday 02:00.\n"

But you’d like the web servers to get it first:

conn3x plan -limit='web*'
conn3x apply -auto-approve -limit='web*'

The plan showed five changes, all on web hosts, with a warning that it was limited. The apply rolled out in three batches, web only.

One catch. -limit matches host names, not groups, so name your hosts in a way a pattern can find. conn3x run is different: its patterns do match group names, the way Ansible’s do.

Somebody Fixes It by Hand

3 a.m., and two servers quietly change

It’s 3 a.m. Somebody SSHes into web02 and rewrites its message of the day. Someone else changes the port on app04.

conn3x drift reads every host and compares it with the last apply. It found two resources on two hosts and named each one. It exits with code 2, so a scheduled job can raise the alarm.

What drift leaves out matters just as much. The patch window was still waiting for the app servers, and drift didn’t report it. That’s a change in your code, not something that moved on a server.

One apply put both hand edits back and finished the patch window on the app group: six hosts, three batches, under two seconds. Then drift again, and nothing.

What It Costs at Scale

The honest part

Every plan reads every step on every host, every time. That’s how it catches an edit made by hand. Here, 40 reads across ten hosts took under a third of a second, but these hosts shared a machine with Conn3x, so there’s no network in that number. Turn the reads off with -refresh=false and it’s under a tenth of a second, but then a hand edit is invisible.

At hundreds of hosts, the network is the cost. The project’s own benchmark plans 500 hosts. At the default parallelism of 50, that plan took 5.8 seconds from a client in the same AWS region and 11 seconds over a long-distance link. The numbers and the setup are in issue #524, which is still open.

Two more limits, so they don’t surprise you:

  • No dynamic inventory yet.

    The inventory function reads a static inventory file with its group_vars and host_vars. It doesn't run inventory scripts or plugins.

  • Batches need per_host.

    Set batch_size without strategy = "per_host" and conn3x validate tells you so.

When we finished, the ten containers were gone, and podman ps listed none.

Try It Yourself

Ten minutes, no cloud account

The quickest way in is the local tutorial. It takes about ten minutes, and you don’t need a cloud account. Already have an Ansible inventory? The hosts page shows how to bring it with you, and the batches section of the apply docs has every rule we used here.

And if any of this made you think “that’s the tool I wanted”, give Conn3x a star on GitHub. It takes one click, and it’s how a project this young gets noticed.

// Let's talk

You have ideas.
I have IT solutions.

Fifteen minutes on Zoom is usually enough to tell whether I'm the right person for what you're building.

Denver, CO · Available for architecture, infrastructure, and DevOps engagements