Add a gmod server and required roles

This commit is contained in:
Salt 2020-07-05 11:45:27 -05:00
parent 61ed816059
commit 241a74a21f
9 changed files with 152 additions and 2 deletions

View File

@ -3,3 +3,11 @@
backups_frequency: 6h backups_frequency: 6h
mcheapmax: 4096 mcheapmax: 4096
mcheapmin: 1024 mcheapmin: 1024
steam_api_key: !vault |
$ANSIBLE_VAULT;1.1;AES256
39616163316634306633623435636633623966306537636639316439343839393231376661666335
6136333866633861313566306433393637613364386234360a303832626338373230396665336430
33346530626633616161613635656433356434366437383363663165303862316163323263323230
3334373531646364620a386165626130386265343235363639346230323930626330343235373662
38313431663734343931333462316633643935353038313934663466303834636533616165353961
6438356265656532396363323532616437353831613261323037

View File

@ -63,5 +63,19 @@
tags: [ gameserver, minecraft, magicpack ] tags: [ gameserver, minecraft, magicpack ]
- hosts: game3 - hosts: game3
roles: roles:
- role: steamcmd - role: steamgame
tags: [ steamcmd ] vars:
steam_appid: "232330"
steam_path: "Counter-Strike Source Dedicated Server"
tags: [ steam, gmod, css ]
- role: sourcegame
vars:
source_appid: "4020"
source_path: GarrysModDS
source_game: garrysmod
source_instancename: gmod
# TODO: Add me when sam figures his shit out
# source_args: "+host_workshop_collection COLLECTION_ID"
source_args: "+gamemode sandbox"
source_configrepo: "https://git.9iron.club/salt/gmodconfig"
tags: [ steam, gmod ]

View File

@ -0,0 +1,2 @@
# vim:ft=ansible:
source_maxplayers: 16

View File

@ -0,0 +1,8 @@
#!/usr/bin/ansible-playbook
# vim:ft=ansible:
---
- name: "restart {{ source_instancename }}"
systemd:
name: "source-{{ source_instancename }}"
state: restarted
become: yes

View File

@ -0,0 +1,9 @@
# vim:ft=ansible:
---
allow_duplicates: yes
dependencies:
- role: steamcmd
- role: steamgame
vars:
steam_appid: "{{ source_appid }}"
steam_path: "{{ source_path }}"

View File

@ -0,0 +1,48 @@
#!/usr/bin/ansible-playbook
# vim:ft=ansible:
---
- name: Set up game
block:
- name: Clone configuration repository
git:
repo: "{{ source_configrepo }}"
dest: $HOME/sourcecfg/{{ source_instancename }}
notify: "restart {{ source_instancename }}"
- name: Symlink configs
file:
src: "$HOME/sourcecfg/{{ source_instancename }}/{{ item }}"
path: "/var/steam/.steam/SteamApps/common/{{ source_path }}/{{ source_game }}/cfg/{{ item }}"
state: link
force: yes
loop:
- autoexec.cfg
- mount.cfg
- server.cfg
notify: "restart {{ source_instancename }}"
become: yes
become_user: steamcmd
- name: Set up system
block:
- name: Template out service
template:
src: sourcegame.service
dest: "/etc/systemd/system/source-{{ source_instancename }}.service"
notify: "restart {{ source_instancename }}"
- name: Reload available daemons
systemd:
daemon_reload: yes
- name: Enable service
systemd:
name: "source-{{ source_instancename }}"
state: started
enabled: yes
- name: Assure CNAME record
route53:
state: present
zone: "{{ zone }}"
type: CNAME
record: "{{ source_instancename }}.src.{{ zone }}."
ttl: 300
value:
- "{{ inventory_hostname }}.{{ zone }}."
become: yes

View File

@ -0,0 +1,29 @@
#
# Licensed under the terms of the MIT license
# vim:ft=dosini:
#
[Unit]
Description={{ source_game }} - {{ source_instancename }}
After=network.target
[Service]
User=steamcmd
Group=steamcmd
WorkingDirectory=/var/steam/.steam/SteamApps/common/{{ source_path }}
PrivateUsers=true
ProtectSystem=full
ProtectHome=true
# Implies MountFlags=slave
ProtectKernelTunables=true
# Implies NoNewPrivileges=yes
ProtectKernelModules=true
# Implies MountAPIVFS=yes
ProtectControlGroups=true
ExecStart=/bin/sh -c '/usr/bin/screen -DmS {{ source_instancename }} /var/steam/.steam/SteamApps/common/{{ source_path }}/srcds_run -game {{ source_game }} -maxplayers {{ source_maxplayers }} -authkey {{ steam_api_key }} {{ source_args }}'
Restart=always
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,5 @@
# vim:ft=ansible:
---
allow_duplicates: yes
dependencies:
- role: steamcmd

View File

@ -0,0 +1,27 @@
#!/usr/bin/ansible-playbook
# vim:ft=ansible:
---
- name: Install Steam game
block:
- name: "Install game {{ steam_appid }}"
command:
argv:
- /usr/games/steamcmd
- +login
- anonymous
- +app_update
- "{{ steam_appid }}"
# - validate
- +quit
creates: "$HOME/.steam/SteamApps/common/{{ steam_path }}"
- name: Create quick-access dir
file:
path: $HOME/games
state: directory
- name: Symlink game to quick-access dir
file:
src: "$HOME/.steam/SteamApps/common/{{ steam_path }}"
path: "/var/steam/games/{{ steam_appid }}"
state: link
become: yes
become_user: steamcmd