Download Saved game

This commit is contained in:
Kekskurse 2022-04-08 01:10:27 +02:00
parent 93c34d8cbe
commit 278851f1dc
Signed by: kekskurse
GPG key ID: 728ACCB59341E7E4
4 changed files with 31 additions and 2 deletions

3
.gitignore vendored
View file

@ -1 +1,2 @@
inventory.yml
inventory.yml
saves/

15
download.yml Normal file
View file

@ -0,0 +1,15 @@
---
- name: Setup Factorio
hosts: all
remote_user: root
tasks:
- name: Stop factorio
ansible.builtin.systemd:
state: stopped
name: factorio
- name: Store file /opt/factorio/saves/my-save.zip
ansible.builtin.fetch:
src: /opt/factorio/saves/my-save.zip
dest: "./saves/"

View file

@ -5,7 +5,7 @@ from os.path import exists
def login(username, password):
print("> Login for user "+username)
payload = {'username': username, 'password': password', 'api_version':'4'}
payload = {'username': username, 'password': password, 'api_version':'4'}
headers = {'content-type': 'application/json'}
r = requests.post("https://auth.factorio.com/api-login", data=payload)

View file

@ -45,6 +45,19 @@
args:
chdir: /opt/factorio/mods/
loop: "{{ mods }}"
- name: Check if Map exists on server
stat:
path: "/opt/factorio/saves/my-save.zip"
register: mapPreExists
- name: Upload Saved file from locale disk to server
ansible.builtin.copy:
src: "./saves/{{ inventory_hostname }}/opt/factorio/saves/my-save.zip"
dest: /opt/factorio/saves/my-save.zip
failed_when: False
when: mapPreExists.stat.exists == False
- name: Check if Map exists on server
stat: