test-kitchen / kitchen-vagrant

A Test Kitchen Driver for Vagrant
Other
348 stars 189 forks source link

`network': wrong number of arguments (given 2, expected 1) (ArgumentError) #501

Closed pkelly-mitre closed 3 months ago

pkelly-mitre commented 3 months ago

:speaking_head: Foreword

I am unable to configure my kitchen.yml file to setup a private_network using either type "dhcp" or also manually assigning the ip address.

:ghost: Brief Description

Trying to setup two systems using Test kitchen kitchen.yml. I need to set them up with private networks. I tried using type "dhcp" and also manually setting the ip but getting the same error both times.

Version

Vagrant 2.4.1

Environment

Ubuntu 20.04 Test Kitchen version 3.0.0 VirtualBox: 7.0.18r162988

Scenario

Trying to create systems that assign different ips to each system

Steps to Reproduce

Running kitchen converge with the following kitchen.yml. Everything works fine without the private network field.

driver:
  name: vagrant
  synced_folders:
    - ["../vagrant_data", "/vagrant_data"]

provisioner:
  name: chef_zero

verifier:
  name: inspec

platforms:
  - name: ubuntu-20.04

suites:
  - name: default
    driver:
      vm_hostname: mitan-1
      network: 
        - ["private_network", {ip: "192.168.33.10"}]
    verifier:
      inspec_tests:
        - test/integration/default
    attributes:
  - name: agent
    driver:
      vm_hostname: mitan-2
      network: 
        - ["private_network", {ip: "192.168.33.11"}]
    verifier:
      inspec_tests:
        - test/integration/default

Expected Result

Kitchen converge runs smoothly and at the end I have two VMs with separate ip addresses

Actual Result

-----> Starting Test Kitchen (v3.0.0)
-----> Creating <default-ubuntu-2004>...
       /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/plugins/kernel_v2/config/vm.rb:326:in `network': wrong number of arguments (given 2, expected 1) (ArgumentError)
        from /home/pkelly/projects/cten-components-mitan/.kitchen/kitchen-vagrant/default-ubuntu-2004/Vagrantfile:5:in `block in <top (required)>'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/v2/loader.rb:40:in `load'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:129:in `block (2 levels) in load'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:122:in `each'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:122:in `block in load'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:119:in `each'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:119:in `load'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/vagrantfile.rb:34:in `initialize'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/environment.rb:835:in `new'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/environment.rb:835:in `vagrantfile'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/environment.rb:1016:in `process_configured_plugins'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/environment.rb:200:in `initialize'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/bin/vagrant:211:in `new'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/bin/vagrant:211:in `<main>'
-----> Creating <agent-ubuntu-2004>...
       /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/plugins/kernel_v2/config/vm.rb:326:in `network': wrong number of arguments (given 2, expected 1) (ArgumentError)
        from /home/pkelly/projects/cten-components-mitan/.kitchen/kitchen-vagrant/agent-ubuntu-2004/Vagrantfile:5:in `block in <top (required)>'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/v2/loader.rb:40:in `load'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:129:in `block (2 levels) in load'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:122:in `each'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:122:in `block in load'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:119:in `each'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:119:in `load'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/vagrantfile.rb:34:in `initialize'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/environment.rb:835:in `new'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/environment.rb:835:in `vagrantfile'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/environment.rb:1016:in `process_configured_plugins'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/environment.rb:200:in `initialize'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/bin/vagrant:211:in `new'
        from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/bin/vagrant:211:in `<main>'
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 2 actions failed.
>>>>>>     Failed to complete #create action: [Expected process to exit with [0], but received '1'
---- Begin output of vagrant up --no-provision --provider virtualbox ----
STDOUT: 
STDERR: /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/plugins/kernel_v2/config/vm.rb:326:in `network': wrong number of arguments (given 2, expected 1) (ArgumentError)
    from /home/pkelly/projects/cten-components-mitan/.kitchen/kitchen-vagrant/default-ubuntu-2004/Vagrantfile:5:in `block in <top (required)>'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/v2/loader.rb:40:in `load'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:129:in `block (2 levels) in load'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:122:in `each'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:122:in `block in load'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:119:in `each'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:119:in `load'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/vagrantfile.rb:34:in `initialize'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/environment.rb:835:in `new'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/environment.rb:835:in `vagrantfile'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/environment.rb:1016:in `process_configured_plugins'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/environment.rb:200:in `initialize'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/bin/vagrant:211:in `new'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/bin/vagrant:211:in `<main>'
---- End output of vagrant up --no-provision --provider virtualbox ----
Ran vagrant up --no-provision --provider virtualbox returned 1] on default-ubuntu-2004
>>>>>>     Failed to complete #create action: [Expected process to exit with [0], but received '1'
---- Begin output of vagrant up --no-provision --provider virtualbox ----
STDOUT: 
STDERR: /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/plugins/kernel_v2/config/vm.rb:326:in `network': wrong number of arguments (given 2, expected 1) (ArgumentError)
    from /home/pkelly/projects/cten-components-mitan/.kitchen/kitchen-vagrant/agent-ubuntu-2004/Vagrantfile:5:in `block in <top (required)>'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/v2/loader.rb:40:in `load'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:129:in `block (2 levels) in load'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:122:in `each'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:122:in `block in load'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:119:in `each'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/config/loader.rb:119:in `load'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/vagrantfile.rb:34:in `initialize'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/environment.rb:835:in `new'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/environment.rb:835:in `vagrantfile'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/environment.rb:1016:in `process_configured_plugins'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/lib/vagrant/environment.rb:200:in `initialize'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/bin/vagrant:211:in `new'
    from /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/bin/vagrant:211:in `<main>'
---- End output of vagrant up --no-provision --provider virtualbox ----
Ran vagrant up --no-provision --provider virtualbox returned 1] on agent-ubuntu-2004
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

:heavy_plus_sign: Additional context

Downgrading to different versions has not worked for me as suggested in other posts.

Stromweld commented 3 months ago

can you upgrade your test-kitchen version to latest 3.6.0 and see if that fixes your issue.

Stromweld commented 3 months ago

Is this also for private within the local workstation or are you looking for the box to be on the local network with private IP similar to the workstations primary network IP? This requires bridged interface to be used like:

network:
    - [ "public_network", { bridge: [ 'en9: StartTech DK30CH2DEP', 'en0: Wi-Fi (Wireless)' ], type: dhcp } ]
pkelly-mitre commented 3 months ago

I am trying to use it private within the workstation. Updating to latest version fixed my issue. Thank you