noderings.cloud.virtual_machine module – Order and manage NodeRings virtual machines

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.virtual_machine.

New in noderings.cloud 0.1.0

Synopsis

  • Orders a virtual machine from a hosting provider on the NodeRings marketplace, keeps its tags, firewall and power state as configured, reinstalls it on request, and deletes it.

  • Choose what to order either with plan_id and region_id, or let the module pick an offer from plan_code, country and city (see noderings.cloud.marketplace_offer_info).

  • Plan, region and offer options are only used when the VM is ordered. An existing VM is never moved to another offer, so a cheaper offer appearing later does not replace your server.

  • VMs are matched by hostname, or by id when given.

Requirements

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

  • python >= 3.9

Parameters

Parameter

Comments

allow_reinstall

boolean

Reinstall an existing VM when distro or instant_app differs from what it runs. This erases the disk.

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

usage (billed hourly from prepaid credit), subscription (monthly, charged to the card) or free.

Strongly recommended with plan_code; without it each provider offers one plan of its choice.

Choices:

  • "usage"

  • "subscription"

  • "free"

city

string

City of the offer, for example Frankfurt. Required with plan_code.

country

string

Country of the offer, for example Germany. Required with plan_code.

coupon_code

string

Promotion code applied to the order.

distro

string

Operating system, for example ubuntu_24_04 or debian_12. See noderings.cloud.distro_info.

Defaults to the provider’s default distro, or the instant app’s distro.

For an existing VM a different value only takes effect with allow_reinstall=true or state=reinstalled.

firewall_ruleset

string

Name or ID of the firewall ruleset to attach. An empty string detaches the current one.

Leave unset to not manage the firewall. The provider must support guest_firewall.

hostname

string

Hostname of the VM. Used to find an existing VM, so keep it unique within the organization.

Required unless id is given.

id

string

ID of an existing VM. Takes precedence over hostname for finding the VM.

instant_app

string

Slug of a one-click application to install, for example wordpress. See noderings.cloud.instant_app_info.

instant_app_variables

dictionary

Settings for the instant app.

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.

password

string

Root password. Only used when the VM is ordered or reinstalled. Prefer ssh_keys.

plan_code

string

Marketplace plan code, for example SC-GC-1C-1G-20. The module picks an offer for this code in country and city. See noderings.cloud.marketplace_plan_info.

plan_id

string

Plan to order. Use together with region_id. 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), so the provider can change from one order to the next. Set this to keep it fixed.

Mutually exclusive with provider_id and storefront_slug.

provider_id

string

Only consider offers from this hosting provider.

purge_tags

boolean

Remove tags that are not in tags. With false, tags are only added.

Choices:

  • false

  • true ← (default)

region_id

string

Region of plan_id.

require_capabilities

list / elements=string

Only consider providers that support all of these, for example guest_firewall, snapshots, on_demand_backup or instant_apps.

guest_firewall is added automatically when firewall_ruleset is set.

Default: []

require_ipv6

boolean

Only consider offers with IPv6 in the city.

Choices:

  • false ← (default)

  • true

sort

string

How to choose between offers. price picks the cheapest compute price, rating the best-rated provider.

Choices:

  • "price" ← (default)

  • "rating"

ssh_keys

list / elements=string

Names or IDs of SSH keys to install for root. See noderings.cloud.ssh_key.

Only used when the VM is ordered or reinstalled.

Default: []

state

string

present orders the VM if needed and leaves its power state alone.

running and stopped also start or stop it.

restarted stops and starts it.

reinstalled reinstalls it from distro or instant_app. This erases the disk every time it runs.

absent deletes it. Billing stops.

Choices:

  • "present" ← (default)

  • "running"

  • "stopped"

  • "restarted"

  • "reinstalled"

  • "absent"

storefront_slug

string

Only consider offers from the provider with this public storefront.

tags

list / elements=string

Tags. Firewall rules can match VMs by tag.

Leave unset to not manage tags.

validate_certs

boolean

Whether to validate the API’s TLS certificate.

Choices:

  • false

  • true ← (default)

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: Order a small hourly server in Ashburn
  noderings.cloud.virtual_machine:
    hostname: web-1
    plan_code: SC-GC-1C-1G-20
    country: United States
    city: Ashburn
    billing_type: usage
    distro: ubuntu_24_04
    ssh_keys: [laptop]
    tags: [web, prod]
    firewall_ruleset: web
    state: running
  register: vm

- name: Order the same size from one provider, by its storefront slug
  noderings.cloud.virtual_machine:
    hostname: web-2
    plan_code: SC-GC-1C-1G-20
    country: United States
    city: Ashburn
    billing_type: usage
    provider: acme-hosting
    distro: ubuntu_24_04
    ssh_keys: [laptop]
    state: running

- name: Wait for SSH
  ansible.builtin.wait_for:
    host: "{{ vm.virtual_machine.ipv4 }}"
    port: 22

- name: Stop it for the night
  noderings.cloud.virtual_machine:
    hostname: web-1
    state: stopped

- name: Delete it
  noderings.cloud.virtual_machine:
    hostname: web-1
    state: absent

Return Values

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

Key

Description

offer

dictionary

The offer that was ordered, when the module chose one from plan_code.

Returned: when a VM was ordered from plan_code

virtual_machine

dictionary

The VM. Empty after state=absent.

Returned: always

Sample: {"billing_type": "usage", "capabilities": ["guest_firewall", "snapshots"], "cpu": 1, "distro": "ubuntu_24_04", "firewall_ruleset_id": "7a6b5c4d-1111-2222-3333-444455556666", "hostname": "web-1", "id": "2f6e0d1c-0000-4b4b-8c8c-0123456789ab", "ipv4": "203.0.113.10", "ipv6": "2001:db8::10", "memory": 1, "plan_code": "SC-GC-1C-1G-20", "plan_id": "7f3a9c1e-0000-0000-0000-000000000000", "power_state": "running", "provider_name": "Example Hosting", "provisioning_status": "applied", "region_city": "Ashburn", "region_country": "United States", "region_id": "2b8d4e6f-0000-0000-0000-000000000000", "storage": 20, "tags": ["prod", "web"]}

Authors

  • Shaygun (@shaygun)