noderings

Declare NodeRings resources in Salt states: SSH keys, DNS zones and records, firewall rulesets and virtual machines.

Every state supports test=True. Credentials come from noderings:token in the minion configuration or pillar, or the NODERINGS_TOKEN environment variable; see the execution module.

laptop-key:
  noderings.ssh_key_present:
    - name: laptop
    - public_key: ssh-ed25519 AAAA... me@laptop

example.com:
  noderings.dns_zone_present

web-1:
  noderings.vm_present:
    - plan_code: SC-GC-1C-1G-20
    - country: United States
    - city: Ashburn
    - distro: ubuntu_24_04
    - ssh_keys: [laptop]
    - firewall_ruleset: web
    - require:
      - noderings: laptop-key
      - noderings: web-firewall

www:
  noderings.dns_record_present:
    - zone: example.com
    - rtype: A
    - values:
      - {{ salt['noderings.get_vm']('web-1')['ipv4'] }}
saltext.noderings.states.noderings_mod.ssh_key_present(name, public_key, profile='noderings')[source]

Ensure an SSH key with this name holds public_key. A key with the same name but another public key is replaced.

name

Key name.

public_key

The public key, for example ssh-ed25519 AAAA... me@laptop.

saltext.noderings.states.noderings_mod.ssh_key_absent(name, profile='noderings')[source]

Ensure no SSH key has this name.

saltext.noderings.states.noderings_mod.dns_zone_present(name, dnssec=False, profile='noderings')[source]

Ensure a DNS zone exists, and optionally that it is signed with DNSSEC. Set the zone’s nameservers (in the nameservers change) at the registrar.

name

Domain, for example example.com.

dnssec

Sign the zone. Add the DS record from noderings.get_dnssec at the registrar afterwards. Turning signing off is left to noderings.delete_zone or the console, because doing it while the registrar has the DS record breaks the domain.

saltext.noderings.states.noderings_mod.dns_zone_absent(name, force=False, profile='noderings')[source]

Ensure a DNS zone does not exist. Deleting it deletes all its records.

saltext.noderings.states.noderings_mod.dns_record_present(name, zone, rtype, values, ttl=3600, profile='noderings')[source]

Ensure the records of one name and type hold exactly values.

name

Record name relative to the zone (www, @ for the apex), or fully qualified.

zone

Zone name or ID.

rtype

Record type, for example A, AAAA, CNAME, MX or TXT.

values

List of values. Hostnames should end with a dot. TXT values are plain text without quotes.

ttl

Time to live in seconds, 30 to 86400.

saltext.noderings.states.noderings_mod.dns_record_absent(name, zone, rtype, profile='noderings')[source]

Ensure there are no records of this name and type. A missing zone counts as absent.

saltext.noderings.states.noderings_mod.firewall_ruleset_present(name, rules=None, profile='noderings')[source]

Ensure a firewall ruleset exists and, when rules is given, holds exactly these rules in this order.

Rules run top to bottom, and traffic that matches no rule is accepted, so end the list with a drop rule. Each rule is a mapping with direction (ingress or egress), action (accept or drop), protocol (default tcp), source and destination (each with cidrs, address_groups, address_group_ids or vm_tags), and destination_ports / source_ports (one port such as 443 or one range such as 8000-8100).

web-firewall:
  noderings.firewall_ruleset_present:
    - name: web
    - rules:
      - {direction: ingress, action: accept, protocol: tcp, destination_ports: "22", source: {cidrs: [198.51.100.0/24]}}
      - {direction: ingress, action: accept, protocol: tcp, destination_ports: "443", source: {cidrs: [0.0.0.0/0]}}
      - {direction: ingress, action: drop, protocol: any, source: {cidrs: [0.0.0.0/0]}}
saltext.noderings.states.noderings_mod.firewall_ruleset_absent(name, force=False, profile='noderings')[source]

Ensure a firewall ruleset does not exist. force=True deletes it even while it is attached to virtual machines.

saltext.noderings.states.noderings_mod.vm_present(name, plan_code=None, country=None, city=None, distro='ubuntu_24_04', billing_type='usage', ssh_keys=None, tags=None, firewall_ruleset=None, power_state='running', allow_reinstall=False, plan_id=None, region_id=None, provider_id=None, password=None, wait_timeout=900, profile='noderings')[source]

Ensure a virtual machine with this hostname exists, in the given state.

A new VM is ordered from the cheapest offer for plan_code in country and city (or exactly plan_id and region_id). Ordering costs money: billing_type=usage bills by the hour from prepaid credit. For an existing VM, tags, firewall_ruleset and power_state are updated in place. A different distro reinstalls the VM only with allow_reinstall=True, because reinstalling erases the disk; otherwise the state reports the difference and fails. The plan and region of an existing VM are never changed.

name

Hostname. Must be unique in the organization.

power_state

running or stopped.

firewall_ruleset

Name or ID of a ruleset to attach. "" detaches the current one; None (the default) leaves it alone.

saltext.noderings.states.noderings_mod.vm_absent(name, profile='noderings')[source]

Ensure no virtual machine has this hostname. An hourly VM stops billing; a monthly subscription is cancelled without a refund.