Giter VIP home page Giter VIP logo

ansible_minecraftserver's Introduction

ansible_minecraftserver

This is an ansible role to install a minecraft server as docker container controlled by systemd.

I'm using itzg's docker image. Thanks for your great work!

System requirements

  • Docker
  • docker-compose
  • Systemd

Role requirements

  • (none, so far)

Tasks

  • Template docker-compose file environment
  • Create data volume directory for docker container
  • Setup systemd unit file
  • Start/Restart systemd service

Role parameters

Variable Type Mandatory? Default Description
minecraftserver_state text no 'present' If absent removes the docker configuration and systemd service
minecraftserver_image_version text no 'latest' itzg's Docker image version
minecraftserver_version text no '' Minecraft Server version (e.g. 1.16.5, default: latest version will be downloaded)
minecraftserver_interface text no 0.0.0.0 Mapped network interface
minecraftserver_port text no 25565 Mapped network port
minecraftserver_data_volume_directory text no /srv/minecraftserver/minecraft-data Location of your data volume directory
minecraftserver_environment key-value map no {} Specifies the environment for the docker image (See itzg's documentation)
minecraftserver_force_remove boolean no false Only for state absent: Specifies if your data volume directory will be deleted on when uninstalling

Example Playbook

Add to requirements.yml:

- name: install-minecraftserver
  src: https://github.com/borisskert/ansible_minecraftserver.git
  scm: git

Example playbook.yml:

- hosts: servers
  roles:
    - role: install-minecraftserver
      minecraftserver_state: present
      minecraftserver_image_version: latest
      minecraftserver_version: '1.16.5'
      minecraftserver_interface: 0.0.0.0
      minecraftserver_port: 25565
      minecraftserver_data_volume_directory: /srv/minecraftserver/minecraft-data
      minecraftserver_environment:
        SEED: 1785852800490497919
        VIEW_DISTANCE: 10
        MODE: creative
        MOTD: My super cool MC server

Example playbook.yml for uninstall:

- hosts: servers
  roles:
    - role: install-minecraftserver
      minecraftserver_state: absent
      minecraftserver_force_remove: true

Testing

Requirements:

Run within docker

molecule test && molecule test --scenario-name all-parameters && molecule test --scenario-name state-absent && molecule test --scenario-name with-environment && molecule test --scenario-name state-absent-force-remove-persistent-data

Run within Vagrant

molecule test -s vagrant-default && molecule test -s vagrant-all-parameters && molecule test --scenario-name vagrant-state-absent && molecule test --scenario-name vagrant-with-environment && molecule test --scenario-name vagrant-state-absent-force-remove-persistent-data

I recommend to use pyenv for local testing. Within the Github Actions pipeline I use my own molecule Docker image.

License

MIT

Author Information

Further links

ansible_minecraftserver's People

Contributors

borisskert avatar

Watchers

 avatar  avatar

Forkers

lukas-holzner

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.