Download Saved game
This commit is contained in:
parent
93c34d8cbe
commit
278851f1dc
4 changed files with 31 additions and 2 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
inventory.yml
|
inventory.yml
|
||||||
|
saves/
|
15
download.yml
Normal file
15
download.yml
Normal 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/"
|
|
@ -5,7 +5,7 @@ from os.path import exists
|
||||||
|
|
||||||
def login(username, password):
|
def login(username, password):
|
||||||
print("> Login for user "+username)
|
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'}
|
headers = {'content-type': 'application/json'}
|
||||||
|
|
||||||
r = requests.post("https://auth.factorio.com/api-login", data=payload)
|
r = requests.post("https://auth.factorio.com/api-login", data=payload)
|
||||||
|
|
13
setup.yml
13
setup.yml
|
@ -45,6 +45,19 @@
|
||||||
args:
|
args:
|
||||||
chdir: /opt/factorio/mods/
|
chdir: /opt/factorio/mods/
|
||||||
loop: "{{ 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
|
- name: Check if Map exists on server
|
||||||
stat:
|
stat:
|
||||||
|
|
Loading…
Reference in a new issue