【问题标题】:chef_zero provisioner won't work in test-kitchenchef_zero 供应商在测试厨房中不起作用
【发布时间】:2014-06-11 14:16:06
【问题描述】:

在 OpsCode test-kitchen 工具中测试 chef_zero 配置程序时,我看到以下错误:

$ bundle exec kitchen test
-----> Starting Kitchen (v1.1.1)
-----> Cleaning up any prior instances of <default-ubuntu-1004>
-----> Destroying <default-ubuntu-1004>...
       ==> default: Forcing shutdown of VM...
       ==> default: Destroying VM and associated drives...
       Vagrant instance <default-ubuntu-1004> destroyed.
       Finished destroying <default-ubuntu-1004> (0m4.62s).
-----> Testing <default-ubuntu-1004>
-----> Creating <default-ubuntu-1004>...
       Bringing machine 'default' up with 'virtualbox' provider...
       ==> default: Importing base box 'opscode-ubuntu-10.04'...
       ==> default: Matching MAC address for NAT networking...
       ==> default: Setting the name of the VM: default-ubuntu-1004_default_1402458172208_54996
       Skipping Berkshelf with --no-provision
       ==> default: Clearing any previously set network interfaces...
       ==> default: Preparing network interfaces based on configuration...
           default: Adapter 1: nat
       ==> default: Forwarding ports...
           default: 22 => 2222 (adapter 1)
       ==> default: Running 'pre-boot' VM customizations...
       ==> default: Booting VM...
       ==> default: Waiting for machine to boot. This may take a few minutes...
           default: SSH address: 127.0.0.1:2222
           default: SSH username: vagrant
           default: SSH auth method: private key
           default: Warning: Connection timeout. Retrying...
       ==> default: Machine booted and ready!
       ==> default: Checking for guest additions in VM...
           default: The guest additions on this VM do not match the installed version of
           default: VirtualBox! In most cases this is fine, but in rare cases it can
           default: prevent things such as shared folders from working properly. If you see
           default: shared folder errors, please make sure the guest additions within the
           default: virtual machine match the version of VirtualBox you have installed on
           default: your host and reload your VM.
           default:
           default: Guest Additions Version: 4.2.6
           default: VirtualBox Version: 4.3
       ==> default: Setting hostname...
       ==> default: Machine not provisioning because `--no-provision` is specified.
       Vagrant instance <default-ubuntu-1004> created.
       Finished creating <default-ubuntu-1004> (0m36.52s).
-----> Converging <default-ubuntu-1004>...
       Preparing files for transfer
       Resolving cookbook dependencies with Berkshelf...
       Removing non-cookbook files before transfer
       Transfering files to <default-ubuntu-1004>
       /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-cli-1.3.0/lib/mixlib/cli.rb:226:in `parse_options': invalid option: -z (OptionParser::InvalidOption)
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.2.0/lib/chef/application.rb:78:in `configure_chef'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.2.0/lib/chef/application.rb:65:in `reconfigure'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.2.0/lib/chef/application/client.rb:217:in `reconfigure'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.2.0/lib/chef/application.rb:71:in `run'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.2.0/bin/chef-client:26:in `<top (required)>'
        from /usr/bin/chef-client:23:in `load'
        from /usr/bin/chef-client:23:in `<main>'
>>>>>> Converge failed on instance <default-ubuntu-1004>.
>>>>>> Please see .kitchen/logs/default-ubuntu-1004.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sudo -E chef-client -z --config /tmp/kitchen/client.rb --json-attributes /tmp/kitchen/dna.json --log_level info]
>>>>>> ----------------------

它似乎正在运行带有-z 标志的chef-client,但它返回的错误是invalid option

我该如何解决这个问题?

【问题讨论】:

    标签: vagrant chef-infra test-kitchen


    【解决方案1】:

    问题可能是test-kitchen 用于平台ubuntu-1004bento box 没有预先安装足够新版本的厨师。因此,使用 chef_zero 配置器的 -z 标志不可用!

    要解决此问题,请确保在 .kitchen.yml 中设置 require_chef_omnibus: latest

    ---
    driver:
      name: vagrant
    driver_config:
      require_chef_omnibus: latest
    
    provisioner:
      name: chef_zero
    
    platforms:
      - name: ubuntu-10.04
      - name: ubuntu-12.04
      - name: ubuntu-12.10
      - name: ubuntu-13.04
      - name: ubuntu-13.10
    
    suites:
      - name: default
        run_list:
         - recipe[make-me-a-sammich::default]
        attributes:
    

    编辑:

    也可能是您在本地缓存了旧版本的 OpsCode ubuntu-1004 便当盒。正如@sethvargo 指出的那样,较新的便当盒都是无供应的。如果是这种情况,您可以尝试通过先移动旧的缓存框来修复它,然后重新尝试kitchen test 命令:

    mv ~/.vagrant.d/boxes/opscode-ubuntu-10.04 ~/.vagrant.d/tmp/opscode-ubuntu-10.04
    bundle exec kitchen test ubuntu-1004 -d never
    

    如果这解决了您的问题,那么您的系统上的缓存框不正确!

    【讨论】:

    • 是的,我一开始也是这么想的,因为通常的 vagrant box URI 中包含chef-provisionerless ......但是,我能够重现它,并且它似乎在ubuntu-1004盒子,厨师确实安装在/opt/chef下。 vagrant@default-ubuntu-1004:~$ /opt/chef/bin/chef-client -v Chef: 11.2.0
    • 快速复制:git clone git@github.com:trinitronx/chef-make-me-a-sammich.git &amp;&amp; cd chef-make-me-a-sammich/bundle installbundle exec kitchen test default-ubuntu-1004 -d neverbundle exec kitchen login default-ubuntu-1004/opt/chef/bin/chef-client -v
    • @sethvargo:实际上看起来我无法在另一台机器上重现。我刚刚尝试移动本地缓存的盒子(例如mv ~/.vagrant.d/boxes/opscode-ubuntu-10.04 ~/.vagrant.d/boxes/tmp/),现在它工作正常!一定是本地缓存的操作码便当盒的旧版本。
    • @sethvargo:感谢您的回拨!它促使我进一步深入研究以找到问题。好消息是,现在我们有多个文档化的解决方案^_^
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-28
    • 1970-01-01
    相关资源
    最近更新 更多