From 3ace280acec54508dcd1ab9964fa57a47fb752f5 Mon Sep 17 00:00:00 2001 From: binary Date: Thu, 25 Mar 2021 21:39:06 +0100 Subject: Fix alpine quirks automatically --- roles/factorio/tasks/main.yml | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'roles/factorio/tasks') diff --git a/roles/factorio/tasks/main.yml b/roles/factorio/tasks/main.yml index 3c23569..548d7de 100644 --- a/roles/factorio/tasks/main.yml +++ b/roles/factorio/tasks/main.yml @@ -25,25 +25,33 @@ - name: download latest factorio server get_url: - url: https://factorio.com/get-download/latest/headless/linux64 + url: "{{ factorio_url }}" dest: "{{ factorio_dir }}/factorio.tar.gz" owner: "{{ factorio_user }}" group: "{{ factorio_group }}" mode: 0600 register: archive +- name: ensure GNU tar is present for busybox + package: + name: tar + state: present + when: ansible_distribution == "Alpine" + - name: untar factorio server unarchive: src: "{{ factorio_dir }}/factorio.tar.gz" dest: "{{ factorio_dir }}" + owner: "{{ factorio_user }}" + group: "{{ factorio_group }}" + remote_src: true extra_opts: - --strip-components=1 - remote_src: true when: archive.changed -- name: deploy server settings - copy: - src: server-settings.json +- name: generate server setting + template: + src: server-settings.json.j2 dest: "{{ factorio_dir }}/data/server-settings.json" owner: "{{ factorio_user }}" group: "{{ factorio_group }}" @@ -54,16 +62,18 @@ register: world - name: create default world - shell: ./bin/x64/factorio --create "{{ factorio_world }}" + shell: "{{ factorio_dir }}/bin/x64/factorio --create {{ factorio_world }}" args: chdir: "{{ factorio_dir }}" + become: true + become_user: "{{ factorio_user }}" when: world.stat.islnk is not defined - name: enable and start rc script include_role: name=rc vars: rc_cmd: "{{ factorio_dir }}/bin/x64/factorio" - rc_args: --server-settings server-settings.json --start-server "{{ factorio_world }}" + rc_args: "--server-settings data/server-settings.json --start-server {{ factorio_world }}" rc_user: "{{ factorio_user }}:{{ factorio_group }}" rc_dir: "{{ factorio_dir }}" rc_name: factorio -- cgit v1.2.3