- Shell 79.7%
- Jinja 13.7%
- Dockerfile 6.6%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| inventory | ||
| local | ||
| playbooks | ||
| roles | ||
| .gitignore | ||
| ansible.cfg | ||
| Architecture.md | ||
| README.md | ||
lan-cs2
Provision and tune the LAN CS2 servers (HP EliteDesk 800 G3, i5-7500) with Ansible.
Hosts
| Inventory name | Address |
|---|---|
| cs2-srv1 | 10.11.0.3 |
| cs2-srv2 | 10.11.0.4 |
| cs2-srv3 | 10.11.0.5 |
| cs2-srv4 | 10.11.0.6 |
| cs2-srv5 | 10.11.0.7 |
Prerequisites
- Ansible core 2.20+ with the
community.generalcollection - SSH key
~/.ssh/id_lan_cs2 - Vault password in
.vault-passat the repo root (git-ignored) (secrets live ininventory/group_vars/cs2/vault.yml)
New host
ssh-copy-id -i ~/.ssh/id_lan_cs2.pub debian@<ip> # debian password from the OS install
ansible-playbook playbooks/bootstrap.yml --limit <name> # installs sudo via su
ansible-playbook playbooks/site.yml --limit <name>
Add the host to inventory/hosts.yml first. On first run the server installs Ready Up, enrolls
on the Auto Tournament platform with the fleet key. Enable it for matches in the platform UI
(once per server).
Usage
All commands accept --limit <name> for one host or --limit 'cs2:!cs2-srv3' to skip one.
Changes that restart cs2 kick players: do not run them during a live match.
Converge
ansible-playbook playbooks/site.yml
Applies every tag. Idempotent: CS2 is installed if missing but not updated.
Update CS2
ansible-playbook playbooks/site.yml --tags update
Runs steamcmd (no validate), then re-patches gameinfo.gi for Ready Up and restarts cs2.
Update Ready Up
Set cs2_readyup_version (a .custom.N tag of cs2_readyup_repo) in roles/cs2_server/defaults/main.yml, then:
ansible-playbook playbooks/site.yml --tags readyup
Reinstalls Ready Up only when the installed version differs, then restarts cs2.
Deploy the platform
Set platform_image in roles/platform/defaults/main.yml, then:
ansible-playbook playbooks/platform.yml
Writes docker/compose.custom.yml (image override for the auto-tournament service) and the MODULE_TRUSTED_KEYS line of .env on 10.11.0.2, keeping a timestamped copy of each. When either changes, dumps the database to /opt/auto-tournament/backups/<timestamp>.sql.gz and docker/data/modules to <timestamp>-modules.tar.gz, pulls the image and runs docker compose up -d in project docker. Rollback: stop the stack, restore both backups and the saved copies of compose.custom.yml and .env, start. The platform never downgrades the CS2 module by itself. Not part of site.yml.
Change server config
Edit roles/cs2_server/templates/server.cfg.j2 or fleet.cfg.j2, then:
ansible-playbook playbooks/site.yml --tags config
Restarts cs2 only if a file changed. Launch options live in run_cs2.sh.j2 (--tags service).
Host tuning
ansible-playbook playbooks/site.yml --tags tuning
Governor change restarts cpu-tuning; kernel command line change runs update-grub and reboots.
Other tags
| Tag | Scope |
|---|---|
ssh |
key-only SSH, reloads ssh |
timezone |
cs2_timezone |
service |
cs2.service, run_cs2.sh |
install |
steamcmd, CS2 (if missing), Ready Up |
Secrets
Secrets in the vault (ansible-vault edit inventory/group_vars/cs2/vault.yml). To create it from
the example:
cp inventory/group_vars/cs2/vault.yml.example inventory/group_vars/cs2/vault.yml
ansible-vault encrypt inventory/group_vars/cs2/vault.yml
| Variable | Use |
|---|---|
vault_root_password |
su during bootstrap |
vault_rcon_password |
RCON password in server.cfg |
vault_fleet_enroll_key |
reusable Auto Tournament fleet key (rfk_...) |
Local play-testing
Two CS2 servers with Ready Up in rootless podman on the workstation, enrolled on a local Auto Tournament platform. Needs podman, Ansible and a btrfs/xfs filesystem (reflink) under ~/cs2-local.
local/cs2local build # tools and runtime image
local/cs2local update # CS2 into ~/cs2-local/base (about 70 GB)
local/cs2local install-readyup # Ready Up at the pinned version into base
local/cs2local clone # reflink copies a and b, rendered configs
local/vars.yml (created from vars.yml.example, git-ignored) holds cs2_fleet_enroll_key (a platform fleet key with auto-link) and the RCON password. Then:
local/cs2local up # or: up a
local/cs2local status
local/cs2local console a # detach with Ctrl-b d
local/cs2local down
| Instance | Game | GOTV | Status |
|---|---|---|---|
| a | 27015 | 27020 | 27022 |
| b | 27025 | 27030 | 27032 |
- Connect from a CS2 client with
connect <LAN IP>:27015; the address is also shown on the platform. - Bots: enable "Fill teams with bots" in the tournament settings; bots take the empty seats.
reset are-clones an instance and enrolls it as a new server.updatere-downloads CS2 into base only; runcloneafterwards.- A Ready Up build from a branch: package it with
scripts/package-release.sh, thencs2local install-readyup --zip <file>andclone. - Set
CS2_READYUP_VERSIONto install another release than the pinned one.
Console
ssh debian@<ip>
tmux attach -t cs2 # detach with Ctrl-b d
systemctl status cs2
The server runs in a restart loop: if CS2 exits or crashes it comes back after 5 s.
Players and spectators
- 16 slots: 10 players, SourceTV, 4 in-server spectators (listed in the match config or admins), 1 spare.
- GOTV viewers:
connect <ip>:27020, up to 32 per server. - While a match is loaded, Ready Up only keeps the roster, its spectators and admins on the server.