Kitchen::Linode

July 21, 2022 ยท View on GitHub

Gem Gem Gem Code Climate Test Coverage CI

A Test Kitchen Driver for Linode.

asciicast

Requirements

Requires Test Kitchen and a Linode account.

gem install test-kitchen

Installation and Setup

The gem file is hosted at RubyGems. To install the gem file, run:

gem install kitchen-linode

Or, install with bundler if you have a Gemfile.

Please read the Driver usage page for more details.

Configuration

For many of these, you can specify an ID number, a full name, or a partial name that will try to match something in the list but may not match exactly what you want.

OptionEnv VarDefaultDescription
linode_tokenLINODE_TOKENnoneLinode API token. Required.
passwordLINODE_PASSWORDRandom UUIDPassword for root.
labelnoneAuto generatedLabel for the server.
tagsnone["kitchen"]List of tags to set on the server.
hostnamenoneLabel if provided, else kitchen instance nameThe hostname of the server.
imagenoneKitchen platform nameLinode image.
regionLINODE_REGIONus-eastLinode region.
typenoneg6-nanode-1Linode type.
stackscript_idnonenoneStackScript ID to provision the server with.
stackscript_datanonenoneStackScript data for user defined fields.
swap_sizenonenoneSwap size in MB.
private_ipnonefalseSet to true to add a private IP to the server.
authorized_usersLINODE_AUTH_USERS[]List of authorized Linode users for seeding SSH keys. Environment variable should be a comma separated list of usernames.
private_key_pathLINODE_PRIVATE_KEY~/.ssh/id_rsa, ~/.ssh/id_dsa, ~/.ssh/identity, or ~/.ssh/id_ecdsa, whichever first exists.Path to SSH private key that should be used to connect to the server.
public_key_pathnoneAuto inferred based on the private_key_pathPath to SSH public key that should be installed on the server.
disable_ssh_passwordnonetrueWhen set to true and SSH keys are provided password auth for SSH is disabled.
api_retriesnone5How many times to retry API calls on timeouts or rate limits.

Usage

First, set your Linode API token in an environment variable:

export LINODE_TOKEN='myrandomtoken123123213h123bh12'

Then, create a .kitchen.yml file:

---
driver:
  name: linode

provisioner:
  name: salt_solo
  formula: vim
  state_top:
    base:
      "*":
        - vim

platforms:
  - name: linode/debian10

suites:
  - name: default

then you're ready to run kitchen test or kitchen converge

kitchen test

If you want to use Vagrant for local tests and Linode for CI tests then you can add the following to your .kitchen.yml to automatically switch the driver if the LINODE_TOKEN environment variable is set:

driver:
  name: <%= ENV['LINODE_TOKEN'] ? 'linode' : 'vagrant' %>

platforms:
  - name: debian-10
    driver:
      box: bento/debian-10
      image: linode/debian10

suites:
  - name: default

Note that both the image (linode) and the box (vagrant) options are supplied in the platform driver configuration.

If you want to change any of the default settings, you can do so in the 'platforms' area:

# ...<snip>...
platforms:
  - name: ubuntu_lts
    driver:
      type: g6-standard-2
      region: eu-central
      image: linode/ubuntu20.04
# ...<snip>...

Development

Pull requests are very welcome! Make sure your patches are well tested. Ideally create a topic branch for every separate change you make. For example:

  1. Fork the repo
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Authors

Created and maintained by Brett Taylor (btaylor@linode.com)

License

Apache 2.0 (see LICENSE)