factorio: Add basic factorio server role
yay :) 1.1 is here
This commit is contained in:
parent
ff0316277c
commit
e894ca8101
6 changed files with 225 additions and 0 deletions
26
factorio.yml
Normal file
26
factorio.yml
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
# Infrastructure
|
||||||
|
# Ansible instructions to deploy the infrastructure
|
||||||
|
# Copyright (C) 2020 Saibotk
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, version 3 of the License.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
- hosts: factorio
|
||||||
|
roles:
|
||||||
|
- docker
|
||||||
|
- docker_compose
|
||||||
|
- docker_cleanup
|
||||||
|
- factorio
|
||||||
|
environment:
|
||||||
|
PYTHONPATH: /opt/python2/ansible-dependencies/lib/python2.7/site-packages
|
27
roles/factorio/README.md
Normal file
27
roles/factorio/README.md
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
Factorio
|
||||||
|
=========
|
||||||
|
|
||||||
|
This will setup a [Factorio](https://github.com/factoriotools/factorio-docker) gameserver using a docker container.
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
You will need to have docker and docker-compose installed or declared as dependencies with their respective roles.
|
||||||
|
|
||||||
|
Role Variables
|
||||||
|
--------------
|
||||||
|
|
||||||
|
**Please look at the [defaults/main.yml](defaults/main.yml) for all available variables and their description.**
|
||||||
|
|
||||||
|
**Note: Lines that are commented out via `#` are usually still valid/used variables, but they are not defined by default, so they might enable a feature, when uncommenting/defining them!**
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
------------
|
||||||
|
|
||||||
|
- docker
|
||||||
|
- docker-compose
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
GPL-3.0-only
|
37
roles/factorio/defaults/main.yml
Normal file
37
roles/factorio/defaults/main.yml
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
---
|
||||||
|
# Default variables for the factorio role
|
||||||
|
|
||||||
|
# Infrastructure
|
||||||
|
# Ansible instructions to deploy the infrastructure
|
||||||
|
# Copyright (C) 2020 Saibotk
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, version 3 of the License.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# The install location (where the docker-compose file is stored)
|
||||||
|
factorio_install_location: "/srv/factorio"
|
||||||
|
factorio_data_location: "{{ factorio_install_location }}/data"
|
||||||
|
|
||||||
|
# The camo version that should be used
|
||||||
|
# renovate: depName=docker.io/factoriotools/factorio
|
||||||
|
factorio_version: "1.1.0"
|
||||||
|
|
||||||
|
# Docker image
|
||||||
|
factorio_image: "docker.io/factoriotools/factorio"
|
||||||
|
|
||||||
|
# The factorio server port that should be exposed
|
||||||
|
factorio_server_port: 34197
|
||||||
|
|
||||||
|
# IPv6 ULA config for the bridge network used by docker-ipv6-nat
|
||||||
|
factorio_ipv6:
|
||||||
|
enabled: false
|
||||||
|
subnet: "fd9e:21a7:a92c:2456::/64"
|
16
roles/factorio/meta/main.yml
Normal file
16
roles/factorio/meta/main.yml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
galaxy_info:
|
||||||
|
author: saibotk
|
||||||
|
description: Installs a factorio server.
|
||||||
|
license: GPL-3.0-only
|
||||||
|
min_ansible_version: 2.9
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: CentOS
|
||||||
|
versions:
|
||||||
|
- 7
|
||||||
|
|
||||||
|
galaxy_tags: []
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
- docker
|
||||||
|
- docker_compose
|
79
roles/factorio/tasks/main.yml
Normal file
79
roles/factorio/tasks/main.yml
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
---
|
||||||
|
# Tasks file for the factorio role
|
||||||
|
|
||||||
|
# Infrastructure
|
||||||
|
# Ansible instructions to deploy the infrastructure
|
||||||
|
# Copyright (C) 2020 Saibotk
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, version 3 of the License.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
- name: Update default SELinux contexts
|
||||||
|
sefcontext:
|
||||||
|
target: '{{ item }}(/.*)?'
|
||||||
|
setype: "container_file_t"
|
||||||
|
state: present
|
||||||
|
with_items:
|
||||||
|
- "{{ factorio_data_location }}"
|
||||||
|
tags:
|
||||||
|
- factorio
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Create install directory
|
||||||
|
file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: directory
|
||||||
|
mode: '0700'
|
||||||
|
owner: 'root'
|
||||||
|
group: 'root'
|
||||||
|
with_items:
|
||||||
|
- "{{ factorio_install_location }}"
|
||||||
|
become: true
|
||||||
|
tags:
|
||||||
|
- factorio
|
||||||
|
|
||||||
|
- name: Create data directory
|
||||||
|
file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: directory
|
||||||
|
mode: '0750'
|
||||||
|
owner: '845'
|
||||||
|
group: '845'
|
||||||
|
setype: "container_file_t"
|
||||||
|
with_items:
|
||||||
|
- "{{ factorio_data_location }}"
|
||||||
|
tags:
|
||||||
|
- factorio
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Deploy docker-compose.yml
|
||||||
|
template:
|
||||||
|
src: docker-compose.yml
|
||||||
|
dest: "{{ factorio_install_location }}/docker-compose.yml"
|
||||||
|
mode: '0600'
|
||||||
|
owner: 'root'
|
||||||
|
group: 'root'
|
||||||
|
validate: python2 -m compose -f %s config -q
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- factorio
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Compose factorio container
|
||||||
|
docker_compose:
|
||||||
|
state: present
|
||||||
|
project_src: "{{ factorio_install_location }}"
|
||||||
|
pull: yes
|
||||||
|
remove_orphans: yes
|
||||||
|
tags:
|
||||||
|
- factorio
|
||||||
|
become: true
|
40
roles/factorio/templates/docker-compose.yml
Normal file
40
roles/factorio/templates/docker-compose.yml
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
{{ ansible_managed | comment }}
|
||||||
|
|
||||||
|
# Infrastructure
|
||||||
|
# Ansible instructions to deploy the infrastructure
|
||||||
|
# Copyright (C) 2020 Saibotk
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, version 3 of the License.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
version: '2.1'
|
||||||
|
services:
|
||||||
|
factorio:
|
||||||
|
image: "{{ factorio_image }}:{{ factorio_version }}"
|
||||||
|
ports:
|
||||||
|
- "{{ factorio_server_port }}:34197/udp"
|
||||||
|
volumes:
|
||||||
|
- "{{ factorio_data_location }}:/factorio"
|
||||||
|
restart: always
|
||||||
|
networks:
|
||||||
|
factorio-backend:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
factorio-backend:
|
||||||
|
driver: bridge
|
||||||
|
{% if factorio_ipv6 is defined and factorio_ipv6.enabled %}
|
||||||
|
ipam:
|
||||||
|
driver: default
|
||||||
|
config:
|
||||||
|
- subnet: {{ factorio_ipv6.subnet }}
|
||||||
|
enable_ipv6: true
|
||||||
|
{% endif %}
|
Loading…
Add table
Reference in a new issue