Skip to content

Commit

Permalink
working monthly and weekly wipes
Browse files Browse the repository at this point in the history
  • Loading branch information
compscidr committed Nov 13, 2024
1 parent 36ca493 commit 9f3376f
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 22 deletions.
4 changes: 4 additions & 0 deletions ansible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ You'll probably want to test it works (and accept the ssh key) - with:
## Deploying to just www.jasonernst.com
`ansible-playbook -i inventory.yml playbook.yml --ask-become-pass --limit www.jasonernst.com`

## Deploying to nas
Requires an extra `ask-pass` argument:
`ansible-playbook -i inventory.yml playbook.yml --ask-become-pass --ask-pass --limit nas.local --tags rust-weekly`

# Checking for problems
`ansible-playbook -i inventory.yml playbook.yml --check -vvvv`

Expand Down
Binary file not shown.
15 changes: 7 additions & 8 deletions ansible/roles/nas_local/rust_game/files/rust.env.j2
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
RUST_SERVER_STARTUP_ARGUMENTS={{ rust_startup_args }}
RUST_SERVER_STARTUP_ARGUMENTS="{{ rust_startup_args }}"
RUST_SERVER_IDENTITY={{ rust_identity }}
RUST_SERVER_MAXPLAYERS=500
RUST_SERVER_SEED={{ rust_seed }}
RUST_SERVER_NAME={{ rust_server_name }}
RUST_SERVER_DESCRIPTION={{ rust_server_description }}
RUST_SERVER_NAME="{{ rust_server_name }}"
RUST_SERVER_DESCRIPTION="{{ rust_server_description }}"
RUST_SERVER_WORLDSIZE={{ rust_world_size }}
RUST_RCON_PASSWORD={{ rust_rcon_password }}
RUST_UPDATE_CHECKING=1
RUST_SERVER_PORT={{ rust_server_port }}
RUST_SERVER_QUERYPORT={{ rust_server_query_port }}
RUST_SERVER_TAGS={{ rust_server_tags }}
RUST_SERVER_TAGS="{{ rust_server_tags }}"
RUST_RCON_PORT={{ rust_rcon_port }}
RUST_APP_PORT={{ rust_app_port }}
RUST_OXIDE_ENABLED={{ rust_oxide_enabled }}
RUST_OXIDE_UPDATE_ON_BOOT=1
RUST_HEARTBEAT=1
RUST_SERVER_URL={{ rust_server_url }}
RUST_SERVER_BANNER_URL={{ rust_banner_url }}
RUST_SERVER_CRON_WIPE_SCHEDULE={{ rust_cron_wipe_schedule }}
RUST_SERVER_URL="{{ rust_server_url }}"
RUST_SERVER_BANNER_URL="{{ rust_banner_url }}"
RUST_SERVER_CRON_WIPE_SCHEDULE="{{ rust_cron_wipe_schedule }}"
1 change: 1 addition & 0 deletions ansible/roles/nas_local/rust_game/files/seed.env.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RUST_SERVER_SEED="{{ rust_seed }}"
9 changes: 9 additions & 0 deletions ansible/roles/nas_local/rust_game/files/wipe-monthly.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# run as root
# https://www.bisecthosting.com/clients/index.php?rp=/knowledgebase/618/How-to-setup-automatic-server-wipes-on-a-Rust-server.html
docker stop rust-monthly
rm server/rust_docker/player.deaths.*
rm server/rust_docker/*.map
rm server/rust_docker/*.sav*
sudo sed -i~ '/^RUST_SERVER_SEED=/s/=.*/='$RANDOM'/' seed.env
docker start rust-monthly
9 changes: 9 additions & 0 deletions ansible/roles/nas_local/rust_game/files/wipe-weekly.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# run as root
# https://www.bisecthosting.com/clients/index.php?rp=/knowledgebase/618/How-to-setup-automatic-server-wipes-on-a-Rust-server.html
docker stop rust-weekly
rm server/rust_docker_weekly/player.deaths.*
rm server/rust_docker_weekly/*.map
rm server/rust_docker_weekly/*.sav*
sudo sed -i~ '/^RUST_SERVER_SEED=/s/=.*/='$RANDOM'/' seed.env
docker start rust-weekly
86 changes: 72 additions & 14 deletions ansible/roles/nas_local/rust_game/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- name: Create Rust Monthly Directories
tags: rust-game
tags: rust-monthly
become: true
ansible.builtin.file:
path: "{{ item }}"
Expand All @@ -14,7 +14,7 @@
- /etc/rust-monthly/cfg

