{"id":23248978,"url":"https://github.com/emilio2hd/pz-server","last_synced_at":"2026-05-17T00:44:34.624Z","repository":{"id":77985122,"uuid":"444863304","full_name":"emilio2hd/pz-server","owner":"emilio2hd","description":"Ansible playbook to set up a project zomboid dedicated server","archived":false,"fork":false,"pushed_at":"2022-01-31T23:58:50.000Z","size":18,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T01:22:29.393Z","etag":null,"topics":["ansible","dedicated-server","project-zomboid","ubuntu"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emilio2hd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-05T15:57:25.000Z","updated_at":"2022-08-31T18:53:29.000Z","dependencies_parsed_at":"2023-04-24T00:00:57.739Z","dependency_job_id":null,"html_url":"https://github.com/emilio2hd/pz-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/emilio2hd/pz-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilio2hd%2Fpz-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilio2hd%2Fpz-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilio2hd%2Fpz-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilio2hd%2Fpz-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emilio2hd","download_url":"https://codeload.github.com/emilio2hd/pz-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilio2hd%2Fpz-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273996656,"owners_count":25204472,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","dedicated-server","project-zomboid","ubuntu"],"created_at":"2024-12-19T08:16:25.242Z","updated_at":"2026-05-17T00:44:29.593Z","avatar_url":"https://github.com/emilio2hd.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Project Zomboid Server Config\nAn ansible playbook to set up a [Project Zomboid](https://store.steampowered.com/app/108600/Project_Zomboid/) server.\n\nThis playbook was created base on:\n- Ubuntu 20-04\n- Scaleway instance (DEV1-M: 3 vCPUs; 4 GB RAM; 40 GB SSD)\n- Ansible 2.10.9\n- Python 3.9\n- MacOS/Linux local machine\n\nThe playbook will:\n- Create a `pz-server` folder in `/home/pzuser`, which contains all the files required to run the zomboid server.\n- Create a `/home/pzuser/.local/bin`, with binaries to start, stop, backup and run the server on startup.\n- Create a backup repository `/home/pzuser/pz-server/backups/repository` using [restic](https://restic.readthedocs.io/en/stable/)\nand a cron task to backup the folders `Zomboid/Server`, `Zomboid/db`, `Zomboid/Saves/Multiplayer/\u003cserver name\u003e`.\n- Allow you to set a server password.\n\n# Before running the playbook\nBefore running this playbook, it's required a few things.\n\n## SSH Configuration\nConfigure the ssh with user and indentity key (add this key to your server):\n```\nHost \u003cserver ip\u003e\n        HostName \u003cserver ip\u003e\n        User root\n        IdentityFile ~/.ssh/id_rsa\n```\n\nMake sure you're able to access the instance using only `ssh \u003cserver ip\u003e`.\n\n## Create Pzuser\nThis playbook relies on a user called `pzuser`. Create one with:\n```\nadduser --disabled-password --gecos \"\" pzuser -q\nchpasswd \u003c\u003c\u003c\"pzuser:\u003cyour password\u003e\"\nusermod -aG sudo pzuser\n```\n\nMake sure you are able to do `sudo su pzuser` without typing password.\n\n## Create Swap File\nThis is not strictly required, but some instances are created without the swap area, relying only on server memory.\nIn order to not have your server killing processes due to lack of memory, create a swap file with the commands:\n\n```\n# Create and use swap file\nsudo fallocate -l 4G /swapfile\nls -lh /swapfile\nsudo chmod 600 /swapfile\nls -lh /swapfile\nsudo mkswap /swapfile\nsudo swapon /swapfile\nsudo swapon --show\n\n# Making the swap file permanent\nsudo cp /etc/fstab /etc/fstab.bak\necho '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab\n```\nYou can read more about it here: https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04\n\n## Firewall\nMake the server a bit more secure.\n```\nsudo apt-get install ufw\n\nsudo ufw default deny             # Defining the policy, that refuses everything by default\nsudo ufw default allow outgoing   # Enable outgoing traffic.\n\nsudo ufw allow 22/tcp     # Authorize SSH\nsudo ufw allow 80/tcp     # Authorize HTTP\nsudo ufw allow 443/tcp    # Authorize HTTPS\nsudo ufw allow 53         # Authorize DNS\n\n# Steam and zomboid ports\nsudo ufw allow 8766/udp\nsudo ufw allow 8767/udp\nsudo ufw allow 16261/udp\nsudo ufw allow 27015/tcp        # In order to enable access to RCON Server\n\n# TCP ports will have to be opened for each player slot on the server.\nsudo ufw allow 16262:16272/tcp    # Server with 10 player slots\n\nsudo ufw enable\n```\n\nMore about it:\n- https://www.scaleway.com/en/docs/tutorials/installation-uncomplicated-firewall/\n- https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu-18-04-pt\n\n## Creating ansible files\nFrom the `inventory.example`, create a `inventory` file and change `\u003cserver ip\u003e` to your server ip address. Ex.:\n```\n[pzserver]\n192.168.01.20     ansible_connection=ssh\n```\n\nYou can create a `config.yml` to overwrite the values on `default.config.yml`. If you wanna create a server with a different name. Like, the same server name as the current you already have.\n```\n# config.yml\n\nzomboid_servername: \"HellOnEarth\"\nzomboid_server_password: \"SuperStrongPwD\"\nzomboid_server_admin_password: \"IamTheBoss!\"\n```\n\n# Running the playbook\nNow that all the files are in place, you should be good to run the playbook. On your local machine, run in the terminal:\n```\nansible-playbook site.yml\n```\n\n## First run\nOnce the playbook complete successfully, go to you server via ssh `ssh \u003cserver ip address\u003e`, change the user to pzuser with `sudo su pzuser` and run:\n```\ncd ~                            # Should lead you to /home/pzuser\nsource .profile                 # Load the scripts in /home/pzuser/.local/bin\nstart-zomboid \u0026\u0026 screen -r      # Run the server and display the logs\n```\nYou should see the dedicated server initializing and printing the logs. Once you see:\n```\nLOG  : General blahblah ######\nServer Steam ID \u003cbunch of numbers\u003e\n##########\n```\nIn order to exit screen without killing the server type: `ctrl + a` followed by `ctrl + d`.\nTry to not to kill the server, it could not save the world properly and you losing your stuff.\n\nAlways use, as `pzuser`:\n```\nsource .profile\nstop-zomboid\n```\n\nOnce the server is running, you should be good to connect to the server following the instruction here [Connecting to the Server](https://pzwiki.net/wiki/Dedicated_Server#Connecting_to_the_Server).\n\n# Migrating your save\nThis step is if you have a dedicated server and want to move the files to the new one.\n\n## Save files\nGo to the save folder(Zomboid/Saves/Multiplayer/\u003cyour server name\u003e) and run the command:\n```\ntar -czf \u003cyour server name\u003e.tar.gz --exclude=\u003cyour server name\u003e.tar.gz .\n```\nThis will compact all the files in the root of the compacted one.\nAttention! \u003cyour server name\u003e should match with the same name as in `zomboid_servername:` in default.config.yml or `config.yml`.\nSo, if you have:\n```\n# config.yml\nzomboid_servername: \"HellOnEarth\"\n```\nYou should compact the files like:\n```\ntar -czf HellOnEarth.tar.gz --exclude=HellOnEarth.tar.gz .\n```\n\nCopy the `\u003cyour server name\u003e.tar.gz` to the folder `pz-server/files/saves`.\n\n## Server files\nCopy the files in the `Zomboid/Server` folder to the folder `pz-server/files/server`. Make sure the files are prefixed with `zomboid_servername` value.\nSo, if you have:\n```\n# config.yml\nzomboid_servername: \"HellOnEarth\"\n```\nYou should have the files:\n```\npz-server/files/server\n├── HellOnEarth.ini\n├── HellOnEarth_SandboxVars.lua\n└── HellOnEarth_spawnregions.lua\n```\n\nNow, with files in place, run:\n```\nansible-playbook site.yml --tags \"migrate-files\"\n```\n\nRun the server again and create the user with the same name as the old server and you should get the world and the characters in the new server.\n\n## Server password\n\nTo protect your server, I would recommend enabling the password.\nIn the `config.yml`, uncomment the `zomboid_server_password`, set some password and run:\n```\nansible-playbook site.yml --tags \"server-pwd\"\n```\n\n## Enable RCON\n\nZomboid server allows remote connection. In order to do this, it's required to set a password to the rcon server.\nIn the `config.yml`, uncomment the `zomboid_rcon_password`, set some password and run:\n```\nansible-playbook site.yml --tags \"server-rcon\"\n```\n\nHave fun!\n\n# Links\n- https://linuxize.com/post/how-to-use-linux-screen/\n- https://www.digitalocean.com/community/tutorials/how-to-back-up-data-to-an-object-storage-service-with-the-restic-backup-client\n- https://pzwiki.net/wiki/Startup_parameters\n- https://pzwiki.net/wiki/Dedicated_Server\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femilio2hd%2Fpz-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femilio2hd%2Fpz-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femilio2hd%2Fpz-server/lists"}