diff --git a/README.md b/README.md index 69272ef..b45464e 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ For many of these, you can specify an ID number, a full name, or a partial name | `public_key_path` | none | Auto inferred based on the `private_key_path` | Path to SSH public key that should be installed on the server. | | `disable_ssh_password` | none | `true` | When set to `true` and SSH keys are provided password auth for SSH is disabled. | | `api_retries` | none | `5` | How many times to retry API calls on timeouts or rate limits. | +| `interfaces` | none | `public` | A list of network interfaces to create on the linode, conforming to acceptable API definition. | ## Usage @@ -121,6 +122,26 @@ platforms: # ...... ``` +Note on `interfaces`: +By default, a linode is created with a single network interface (eth0) which is +assigned a public IP address. If your test linode requires another network +interface (eth1) to mock a backend network, you may declare it within the platform +definition. If you do this, you should declare _all_ network interfaces, as +shown below. + +```yaml +platforms: + - name: debian10 + driver: + ... + interfaces: + - purpose: public + - purpose: vlan + label: myGreatVLAN + ipam_address: 11.22.33.44/24 + ... +``` + ## Development * Source hosted at [GitHub][repo] diff --git a/lib/kitchen/driver/linode.rb b/lib/kitchen/driver/linode.rb index d38ac9a..998941c 100644 --- a/lib/kitchen/driver/linode.rb +++ b/lib/kitchen/driver/linode.rb @@ -49,6 +49,13 @@ class Linode < Kitchen::Driver::Base default_config :stackscript_id, nil default_config :stackscript_data, nil default_config :swap_size, nil + default_config :interfaces, [ + { + "purpose" => "public", + "label" => nil, + "ipam_address" => nil + } + ] default_config :private_ip, false default_config :authorized_users do ENV["LINODE_AUTH_USERS"].to_s.split(",") @@ -177,6 +184,13 @@ def create_server info " type: #{config[:type]}" info " tags: #{config[:tags]}" info " swap_size: #{config[:swap_size]}" if config[:swap_size] + info " interfaces:" + config[:interfaces].each do |iface| + info " #{iface[:purpose]}" + iface.each do |iface_part, iface_value| + info " #{iface_part}: #{iface_value}" + end + end info " private_ip: #{config[:private_ip]}" if config[:private_ip] info " stackscript_id: #{config[:stackscript_id]}" if config[:stackscript_id] Retryable.retryable do @@ -189,6 +203,7 @@ def create_server stackscript_id: config[:stackscript_id], stackscript_data: config[:stackscript_data], swap_size: config[:swap_size], + interfaces: config[:interfaces], private_ip: config[:private_ip], root_pass: config[:password], authorized_keys: config[:public_key_path] ? [open(config[:public_key_path]).read.strip] : [], diff --git a/lib/kitchen/driver/linode_version.rb b/lib/kitchen/driver/linode_version.rb index 400b028..87c2ed1 100644 --- a/lib/kitchen/driver/linode_version.rb +++ b/lib/kitchen/driver/linode_version.rb @@ -19,6 +19,6 @@ module Kitchen module Driver # Version string for Linode Kitchen driver - LINODE_VERSION = "0.15.0".freeze + LINODE_VERSION = "0.15.1".freeze end end