- name: Create Rust Weekly Directories
tags: rust-game
tags: rust-weekly
become: true
ansible.builtin.file:
path: "{{ item }}"
Expand All @@ -29,7 +29,7 @@
- /etc/rust-weekly/cfg

- name: Copy oxide plugins to Monthly
tags: rust-game
tags: rust-monthly
become: true
ansible.builtin.copy:
src: "{{ item.src }}"
Expand All @@ -42,9 +42,11 @@
dest: /etc/rust-monthly/oxide/oxide.config.json
- src: files/RustadminOnline.cs
dest: /etc/rust-monthly/oxide/plugins/RustadminOnline.cs
- src: files/Oxide.Ext.RustIO.dll
dest: /etc/rust-monthly/RustDedicated_Data/Managed/Oxide.Ext.RustIO.dll

- name: Copy oxide plugins to Weekly
tags: rust-game
tags: rust-weekly
become: true
ansible.builtin.copy:
src: "{{ item.src }}"
Expand All @@ -57,9 +59,53 @@
dest: /etc/rust-weekly/oxide/oxide.config.json
- src: files/RustadminOnline.cs
dest: /etc/rust-weekly/oxide/plugins/RustadminOnline.cs
- src: files/Oxide.Ext.RustIO.dll
dest: /etc/rust-weekly/RustDedicated_Data/Managed/Oxide.Ext.RustIO.dll

- name: Copy Wipe Script to weekly
tags: rust-weekly
become: true
ansible.builtin.copy:
src: files/wipe-weekly.sh
dest: /etc/rust-weekly/wipe.sh
mode: '644'
owner: root
group: root

- name: Cron weekly wipe
tags: rust-weekly
become: true
ansible.builtin.cron:
name: rust-weekly-wipe
weekday: "4"
hour: "19"
user: root
job: "bash /etc/rust-weekly/wipe.sh"
cron_file: rust-weekly-wipe

- name: Cron monthly wipe
tags: rust-monthly
become: true
ansible.builtin.cron:
name: rust-monthly-wipe
weekday: "4"
hour: "19"
user: root
job: "bash /etc/rust-monthly/wipe.sh"
cron_file: rust-weekly-wipe

- name: Copy Wipe Script to monthly
tags: rust-monthly
become: true
ansible.builtin.copy:
src: files/wipe-monthly.sh
dest: /etc/rust-monthly/wipe.sh
mode: '644'
owner: root
group: root

- name: Copy Rust Monthly config to host
tags: rust-game
tags: rust-monthly
become: true
ansible.builtin.template:
src: "{{ item.src }}"
Expand All @@ -72,14 +118,17 @@
dest: /etc/rust-monthly/rust.env
- src: files/server.cfg.j2
dest: /etc/rust-monthly/server/rust_docker/cfg/server.cfg
# only uncoment if we want to force a specific seed, otherwise it will random on wipe day
# - src: files/seed.env.j2
# dest: /etc/rust-monthly/seed.env
vars:
rust_server_tags: vanilla,monthly,NA
rust_cron_wipe_schedule: 0 19 4 * *
rust_startup_args: -load -nographics +server.secure 1 +server.tags {{ rust_server_tags }} +wipeTimezone America/Los_Angeles
rust_identity: rust_docker
rust_seed: "{{ 2147483647 | random }}"
rust_seed: "756632467"
rust_server_name: "California | Monthly | No BP Wipe"
rust_server_description: "Self hosted in Redwood City CA\nWipes on the 4th day of the month at 7pm PST\nWorld Size: {{ rust_world_size }}"
rust_server_description: "Self hosted in Redwood City CA\\nWipes on the 4th day of the month at 7pm PST\\nWorld Size: {{ rust_world_size }}"
rust_world_size: 4500
rust_server_port: 28015
rust_server_query_port: 28016
Expand All @@ -90,7 +139,7 @@
rust_banner_url: https://images2.imgbox.com/37/6d/fOpdrpYS_o.jpeg

