95 lines
2.3 KiB
YAML
95 lines
2.3 KiB
YAML
---
|
|
- name: create steamcmd group
|
|
ansible.builtin.group:
|
|
name: steamcmd
|
|
system: true
|
|
state: present
|
|
|
|
- name: create steamcmd user
|
|
ansible.builtin.user:
|
|
name: steamcmd
|
|
group: steamcmd
|
|
system: true
|
|
shell: /bin/bash
|
|
home: /var/lib/steamcmd
|
|
create_home: true
|
|
state: present
|
|
|
|
- name: configure debian-unstable.sources
|
|
ansible.builtin.deb822_repository:
|
|
name: debian-unstable
|
|
types: deb
|
|
uris: http://deb.debian.org/debian
|
|
suites:
|
|
- unstable
|
|
components:
|
|
- contrib
|
|
- main
|
|
- non-free
|
|
signed_by: /usr/share/keyrings/debian-archive-keyring.gpg
|
|
state: present
|
|
|
|
- name: check if i386 architecture
|
|
ansible.builtin.command: dpkg --print-foreign-architectures
|
|
register: check_i386
|
|
changed_when: false
|
|
failed_when: false
|
|
|
|
- name: add i386 architecture
|
|
ansible.builtin.command: dpkg --add-architecture i386
|
|
when: "'i386' not in check_i386.stdout"
|
|
|
|
- name: accept agreement
|
|
ansible.builtin.debconf:
|
|
name: steamcmd
|
|
question: steam/question
|
|
vtype: string
|
|
value: "I AGREE"
|
|
|
|
- name: install steamcmd
|
|
ansible.builtin.apt:
|
|
name: steamcmd
|
|
update_cache: true
|
|
|
|
- name: ensure valheim data directory exists
|
|
ansible.builtin.file:
|
|
path: /mnt/valheim/data
|
|
owner: steamcmd
|
|
group: steamcmd
|
|
state: "directory"
|
|
|
|
- name: check steam session
|
|
ansible.builtin.stat:
|
|
path: /var/lib/steamcmd/.local/share/Steam/config/config.vdf
|
|
register: steam_session
|
|
|
|
- name: ensure steam authorization exists
|
|
ansible.builtin.fail:
|
|
msg: "Manual Steam authorization required. Please log in interactively."
|
|
when: not steam_session.stat.exists
|
|
|
|
- name: install valheim server
|
|
ansible.builtin.command:
|
|
cmd: su - steamcmd -c "/usr/games/steamcmd +force_install_dir /mnt/valheim/data +login anonymous +app_update 896660 validate +exit"
|
|
register: valheim_result
|
|
changed_when: "'downloading' in valheim_result.stdout"
|
|
notify: restart valheim
|
|
|
|
- name: deploy start_server.sh
|
|
ansible.builtin.copy:
|
|
src: start_server.sh
|
|
dest: /mnt/valheim/data/start_server-custom.sh
|
|
owner: steamcmd
|
|
group: steamcmd
|
|
mode: '0775'
|
|
notify: restart valheim
|
|
|
|
- name: deploy valheim.service
|
|
ansible.builtin.copy:
|
|
src: valheim.service
|
|
dest: /etc/systemd/system/valheim.service
|
|
owner: root
|
|
group: root
|
|
mode: '0644'
|
|
notify: restart valheim
|