bplower.factorio

Factorio

Install from Ansible Galaxy Ansible Lint

This is a role for setting up Factorio servers. Check it out at https://galaxy.ansible.com/bplower/factorio/

Requirements

No requirements needed.

Role Variables

The variables are mainly divided into two sections: deployment settings and Factorio settings.

Deployment Settings

These settings relate to how Ansible installs the Factorio server. They are flexible enough to allow running multiple Factorio servers at the same time.

server_sources: "/opt/games/sources/factorio"
server_version: "0.17.79"
download_url: "https://www.factorio.com/get-download/{{ server_version }}/headless/linux64"
service_name: "factorio-server"
service_user: "factorio"
service_group: "factorio"
service_root: "/home/{{ service_user }}"
service_port: 34197
service_restart_permitted: true
factorio_default_save: "{{ service_root }}/factorio/saves/default-save.zip"
factorio_target_save: "{{ factorio_default_save }}"

Here’s a breakdown of these variables:

  • server_sources: Where to save the server files. Default is "/opt/games/sources/factorio".

  • server_version: The version of Factorio to install. Default is "0.17.79".

  • download_url: The URL source for downloading the server binary. Default is "https://www.factorio.com/get-download/{{ server_version }}/headless/linux64".

  • download_checksum: The checksum for the server binary. Ensures the file is valid. If you change the version or URL, update this as well. Default is "sha256:9ace12fa986df...''.

  • service_name: The name of the service to be created. Default is "factorio-server".

  • service_user: The user account under which the service runs. Default is "factorio".

  • service_group: The group the service user belongs to. Default is "factorio".

  • service_root: The directory for the downloaded Factorio files. Default is "/home/{{ service_user }}".

  • service_port: The port for the service. Default value is 34197.

  • service_restart_permitted: If set to false, the service won’t restart after changes are made, allowing updates without interruption. Default is true.

  • factorio_default_save: The default save path. Default is "{{ service_root }}/factorio/saves/default-save.zip".

  • factorio_target_save: The save file that the server will use. Default is the same as factorio_default_save.

Factorio Settings

Configuration settings for various files can be set in dictionaries named after those files. Each dictionary begins with factorio_ followed by the file name, with hyphens replaced by underscores.

For example, the server-settings.json file corresponds to the dictionary variable factorio_server_settings.

Example config files include:

  • Filename: server-settings.json
    Variable: factorio_server_settings
    Example:

    factorio_server_settings:
      name: "My Public Server"
      max_players: 10
      game_password: "mypassword"
      visibility:
        public: true
        lan: true
    
  • Filename: server-whitelist.json
    Variable: factorio_server_whitelist
    Example:

    factorio_server_whitelist:
    - Oxyd
    
  • Filename: map-settings.json
    Variable: factorio_map_settings
    Example:

    factorio_map_settings:
      pollution:
        enabled: false
    
  • Filename: map-gen-settings.json
    Variable: factorio_map_gen_settings
    Example:

    factorio_map_gen_settings:
      water: "high"
      autoplace_controles:
        coal:
          size: "very-low"
    

Example Playbooks

Here’s how to create a basic Factorio server:

---
- name: Create a default Factorio server
  hosts: localhost
  roles:
  - role: bplower.factorio

Creating a server with a custom port and name:

---
- name: My slightly changed Factorio server
  hosts: localhost
  roles:
  - role: bplower.factorio
    service_port: 12345
    factorio_server_settings:
      name: "My factorio server"

Setting up multiple servers on one host:

---
- name: Factorio farm
  hosts: localhost
  roles:
  - role: bplower.factorio
    service_port: 50001
    service_name: factorio_1
    service_root: /home/{{ service_user }}/{{ service_name }}
  - role: bplower.factorio
    service_port: 50002
    service_name: factorio_2
    service_root: /home/{{ service_user }}/{{ service_name }}

License

GNU GPLv3

Development & Contributions

This project is not actively maintained, but the aim is to keep it up to date. Please feel free to open issues or pull requests if needed.

Testing

This role uses yamllint for checking YAML files and Molecule with Docker for testing. You can install the necessary tools with the command:

pip install -r dev-requirements.txt

Bear in mind that Docker needs to be installed separately.

The tests are organized into three categories based on the platforms. You can start tests using Makefile:

$ make help

Usage:
  make

Targets:
  help        Show this help
  lint        Check YAML files
  test_all    Run all tests
  test_centos  Run CentOS tests
  test_debian  Run Debian tests
  test_ubuntu  Run Ubuntu tests
Informazioni sul progetto

A role for creating Factorio servers

Installa
ansible-galaxy install bplower.factorio
Licenza
Unknown
Download
310
Proprietario