# jack-avery/ansible-tf2network architecture

> Architecture diagram of the GitHub repository jack-avery/ansible-tf2network, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jack-avery/ansible-tf2network
- Repository: https://github.com/jack-avery/ansible-tf2network

## Overview

This repository is an Ansible system for provisioning and operating a network of Team Fortress 2 servers, with SourceBans++ and an optional Discord relay. The documented operator workflow prepares the metrics host and SSH access, builds the base server image, distributes SourceMod, builds instance images, and deploys containers; admins can be updated separately. Configuration comes from shared and per-host variables, while `library/narrow.py` selects instances and derives their ports. `manifest.py` gathers inventory and variables into relay/server-hop metadata. The README documents these capabilities; sampled source was limited to the two Ansible modules and manifest generator, so uncertain playbook-to-role wiring is omitted.

Main entry points: [`manifest.py`](https://github.com/jack-avery/ansible-tf2network/blob/main/manifest.py) (Server manifest), [`playbooks/relay.yml`](https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/relay.yml) (Discord relay), [`playbooks/srcds.yml`](https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/srcds.yml) (Instance images), [`playbooks/deploy.yml`](https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/deploy.yml) (Server deploy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operations["Operations"]
  node_setup["Host setup<br/>[setup.yml]"]
  node_sshgen["SSH key generation<br/>[ssh-gen.yml]"]
  node_sshauth["SSH authorization<br/>[ssh-auth.yml]"]
end

subgraph group_server["Server Provisioning"]
  node_base["Base TF2 image<br/>[base-tf2server.yml]"]
  node_sourcemod["SourceMod setup<br/>[sourcemod.yml]"]
  node_srcds["Instance images<br/>[srcds.yml]"]
  node_deploy["Server deploy<br/>[deploy.yml]"]
end

subgraph group_services["Network Services"]
  node_admins["Admin management<br/>[admins.yml]"]
  node_sbinstall["SourceBans install<br/>[sbpp-install.yml]"]
  node_sbpp["SourceBans service<br/>[sbpp.yml]"]
  node_relay["Discord relay<br/>[relay.yml]"]
  node_rcon["RCON module<br/>[rcon.py]"]
  node_manifest["Server manifest<br/>[manifest.py]"]
end

subgraph group_config["Configuration"]
  node_configdata["Shared settings<br/>[tf2.yml]"]
  node_hostdata["Host settings<br/>[nae-1.yml]"]
  node_narrow["Instance selection<br/>[narrow.py]"]
end

node_operator(("Operator"))
node_docker["Docker hosts"]
node_tfservers["TF2 servers"]
node_discord(("Discord"))
node_database[("SourceBans database")]

node_operator -->|"runs setup"| node_setup
node_operator -->|"generates keys"| node_sshgen
node_operator -->|"sets access"| node_sshauth
node_operator -->|"builds base"| node_base
node_operator -->|"distributes plugins"| node_sourcemod
node_operator -->|"builds instances"| node_srcds
node_operator -->|"deploys servers"| node_deploy
node_operator -->|"updates admins"| node_admins
node_operator -->|"installs service"| node_sbinstall
node_operator -.->|"deploys relay"| node_relay
node_setup -->|"prepares hosts"| node_docker
node_sshgen -->|"provides keys"| node_sshauth
node_base -->|"builds image on"| node_docker
node_sourcemod -->|"provides plugins"| node_srcds
node_srcds -->|"builds images on"| node_docker
node_deploy -->|"starts containers"| node_tfservers
node_configdata -->|"supplies defaults"| node_narrow
node_hostdata -->|"supplies instances"| node_narrow
node_narrow -->|"selects instances"| node_deploy
node_admins -->|"updates admins"| node_tfservers
node_sbinstall -->|"installs database"| node_database
node_sbpp -->|"uses database"| node_database
node_relay -.->|"relays messages"| node_discord
node_relay -.->|"relays server chat"| node_tfservers
node_manifest -->|"reads settings"| node_configdata
node_manifest -->|"reads host data"| node_hostdata
node_manifest -->|"describes instances"| node_tfservers
node_rcon -->|"sends commands"| node_tfservers

click node_setup "https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/setup.yml"
click node_sshgen "https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/ssh-gen.yml"
click node_sshauth "https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/ssh-auth.yml"
click node_base "https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/base-tf2server.yml"
click node_sourcemod "https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/sourcemod.yml"
click node_srcds "https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/srcds.yml"
click node_deploy "https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/deploy.yml"
click node_configdata "https://github.com/jack-avery/ansible-tf2network/blob/main/group_vars/tf2.yml"
click node_hostdata "https://github.com/jack-avery/ansible-tf2network/blob/main/host_vars/nae-1.yml"
click node_narrow "https://github.com/jack-avery/ansible-tf2network/blob/main/library/narrow.py"
click node_admins "https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/admins.yml"
click node_sbinstall "https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/sbpp-install.yml"
click node_sbpp "https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/sbpp.yml"
click node_relay "https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/relay.yml"
click node_rcon "https://github.com/jack-avery/ansible-tf2network/blob/main/library/rcon.py"
click node_manifest "https://github.com/jack-avery/ansible-tf2network/blob/main/manifest.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_setup,node_sshgen,node_sshauth toneBlue
class node_base,node_sourcemod,node_srcds,node_deploy,node_database toneAmber
class node_admins,node_sbinstall,node_sbpp,node_relay,node_rcon,node_manifest,node_tfservers toneMint
class node_configdata,node_hostdata,node_narrow toneRose
class node_operator,node_docker,node_discord toneIndigo
```

## Components

### Operations

- [Host setup](https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/setup.yml): `playbooks/setup.yml`
- [SSH key generation](https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/ssh-gen.yml): `playbooks/ssh-gen.yml`
- [SSH authorization](https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/ssh-auth.yml): `playbooks/ssh-auth.yml`

### Server Provisioning

- [Base TF2 image](https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/base-tf2server.yml): `playbooks/base-tf2server.yml`
- [SourceMod setup](https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/sourcemod.yml): `playbooks/sourcemod.yml`
- [Instance images](https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/srcds.yml): `playbooks/srcds.yml`
- [Server deploy](https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/deploy.yml): `playbooks/deploy.yml`

### Network Services

- [Admin management](https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/admins.yml): `playbooks/admins.yml`
- [SourceBans install](https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/sbpp-install.yml): `playbooks/sbpp-install.yml`
- [SourceBans service](https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/sbpp.yml): `playbooks/sbpp.yml`
- [Discord relay](https://github.com/jack-avery/ansible-tf2network/blob/main/playbooks/relay.yml): `playbooks/relay.yml`
- [RCON module](https://github.com/jack-avery/ansible-tf2network/blob/main/library/rcon.py): `library/rcon.py`
- [Server manifest](https://github.com/jack-avery/ansible-tf2network/blob/main/manifest.py): `manifest.py`

### Configuration

- [Shared settings](https://github.com/jack-avery/ansible-tf2network/blob/main/group_vars/tf2.yml): `group_vars/tf2.yml`
- [Host settings](https://github.com/jack-avery/ansible-tf2network/blob/main/host_vars/nae-1.yml): `host_vars/nae-1.yml`
- [Instance selection](https://github.com/jack-avery/ansible-tf2network/blob/main/library/narrow.py): `library/narrow.py`

### Other components

- **Operator**
- **Docker hosts**
- **TF2 servers**
- **Discord**
- **SourceBans database**

## Connections

- Operator → Host setup: runs setup
- Operator → SSH key generation: generates keys
- Operator → SSH authorization: sets access
- Operator → Base TF2 image: builds base
- Operator → SourceMod setup: distributes plugins
- Operator → Instance images: builds instances
- Operator → Server deploy: deploys servers
- Operator → Admin management: updates admins
- Operator → SourceBans install: installs service
- Operator → Discord relay: deploys relay
- Host setup → Docker hosts: prepares hosts
- SSH key generation → SSH authorization: provides keys
- Base TF2 image → Docker hosts: builds image on
- SourceMod setup → Instance images: provides plugins
- Instance images → Docker hosts: builds images on
- Server deploy → TF2 servers: starts containers
- Shared settings → Instance selection: supplies defaults
- Host settings → Instance selection: supplies instances
- Instance selection → Server deploy: selects instances
- Admin management → TF2 servers: updates admins
- SourceBans install → SourceBans database: installs database
- SourceBans service → SourceBans database: uses database
- Discord relay → Discord: relays messages
- Discord relay → TF2 servers: relays server chat
- Server manifest → Shared settings: reads settings
- Server manifest → Host settings: reads host data
- Server manifest → TF2 servers: describes instances
- RCON module → TF2 servers: sends commands
