commit 5d0935dbf8eac3615df1a064eb802afd664560db Author: Alex Date: Thu Jul 2 20:47:56 2020 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4dc51e8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +vault/ diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..525ca53 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,35 @@ +- name: Fetch Factorio files + get_url: + url: "https://factorio.com/get-download/0.17.79/headless/linux64" + dest: "/tmp/factorio.tar.xz" + tags: + - factorio + - fetch +- name: Extract Factorio files + command: + warn: false + argv: ["tar", "-xv", "--xz", "--strip-components=1", "-f", "/tmp/factorio.tar.xz"] + chdir: "/etc/factorio" + tags: + - factorio + - fetch +- name: Copy Factorio config + template: + src: "server-settings.json" + dest: "/etc/factorio/data/server-settings.json" + owner: "nobody" + group: "nogroup" + mode: "700" + tags: + - vault + - configs + - factorio + notify: Run service actions +- name: Copy Factorio service + template: + src: "factorio.service.j2" + dest: "/etc/systemd/system/factorio.service" + tags: + - systemd + - factorio + notify: Restart services diff --git a/templates/factorio.service.j2 b/templates/factorio.service.j2 new file mode 100644 index 0000000..2950da4 --- /dev/null +++ b/templates/factorio.service.j2 @@ -0,0 +1,17 @@ +[Unit] +Description=Factorio server +After=network.target + +[Service] +ExecStart=/etc/factorio/bin/x64/factorio --start-server {{ factorio.paths.data }}/main.zip --port {{ factorio.bind.port }} --bind {{ factorio.bind.address }} --server-settings /etc/factorio/data/server-settings.json +Restart=on-failure +User=nobody +Group=nogroup +WorkingDirectory={{ factorio.paths.data }} +ProtectSystem=strict +BindPaths=-{{ factorio.paths.data }} +TemporaryFileSystem=/:rw +PrivateTmp=true + +[Install] +WantedBy=multi-user.target diff --git a/templates/server-settings.json b/templates/server-settings.json new file mode 100644 index 0000000..b8279cd --- /dev/null +++ b/templates/server-settings.json @@ -0,0 +1,69 @@ +{ + "name": "[RX] What is this game??? Oh, factorio...", + "description": "Server hosted by redxen.eu", + "tags": ["redxen", "new"], + + "_comment_max_players": "Maximum number of players allowed, admins can join even a full server. 0 means unlimited.", + "max_players": 0, + + "_comment_visibility": ["public: Game will be published on the official Factorio matching server", + "lan: Game will be broadcast on LAN"], + "visibility": + { + "public": true, + "lan": false + }, + + "_comment_credentials": "Your factorio.com login credentials. Required for games with visibility public", + "username": "caskd", + "password": "", + + "_comment_token": "Authentication token. May be used instead of 'password' above.", + "token": "{{ vault_factorio.token }}", + + "game_password": "{{ vault_factorio.gamepass }}", + + "_comment_require_user_verification": "When set to true, the server will only allow clients that have a valid Factorio.com account", + "require_user_verification": true, + + "_comment_max_upload_in_kilobytes_per_second" : "optional, default value is 0. 0 means unlimited.", + "max_upload_in_kilobytes_per_second": 0, + + "_comment_max_upload_slots" : "optional, default value is 5. 0 means unlimited.", + "max_upload_slots": 5, + + "_comment_minimum_latency_in_ticks": "optional one tick is 16ms in default speed, default value is 0. 0 means no minimum.", + "minimum_latency_in_ticks": 0, + + "_comment_ignore_player_limit_for_returning_players": "Players that played on this map already can join even when the max player limit was reached.", + "ignore_player_limit_for_returning_players": false, + + "_comment_allow_commands": "possible values are, true, false and admins-only", + "allow_commands": "admins-only", + + "_comment_autosave_interval": "Autosave interval in minutes", + "autosave_interval": 10, + + "_comment_autosave_slots": "server autosave slots, it is cycled through when the server autosaves.", + "autosave_slots": 5, + + "_comment_afk_autokick_interval": "How many minutes until someone is kicked when doing nothing, 0 for never.", + "afk_autokick_interval": 0, + + "_comment_auto_pause": "Whether should the server be paused when no players are present.", + "auto_pause": true, + + "only_admins_can_pause_the_game": true, + + "_comment_autosave_only_on_server": "Whether autosaves should be saved only on server or also on all connected clients. Default is true.", + "autosave_only_on_server": true, + + "_comment_non_blocking_saving": "Highly experimental feature, enable only at your own risk of losing your saves. On UNIX systems, server will fork itself to create an autosave. Autosaving on connected Windows clients will be disabled regardless of autosave_only_on_server option.", + "non_blocking_saving": false, + + "_comment_segment_sizes": "Long network messages are split into segments that are sent over multiple ticks. Their size depends on the number of peers currently connected. Increasing the segment size will increase upload bandwidth requirement for the server and download bandwidth requirement for clients. This setting only affects server outbound messages. Changing these settings can have a negative impact on connection stability for some clients.", + "minimum_segment_size": 25, + "minimum_segment_size_peer_count": 20, + "maximum_segment_size": 100, + "maximum_segment_size_peer_count": 10 +}