- name: Copy Rust Weekly config to host
tags: rust-game
tags: rust-weekly
become: true
ansible.builtin.template:
src: "{{ item.src }}"
Expand All @@ -103,14 +152,17 @@
dest: /etc/rust-weekly/rust.env
- src: files/server.cfg.j2
dest: /etc/rust-weekly/server/rust_docker_weekly/cfg/server.cfg
# only uncoment if we want to force a specific seed, otherwise it will random on wipe day
# - src: files/seed.env.j2
# dest: /etc/rust-weekly/seed.env
vars:
rust_server_tags: vanilla,weekly,NA
rust_cron_wipe_schedule: 0 19 * * 4
rust_startup_args: -load -nographics +server.secure 1 +server.tags {{ rust_server_tags }} +wipeTimezone America/Los_Angeles
rust_identity: rust_docker_weekly
rust_seed: "{{ 2147483647 | random }}"
rust_seed: "895907835"
rust_server_name: "California | Weekly | No BP Wipe"
rust_server_description: "Self hosted in Redwood City CA\nWipes on Thursdays at 7pm PST\nWorld Size: {{ rust_world_size }}"
rust_server_description: "Self hosted in Redwood City CA\\nWipes on Thursdays at 7pm PST\\nWorld Size: {{ rust_world_size }}"
rust_world_size: 3000
rust_server_port: 27015
rust_server_query_port: 27016
Expand All @@ -121,7 +173,7 @@
rust_banner_url: https://images2.imgbox.com/37/6d/fOpdrpYS_o.jpeg

- name: Deploy Rust Monthly
tags: rust-game
tags: rust-monthly
# vars:
# ansible_python_interpreter: "/usr/bin/env python3-docker"
community.docker.docker_container:
Expand All @@ -130,7 +182,8 @@
pull: true
volumes:
- "/etc/rust-monthly:/steamcmd/rust:rw"
env_file: /etc/rust-monthly/rust.env
- "/etc/rust-monthly/rust.env:/etc/rust/rust.env"
- "/etc/rust-monthly/seed.env:/etc/rust/seed.env"
ports:
- "28015:28015"
- "28015:28015/udp"
Expand All @@ -146,10 +199,12 @@
PUID: "1000"
PGID: "1000"
restart_policy: unless-stopped
devices:
- /dev/dri:/dev/dri
memory: 16g

- name: Deploy Rust Weekly
tags: rust-game
tags: rust-weekly
# vars:
# ansible_python_interpreter: "/usr/bin/env python3-docker"
community.docker.docker_container:
Expand All @@ -158,7 +213,8 @@
pull: true
volumes:
- "/etc/rust-weekly:/steamcmd/rust:rw"
env_file: /etc/rust-weekly/rust.env
- "/etc/rust-weekly/rust.env:/etc/rust/rust.env"
- "/etc/rust-weekly/seed.env:/etc/rust/seed.env"
ports:
- "27015:27015"
- "27015:27015/udp"
Expand All @@ -173,5 +229,7 @@
TZ: "America/Los_Angeles"
PUID: "1000"
PGID: "1000"
devices:
- /dev/dri:/dev/dri
restart_policy: unless-stopped
memory: 16g

0 comments on commit 9f3376f

Please sign in to comment.