noderings.cloud.game_server module – Order and manage NodeRings game servers

Note

This module is part of the noderings.cloud collection (version 0.2.0).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install noderings.cloud. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: noderings.cloud.game_server.

New in noderings.cloud 0.1.0

Synopsis

  • Orders a game server (for example Minecraft or Valheim) from a hosting provider on the NodeRings marketplace, keeps its name, startup variables, container image and power state as configured, and deletes it.

  • Choose what to order with plan_id, or let the module pick an offer from plan_code, country and city. List the games a plan can run with noderings.cloud.game_server_game_info.

  • Game servers are matched by name, or by id when given.

Requirements

The below requirements are needed on the host that executes this module.

  • python >= 3.9

Parameters

Parameter

Comments

accept_eula

boolean

Accept the game’s end-user licence agreement. Required when the game has one.

Choices:

  • false ← (default)

  • true

allow_game_change

boolean

When game differs from what an existing server runs, change the game in place. The server keeps its address, but all files, schedules and backups are deleted.

Choices:

  • false ← (default)

  • true

api_retries

integer

How many times a request is retried after rate limiting (HTTP 429) or a gateway error (HTTP 502, 503 or 504).

Orders (virtual machines, game servers, snapshots) are never retried blindly.

Default: 5

api_timeout

integer

Timeout in seconds for a single HTTP request.

Default: 60

api_token

aliases: token

string

A NodeRings service-account token.

Create one in the NodeRings console under Organization > Service accounts.

If not set, the value of the NODERINGS_TOKEN, NODERINGS_API_TOKEN or NR_API_TOKEN environment variable is used.

api_url

string

Base URL of the NodeRings API.

If not set, the value of the NODERINGS_API_URL environment variable is used.

Default: "https://api.noderings.com"

billing_type

string

Billing type of the offer when using plan_code.

Choices:

  • "usage"

  • "subscription"

  • "free"

city

string

City of the offer. Required with plan_code.

country

string

Country of the offer. Required with plan_code.

docker_image

string

Container image the game runs in. Must be one of the game’s images (see noderings.cloud.game_server_info).

environment

dictionary

Startup variables, such as the game version or player limit. Only the keys listed are managed.

Default: {}

game

string

Game to install, by name (for example Minecraft) or by the id from noderings.cloud.game_server_game_info. Game IDs are specific to the plan’s provider.

Required when the server is ordered.

id

string

ID of an existing server.

name

string

Name of the server, 1 to 64 characters. Used to find an existing server, so keep it unique.

Required unless id is given.

new_name

string

Rename the server found by name or id to this.

organization_id

string

Organization to act in, sent as the X-Organization-ID header.

Defaults to the organization the token belongs to.

If not set, the value of the NODERINGS_ORGANIZATION_ID or NR_ORGANIZATION_ID environment variable is used.

plan_code

string

Marketplace plan code, for example SC-GS-4C-8G-50. The module picks an offer in country and city.

plan_id

string

Game-server plan to order. Mutually exclusive with plan_code.

provider

string

Only consider offers from this hosting provider, given by its provider ID, its storefront slug (for example acme-hosting) or its name (for example Acme Hosting, in any case).

A name that more than one provider uses fails; give the provider ID or storefront slug then.

Without a provider the module picks the best offer from any provider (see sort).

Mutually exclusive with provider_id.

provider_id

string

Only consider offers from this provider.

region_id

string

Region to place the server in. Defaults to the region of the node it lands on.

sort

string

How to choose between offers.

Choices:

  • "price" ← (default)

  • "rating"

state

string

present orders the server if needed. running and offline also start or stop it.

restarted restarts it. absent deletes it with all its files; billing stops.

Choices:

  • "present" ← (default)

  • "running"

  • "offline"

  • "restarted"

  • "absent"

validate_certs

boolean

Whether to validate the API’s TLS certificate.

Choices:

  • false

  • true ← (default)

version

string

Game version to install. Only used when the server is ordered; later, set the version variable in environment.

wait

boolean

Wait until the operation has finished before returning.

Choices:

  • false

  • true ← (default)

wait_timeout

integer

How long to wait, in seconds, when wait=true.

Default: 1800

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying the target.

diff_mode

Support: full

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Notes

Note

  • All modules in this collection belong to the noderings.cloud.noderings action group, so connection options can be set once with module_defaults.

Examples

- name: A Minecraft server in Frankfurt
  noderings.cloud.game_server:
    name: survival
    plan_code: SC-GS-4C-8G-50
    country: Germany
    city: Frankfurt
    billing_type: subscription
    game: Minecraft
    accept_eula: true
    environment:
      MAX_PLAYERS: "20"
    state: running
  register: mc

- name: Tell players where to connect
  ansible.builtin.debug:
    msg: "{{ mc.game_server.primary_ip }}:{{ mc.game_server.primary_port }}"

- name: Stop it
  noderings.cloud.game_server:
    name: survival
    state: offline

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

game_server

dictionary

The server. Empty after state=absent.

Returned: always

Sample: {"game_name": "Minecraft", "id": "5e4d3c2b-0000-0000-0000-000000000000", "name": "survival", "phase": "ready", "plan_code": "SC-GS-4C-8G-50", "power_state": "running", "primary_ip": "203.0.113.20", "primary_port": 25565, "provider_name": "Example Hosting", "region_city": "Frankfurt", "variant": "Paper"}

Authors

  • Shaygun (@shaygun)