--- - name: Download headless factorio get_url: url: "https://www.factorio.com/get-download/{{ item.factorio_version }}/headless/linux64" dest: /tmp/factorio_headless_{{item.factorio_version}}.tar.xz with_items: - "{{ factorio_servers }}" - name: Create game server directories file: path: "/srv/factorio/{{ item.name }}" state: directory owner: factorio group: factorio with_items: - "{{ factorio_servers }}" - name: Extract headless factorio unarchive: src: "/tmp/factorio_headless_{{item.factorio_version}}.tar.xz" dest: "/srv/factorio/{{ item.name }}" owner: factorio group: factorio remote_src: True with_items: - "{{ factorio_servers }}" - name: Create factorio service template: src: templates/factorio.service dest: "/etc/systemd/system/factorio@.service" - name: Create saves if not exist become: yes become_user: factorio command: cmd: "/srv/factorio/{{ item.name }}/factorio/bin/x64/factorio --create {{ item.name }}" chdir: "/srv/factorio/{{ item.name }}/factorio" creates: "/srv/factorio/{{ item.name }}/factorio/{{ item.name }}.zip" with_items: - "{{ factorio_servers }}" - name: Create server configuration template: src: templates/factorio-config.ini dest: "/srv/factorio/{{ item.name }}/factorio/config/config.ini" owner: factorio group: factorio with_items: - "{{ factorio_servers }}" - name: Reload systemd state systemd_service: daemon_reload: true state: started enabled: true name: factorio@{{ item.name }} with_items: - "{{ factorio_servers }}" - name: Allow all server ports through firewall firewalld: port: "{{ item.server_port }}/udp" permanent: true immediate: true state: enabled with_items: - "{{ factorio_servers }}"