add fivem role
Some checks failed
Deploy Containers / Prepare (push) Failing after 23s

This commit is contained in:
2025-10-15 23:30:27 -04:00
parent 63e30189ec
commit 505f5581fb
4 changed files with 162 additions and 2 deletions

View File

@@ -0,0 +1,64 @@
---
- name: Create folder structure
file:
path: "{{ item }}"
state: directory
with_items:
- "{{ data_dir }}/fivem"
- "{{ data_dir }}/fivem/server"
- "{{ data_dir }}/fivem/server-data"
- name: Check if FiveM has already been downloaded
stat:
path: "{{ data_dir }}/fivem/server/run.sh"
register: fivem_server
- name: Check if FiveM Config directory already exists
stat:
path: "{{ data_dir }}/fivem/server-data/server.cfg"
register: fivem_server_data
- name: Check if FiveM systemd service exists
stat:
path: "/etc/systemd/system/fivem.service"
register: fivem_systemd
- name: Download FiveM Linux Build
get_url:
url: https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/20944-eaa15781d4695bd97b050d848e34aac3607c6696/fx.tar.xz
dest: "{{ data_dir }}/fivem/server.tar.xz"
mode: 0755
when: not fivem_server.stat.exists
- name: Unpack FiveM Linux Build
unarchive:
src: "{{ data_dir }}/fivem/server.tar.xz"
dest: "{{ data_dir }}/fivem/server"
when: not fivem_server.stat.exists
- name: Clone FiveM Server Data
git:
repo: https://github.com/citizenfx/cfx-server-data.git
dest: "{{ data_dir }}/fivem/server-data"
when: not fivem_server_data.stat.exists
- name: Create FiveM server configuration
template:
src: server.cfg.j2
dest: "{{ data_dir }}/fivem/server-data/server.cfg"
when: not fivem_server_data.stat.exists
- name: Create FiveM systemd service
become: yes
template:
src: fivem.service.j2
dest: "/etc/systemd/system/fivem.service"
when: not fivem_systemd.stat.exists
- name: Enable FiveM systemd service
become: yes
command: systemctl enable fivem.service
- name: Start FiveM systemd service
become: yes
command: systemctl start fivem.service

View File

@@ -0,0 +1,15 @@
[Unit]
Description=FiveM Server
Documentation=https://git.alexav.gg/alex/homelab
[Service]
ExecStart=../server/run.sh +exec server.cfg
ExecReload=/bin/kill -s HUP $MAINPID
WorkingDirectory={{ data_dir }}/fivem/server-data
TimeoutSec=0
RestartSec=10
Restart=always
User=alex
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,81 @@
# Only change the IP if you're using a server with multiple network interfaces, otherwise change the port only.
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"
# These resources will start by default.
ensure mapmanager
ensure chat
ensure spawnmanager
ensure sessionmanager
ensure basic-gamemode
ensure hardcap
ensure rconlog
# This allows players to use scripthook-based plugins such as the legacy Lambda Menu.
# Set this to 1 to allow scripthook. Do note that this does _not_ guarantee players won't be able to use external plugins.
sv_scriptHookAllowed 0
# Uncomment this and set a password to enable RCON. Make sure to change the password - it should look like set rcon_password "YOURPASSWORD"
#set rcon_password ""
# A comma-separated list of tags for your server.
# For example:
# - sets tags "drifting, cars, racing"
# Or:
# - sets tags "roleplay, military, tanks"
sets tags "default"
# A valid locale identifier for your server's primary language.
# For example "en-US", "fr-CA", "nl-NL", "de-DE", "en-GB", "pt-BR"
sets locale "root-AQ"
# please DO replace root-AQ on the line ABOVE with a real language! :)
# Set an optional server info and connecting banner image url.
# Size doesn't matter, any banner sized image will be fine.
#sets banner_detail "https://url.to/image.png"
#sets banner_connecting "https://url.to/image.png"
# Set your server's hostname. This is not usually shown anywhere in listings.
sv_hostname "Medal.tv Testing Server"
# Set your server's Project Name
sets sv_projectName "Medal.tv Testing Server"
# Set your server's Project Description
sets sv_projectDesc "A test server for QA"
# Set Game Build (https://docs.fivem.net/docs/server-manual/server-commands/#sv_enforcegamebuild-build)
#sv_enforceGameBuild 2802
# Nested configs!
#exec server_internal.cfg
# Loading a server icon (96x96 PNG file)
#load_server_icon myLogo.png
# convars which can be used in scripts
set temp_convar "hey world!"
# Remove the `#` from the below line if you want your server to be listed as 'private' in the server browser.
# Do not edit it if you *do not* want your server listed as 'private'.
# Check the following url for more detailed information about this:
# https://docs.fivem.net/docs/server-manual/server-commands/#sv_master1-newvalue
#sv_master1 ""
# Add system admins
add_ace group.admin command allow # allow all commands
add_ace group.admin command.quit deny # but don't allow quit
add_principal identifier.fivem:1 group.admin # add the admin to the group
# enable OneSync (required for server-side state awareness)
set onesync on
# Server player slot limit (see https://fivem.net/server-hosting for limits)
sv_maxclients 48
# Steam Web API key, if you want to use Steam authentication (https://steamcommunity.com/dev/apikey)
# -> replace "" with the key
set steam_webApiKey ""
# License key for your server (https://portal.cfx.re)
sv_licenseKey {{ FIVEM_LICENSE_KEY }}