Skip to content

About

Chef Infra cookbook for NodeRings: custom resources for virtual machines, DNS zones and records, firewall rulesets and SSH keys. Works with Chef and Cinc.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

noderings cookbook

Cookbook Version CI License

Custom resources to manage NodeRings from Chef Infra: virtual machines ordered from the NodeRings marketplace, DNS zones and records, firewall rulesets and SSH keys.

New to it? The step-by-step guide How to use Chef on a NodeRings VPS: cookbook, knife and Test Kitchen walks through a first run.

noderings_ssh_key 'deploy' do
  public_key ::File.read('/home/deploy/.ssh/id_ed25519.pub')
end

noderings_firewall_ruleset 'web' do
  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'] } },
  ]
end

noderings_vm 'web-1' do
  plan 'SC-GC-1C-1G-20'
  country 'United States'
  city 'Ashburn'
  distro 'ubuntu_24_04'
  ssh_keys ['deploy']
  firewall_ruleset 'web'
end

noderings_dns_zone 'example.com'

noderings_dns_record 'www' do
  zone 'example.com'
  type 'A'
  values(lazy { node.run_state['noderings']['vms']['web-1']['ipv4'] })
  ttl 300
end

The resources call the NodeRings API, so they can run on any node: a workstation with chef-client --local-mode, a management node, or a CI runner. They use the Ruby standard library only and install nothing on the node.

Installation

The cookbook is on Chef Supermarket. Add it as a dependency in a wrapper cookbook's metadata.rb:

depends 'noderings'

With Berkshelf, in the Berksfile:

source 'https://supermarket.chef.io'
cookbook 'noderings'

With a Policyfile:

default_source :supermarket
cookbook 'noderings'

Requirements

Chef Infra Client

  • Chef Infra Client 17 or later, or Cinc Client 17 or later

Platforms

The resources only make HTTPS calls, so they run on every platform Chef Infra supports: Linux distributions, macOS and Windows.

NodeRings

  • A service account token. Create one in the NodeRings console under Organization → Access Control → Service accounts, with the permissions for the resources you use.
  • For noderings_vm: a payment method or credit on the organization. Ordering a virtual machine is billed.

Credentials

Each resource takes the token from, in order:

  1. its api_token property,
  2. node.run_state['noderings_api_token'],
  3. the NODERINGS_TOKEN environment variable (also NODERINGS_API_TOKEN or NR_API_TOKEN).

Keep the token out of node attributes, which are saved to the Chef Infra Server. Load it from an encrypted source at the start of the run instead, for example with chef-vault:

node.run_state['noderings_api_token'] = chef_vault_item('secrets', 'noderings')['token']

api_url and organization_id work the same way, with the NODERINGS_API_URL and NODERINGS_ORGANIZATION_ID environment variables.

Resources

All resources share the API properties and support why-run mode (chef-client --why-run), which reports what would change without calling any write endpoint.

Using what a resource created

Resources publish what they learned, such as IDs and IP addresses, in node.run_state['noderings'], keyed by kind and name:

Key Contents
['vms'][hostname] id, ipv4, ipv6, power_state, distro, plan_code, billing_type, firewall_ruleset_id, tags
['dns_zones'][zone] id, nameservers (to set at your registrar), state, dnssec_mode, ds
['firewall_rulesets'][name] id
['ssh_keys'][name] id

Read them with lazy in later resources, as in the DNS record above.

Testing

See TESTING.md. In short: cookstyle, chef exec rspec for the unit tests (no token needed), and Test Kitchen for the integration suites, which call the real API.

Related projects

Contributing

See CONTRIBUTING.md.

License

Copyright NodeRings. Licensed under the Apache License, Version 2.0.

About

Chef Infra cookbook for NodeRings: custom resources for virtual machines, DNS zones and records, firewall rulesets and SSH keys. Works with Chef and Cinc.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages