Coder Social home page Coder Social logo

vagrant-serverspec's Introduction

Vagrant-Serverspec


Gem Version

vagrant-serverspec is a vagrant plugin that implements serverspec as a provisioner.

Installing

Standard way

First, install the plugin.

$ vagrant plugin install vagrant-serverspec

In case of fork usage

in case of fork usage you need to build it first

gem build vagrant-serverspec.gemspec

(on windows you may use embedded vagrant ruby for that)

C:\HashiCorp\Vagrant\embedded\bin\gem.bat build vagrant-serverspec.gemspec

after that install plugin from filesystem

vagrant plugin install ./vagrant-serverspec-0.5.0.gem

Example Usage

Next, configure the provisioner in your Vagrantfile.

Vagrant.configure('2') do |config|
  config.vm.box = 'precise64'
  config.vm.box_url = 'http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-vagrant-amd64-disk1.box'

  config.vm.provision :shell, inline: <<-EOF
    sudo ufw allow 22
    yes | sudo ufw enable
  EOF

  config.vm.provision :serverspec do |spec|
    # pattern for specfiles to search
    spec.pattern = '*_spec.rb'
    # pattern for specfiles to ignore, similar to rspec's --exclude-pattern option
    spec.exclude_pattern = 'but_not_*_spec.rb'
    # disable error if no specfile was found ( useful with dynamic specfile retrieving through another provisionner like Ansible Galaxy => specfiles can be saved into ansible role repository for example ). Default: true
    spec.error_no_spec_files = false
    # save result into html an report, saved into a 'rspec_html_reports' directory. Default: false
    spec.html_output = true
    # save result into junit xml report, default file name is 'rspec.xml'
    spec.junit_output = true
    # set custom junit xml report file name
    spec.junit_output_file = 'junit.xml'
  end
end

You may want to override standard settings; a file named spec_helper.rb is usually used for that. Here are some examples of possible overrides.

# Disable sudo
# set :disable_sudo, true

# Set environment variables
# set :env, :LANG => 'C', :LC_MESSAGES => 'C' 

# Set PATH
# set :path, '/sbin:/usr/local/sbin:$PATH'

Then you're ready to write your specs.

require_relative 'spec_helper'

describe package('ufw') do
  it { should be_installed }
end

describe service('ufw') do
  it { should be_enabled }
  it { should be_running }
end

describe port(22) do
  it { should be_listening }
end

##Testing Docker Containers on OSX On OSX the Vagrant docker provider runs a Boot2Docker VM, then launches your docker container on that VM. Vagrant does SSH Proxying to send the commands through that VM and have them reach the Docker Container. Vagrant serverspec handles this the same way by getting the container host VM infromation and proxying the commands to the machine through an SSH Proxy. This functionality was introduced in this PR

Additional informations

SSH connections

SSH connection is closed before each provision run. This is mandatory if the provision is applied to multiple vms in the same run, else all runs will be applied to the first vm (See #22) due to an SSH connection which already exists. This functionality was introduced in this PR

Server spec examples

RSpec examples are clear before each provision run. This is mandatory if the provision is applied to multiple vms in the same run, else each run replay examples of previous calls also. This functionality was introduced in this PR

In case of shared examples

If you use shared examples into your test suite, you need to use 'load' instead of 'require', else errors can occurs (See #23 comments).

Versioning

vagrant-serverspec aims to adhere to Semantic Versioning 2.0.0.

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

Original Idea Jeremy Voorhis ([email protected]).
Current version author and maintainer Vladimir Babchynskyy ([email protected])
and a growing community of contributors.

License

MIT license (see LICENSE)

vagrant-serverspec's People

Contributors

achaussier avatar athak avatar endemics avatar jvoorhis avatar mizzy avatar samyscoub avatar stigkj avatar tyzhnenko avatar vvchik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vagrant-serverspec's Issues

serverspec appears to do nothing.

I've attached a set of files that create the output shown below. My expected result is a reported test failure ('NEVER PASSES').
t
spec-test.zip

neil@neptune ~/src/nextpathway/solr $ vagrant provision 
==> default: Running provisioner: serverspec...
<<< running helper

Command "java -version"
  stderr
Please set sudo password to Specinfra.configuration.sudo_password.

Finished in 0.24973 seconds (files took 1.68 seconds to load)
1 example, 0 failures

Finished in 0.24973 seconds (files took 1.68 seconds to load)
1 example, 0 failures

Cannot install vagrant-serverspec plugin

Vagrant aborts the installation of this plugin due to a dependency needing a newer version of ruby,

vagrant version
Installed Version: 2.2.6
Latest Version: 2.2.6
vagrant plugin install vagrant-serverspec
Installing the 'vagrant-serverspec' plugin. This can take a few minutes...
Fetching: diff-lcs-1.3.gem (100%)
Fetching: rspec-expectations-3.9.0.gem (100%)
Fetching: rspec-mocks-3.9.0.gem (100%)
Fetching: rspec-3.9.0.gem (100%)
Fetching: rspec-its-1.3.0.gem (100%)
Fetching: net-telnet-0.1.1.gem (100%)
Fetching: sfl-2.3.gem (100%)
Fetching: specinfra-2.82.2.gem (100%)
Fetching: serverspec-2.41.5.gem (100%)
Fetching: os-0.9.6.gem (100%)
Vagrant failed to properly resolve required dependencies. These
errors can commonly be caused by misconfigured plugin installations
or transient network issues. The reported error is:

activesupport requires Ruby version >= 2.5.0.
/opt/vagrant/embedded/bin/ruby --version
ruby 2.4.9p362 (2019-10-02 revision 67824) [x86_64-darwin13]

Please let me know if I should report this bug to the vagrant team.

Lock error

This plugin always gives me the following error:

$> vagrant provision
==> default: Running provisioner: serverspec...
An action 'up' was attempted on the machine 'default',
but another process is already executing an action on the machine.
Vagrant locks each machine for access by only one process at a time.
Please wait until the other Vagrant process finishes modifying this
machine, then try again.

Using Vagrant 1.8.1 with Virtualbox 5.

Vagrant.configure(2) do |config|

  config.vm.box = "scalefactory/centos6"

   config.ssh.insert_key = false
  config.vm.provision "serverspec" do |spec|
     spec.pattern = 'spec/default/*_spec.rb'
  end

end

serverspec tests failing

Failures:

  1. File "/opt/tomcat7" should be directory
    On host `127.0.0.1'
    Failure/Error: it { should be_directory}
    SystemStackError:
    stack level too deep
 # C:/Users/user/.vagrant.d/gems/gems/specinfra-2.59.6/lib/specinfra/properties.rb:10:in `properties'
 # C:/Users/user/.vagrant.d/gems/gems/specinfra-2.59.6/lib/specinfra/helper/properties.rb:7:in `property'
 # C:/Users/user/.vagrant.d/gems/gems/specinfra-2.59.6/lib/specinfra/helper/os.rb:7:in `os'
# C:/Users/user/.vagrant.d/gems/gems/specinfra-2.59.6/lib/specinfra/configuration.rb:38:in `os'
 # C:/Users/user/.vagrant.d/gems/gems/specinfra-2.59.6/lib/specinfra/helper/os.rb:16:in `detect_os'      # C:/Users/user/.vagrant.d/gems/gems/specinfra-2.59.6/lib/specinfra/helper/os.rb:9:in `os'
 # C:/Users/user/.vagrant.d/gems/gems/specinfra-2.59.6/lib/specinfra/configuration.rb:38:in `os'
 # C:/Users/user/.vagrant.d/gems/gems/specinfra-2.59.6/lib/specinfra/helper/os.rb:16:in `detect_os'

I tried adding below lines in spec_helper.rb file but still same issue, looks like its unable to detect os..
Is there anythign I am missing?
require 'serverspec'
require 'net/ssh'

set :backend, :ssh

# Disable sudo
set :disable_sudo, true

# Set environment variables
set :env, :LANG => 'C', :LC_MESSAGES => 'C'
# Set PATH
set :path, '/sbin:/usr/local/sbin:$PATH'

Below is my Gemfile

source 'http://rubygems.org'

puppetversion = ENV.key?('PUPPET_VERSION') ? "#{ENV['PUPPET_VERSION']}" : ['= 4.3.2']
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '1.1.1'
gem 'puppet-lint', '1.1.0'
gem 'serverspec', '2.36.0'
gem 'facter', '2.4.6'
gem 'mocha', '1.1.0'
gem 'hiera', '3.0.6'
gem 'rake', '10.4.2'
gem 'r10k', '2.3.0'
gem 'winrm', '1.8.1'

platforms :mswin do
gem "win32console"
end

ruby '2.3.0'

please update this gem on rubygems.org

Hi @jvoorhis

If try to use plugin in standard way vagrant plugin install vagrant-serverspec
it still downloading version 0.1.0

here current version is 0.6.0
so please upload this updated version to rubygems

also it is good practice to follow SemVer ruleset. And it will be good idea to change major number, to 1.0.0 for example, because of backwards incompatible changes for previously written tests that need to be rewritten, for serverspec v2 usage ruleset :)

Upgrade winrm dependency gem?

Hey,

Can we upgrade the backing winrm gem?

I notice the following deprecation warnings w/ the current 1.1.1 version of vagrant-serverspec:

 WARN  WinRM::WinRMWebService : WinRM::WinRMWebService#run_powershell_script is deprecated. Use WinRM::CommandExecutor#run_powershell_script instead

Thanks!

serverspec executed on host system and not guests

Hello,

I tried to use vagrant-serverspec to qualify ansible roles used on Vagrantfile. Sadly, for some reasons, while ansible provisioning is done correctly on guests, serverspec provisioning is on host.

$ ruby --version
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
$ vagrant --version
Vagrant 1.8.5
$ vagrant plugin list
digital_ocean (1.5.0)
vagrant-cachier (1.2.1)
vagrant-digitalocean (0.9.1)
vagrant-libvirt (0.0.35)
vagrant-omnibus (1.5.0)
vagrant-serverspec (1.1.1)
vagrant-share (1.1.5, system)
vagrant-winrm (0.7.0)
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
## require vagrant plugin: vagrant-serverspec

VAGRANTFILE_API_VERSION = "2"
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    config.vm.box = "boxcutter/ubuntu1604"

    config.vm.hostname = "v"
    config.vm.provision :serverspec do |spec|
        spec.pattern = '*_spec.rb'
    end

end
$ cat Vagrantfile.multi 
# -*- mode: ruby -*-
# vi: set ft=ruby :
## require vagrant plugin: vagrant-serverspec

VAGRANTFILE_API_VERSION = "2"
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    config.vm.box = "boxcutter/ubuntu1604"

    config.vm.define "v1" do |v1|
        v1.vm.hostname = "v1"
    end
    config.vm.define "v2" do |v2|
        v2.vm.hostname = "v2"
    end
    config.vm.define "v3" do |v3|
        v3.vm.hostname = "v3"
        v3.vm.provision :serverspec do |spec|
            spec.pattern = '*_spec.rb'
        end
    end

end
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'boxcutter/ubuntu1604'...
==> default: Matching MAC address for NAT networking...
[...]
==> default: Setting hostname...
==> default: Mounting shared folders...
    default: /vagrant => /opt/tmp/security-test/vagrant-serverspec
==> default: Running provisioner: serverspec...
F.

Failures:

  1) Command "hostname" stdout should match /GUEST_HOSTNAME/
     On host `127.0.0.1'
     Failure/Error: its(:stdout) { should match /GUEST_HOSTNAME/ }
       expected "HOST_HOSTNAME\n" to match /GUEST_HOSTNAME/
       Diff:
       @@ -1,2 +1,2 @@
       -/GUEST_HOSTNAME/
       +HOST_HOSTNAME
       /bin/sh -c hostname
       everest

     # ./test_spec.rb:7:in `block (2 levels) in <top (required)>'
     # /opt/tmp/julien.vagrant.d/gems/gems/vagrant-serverspec-1.1.1/lib/vagrant-serverspec/provisioner.rb:66:in `provision'
     # /opt/vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/builtin/provision.rb:133:in `run_provisioner'
[...]

I suspect ssh port is not passed correctly.
I had a quick look at provisioner.rb but didn't see why.

Any pointers ?

Thanks

spec files resident on the vagrant box itself?

Hi,

I'm using the vagrant package with the "--include" option to bundle my *_spec.rb files with the box. That is, I am putting the spec files on the new virtualbox's file system in a directory called "/serverspec".

How do I point to the files in my Vagrantfile definition? In other words, how do I access them from this definition (below) in my Vagrantfile?

config.vm.provision :serverspec do |spec|
    spec.pattern = '*_spec.rb'
  end

Failed, weird execution under Win2016

Hey @vvchik,

Thanks for this amazing plugin. Been using it with box linux/win boxes with a total success.
However, stumbled an issue with Win16:

  • Extremely slow and weird execution with Win16
  • Used WimRM communicator (might be cause of the issue with Win16)

Below is the trace. Tries with various Ruby but it does not seem to have any effect.
Works well on win2012 so I think it might be literally WinRM + Win2016 issue.

Let me know if more information / testing is needed. Happy to help.

  Command "Get-Module -Name xSQLServer -ListAvailable"
    stdout
      example at ./specs/win2012r2_soe_spec.rb:83 (FAILED - 14)
  Command "Get-Module -Name xDSCFirewall -ListAvailable"
    stdout
      example at ./specs/win2012r2_soe_spec.rb:87 (FAILED - 15)
  Command "Get-Module -Name xNetworking -ListAvailable"
    stdout
      example at ./specs/win2012r2_soe_spec.rb:91 (FAILED - 16)
  Command "Get-Module -Name xTimeZone -ListAvailable"
    stdout
      example at ./specs/win2012r2_soe_spec.rb:95 (FAILED - 17)
  Command "Get-Module -Name xWebAdministration -ListAvailable"
    stdout
      example at ./specs/win2012r2_soe_spec.rb:99 (FAILED - 18)
  Command "Get-Module -Name xPendingReboot -ListAvailable"
    stdout
      example at ./specs/win2012r2_soe_spec.rb:103 (FAILED - 19)
  Command "Get-Module -Name xComputerManagement -ListAvailable"
    stdout
      example at ./specs/win2012r2_soe_spec.rb:107 (FAILED - 20)

Improvement with html reports

Hi,
I would like to add an html report feature with rspec_html_formatter gem into your vagrant plugin but i always have this error :

/var/lib/jenkins/.vagrant.d/gems/gems/vagrant-serverspec-1.1.1/lib/vagrant-serverspec/provisioner.rb:71:in require': cannot load such file -- rspec_html_formatter (LoadError) from /var/lib/jenkins/.vagrant.d/gems/gems/vagrant-serverspec-1.1.1/lib/vagrant-serverspec/provisioner.rb:71:in provision'

My code :

          options[:keys]          = machine.ssh_info[:private_key_path]
          options[:password]      = machine.ssh_info[:password]
          options[:forward_agent] = machine.ssh_info[:private_key_path]

          set :host,        options[:host_name] || host
          set :ssh_options, options
        end

        # Always clean examples to not have duplicates between runs using the
        # same process
        RSpec.clear_examples

        require 'json'
        require 'rspec'
        require 'rspec_html_formatter'

        config = RSpec.configuration
        formatter = RspecHtmlFormatter.new(config.output_stream)
        # create reporter with RspecHtmlFormatter
        reporter =  RSpec::Core::Reporter.new(config)
        config.instance_variable_set(:@reporter, reporter)
        # internal hack
        # api may not be stable, make sure lock down Rspec version
        loader = config.send(:formatter_loader)
        notifications = loader.send(:notifications_for, RspecHtmlFormatter)
        reporter.register_listener(formatter, *notifications)
        print @spec_files

        status = RSpec::Core::Runner.run(@spec_files)

        print formatter.to_json

        raise Vagrant::Errors::ServerSpecFailed if status != 0
      end

      private

Can you help me to found where this gem must be installed ( into the vagrant embedded ruby gem path ) ?

Thx

Regards

Error: You must list at least one spec file

I think the documentation is missing a step. Perhaps how Vagrant finds the serverspec files.

$ tail Vagrantfile 
  config.vm.provision "ansible" do |ansible|
     ansible.verbose = 'v'
     ansible.playbook = "solr.yml"
  end

  config.vm.provision "serverspec" do |spec|
     spec.pattern = '*_spec.rb'
  end

end

$ find spec/
spec/
spec/default
spec/default/sample_spec.rb
spec/spec_helper.rb

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
There are errors in the configuration of this machine. Please fix
the following errors and try again:

serverspec provisioner:
* You must list at least one spec file

What is missing?

[feature] Support for `exclude-pattern`

Hi,

I would like to be able to exclude patterns when running serverspec in Vagrant, as per rspec exclude-pattern.

I am already doing that in my Rakefile (for when I am running outside of Vagrant), but it is currently not supported by vagrant-serverspec:

    RSpec::Core::RakeTask.new(t.to_s) do |task|
      task.pattern = "spec/#{role}/*_spec.rb"
      task.exclude_pattern = "spec/#{role}/provider_*_spec.rb"
    end

Would you be open to support this feature? If so I can try and give a go at making a PR.

Cheers,
Gildas

Support Vagrant Docker Provider

For CI it would be awesome to be able to run serverspec against a Docker container that was provisioned with my provisioner of choice. Currently the plugin trys to SSH into the container, but considering Docker may be running in a VM like it does on OSX, you actually have to ssh into the VM then into the container.

vagrant ssh and provisioners seem to handle this without an issue, but Serverspec is failing.

Conflict with vagrant-hostmanager?

I've ran into a weird issue which was so far solved/worked-around by uninstalling vagrant-hostmanager.

Setup: Ubuntu 14.04 LTS x64 (both host and vagrant vm), Vagrant 1.7.2, ruby 1.9.3p484 (from Ubuntu package), VirtualBox: 4.3.22r98236, Vagrant plugins installed:

hostmanager (1.2.2)
landrush (0.18.0)
puppet (3.7.4)
vagrant-aws (0.6.0)
vagrant-host-shell (0.0.4)
vagrant-serverspec (1.0.1)
vagrant-share (1.1.3, system)
vagrant-vbguest (0.10.0)

Error when trying to provision with serverspec:

==> analyticsapi: Running provisioner: serverspec...
/home/amos/.vagrant.d/gems/gems/rubyhacks-0.1.5/lib/rubyhacks.rb:22:in `set': undefined method `backend=' for #<VagrantPlugins::ServerSpec::Provisioner:0x000000019b8fd8> (NoMethodError)
    from /home/amos/.vagrant.d/gems/gems/vagrant-serverspec-1.0.1/lib/vagrant-serverspec/provisioner.rb:26:in `provision'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/provision.rb:133:in `run_provisioner'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:95:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:428:in `hook'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/provision.rb:121:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/provision.rb:121:in `block in call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/provision.rb:103:in `each'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/provision.rb:103:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/providers/virtualbox/action/check_accessible.rb:18:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/call.rb:53:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/call.rb:53:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:214:in `action_raw'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:191:in `block in action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:516:in `lock'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:178:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:178:in `action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/commands/provision/command.rb:30:in `block in execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:226:in `block in with_target_vms'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:220:in `each'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:220:in `with_target_vms'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/commands/provision/command.rb:29:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/cli.rb:42:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:301:in `cli'
    from /opt/vagrant/bin/../embedded/gems/gems/vagrant-1.7.2/bin/vagrant:174:in `<main>'

Searching for the error, I found Azure/vagrant-azure#46, which prompted me to try to remove the latest plugin I added since things used to work. After removing vagrant-hostmanager (with vagrant plugin uninstall hostmanager) it started to work again.

I don't know which plugin's fault this is, but it happens when I try to run the vagrant-serverspec plugin so I'm filing it here.

Provision fails when used alongside chef provisioner

Provision fails below with error. Output and config sanitized to remove client name. :)

Vagrant version 1.7.1
Windows 7 Host
Vagrant-serverspec version 1.0.1

> vagrant provision
==> default: Loading Berkshelf datafile...
==> default: Sharing cookbooks with VM
==> default: Updating Vagrant's Berkshelf...
==> default: Resolving cookbook dependencies...
==> default: Fetching 'foo-dev' from source at .
==> default: Using apt (2.6.1)
==> default: Using ark (0.9.1) from https://github.com/btomasini/ark (at master)
==> default: Using build-essential (2.1.3)
==> default: Using foo-dev (0.0.1) from source at .
==> default: Vendoring apt (2.6.1) to C:/Users/v.btomasini/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150310-12136-1v1adtw-default/apt
==> default: Vendoring ark (0.9.1) to C:/Users/v.btomasini/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150310-12136-1v1adtw-default/ark
==> default: Vendoring build-essential (2.1.3) to C:/Users/v.btomasini/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150310-12136-1v1adtw-default/build-essential
==> default: Vendoring foo-dev (0.0.1) to C:/Users/v.btomasini/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150310-12136-1v1adtw-default/foo-dev
==> default: Running provisioner: chef_solo...
==> default: Detected Chef (latest) is already installed
Generating chef JSON and uploading...
==> default: Running chef-solo...
==> default: stdin: is not a tty
==> default: [2015-03-10T13:01:14-07:00] INFO: Forking chef instance to converge...
==> default: [2015-03-10T13:01:14-07:00] INFO: *** Chef 12.1.1 ***
==> default: [2015-03-10T13:01:14-07:00] INFO: Chef-client pid: 2746
==> default: [2015-03-10T13:01:16-07:00] INFO: Setting the run_list to ["recipe[apt]", "recipe[foo-dev]"] from CLI options
==> default: [2015-03-10T13:01:16-07:00] INFO: Run List is [recipe[apt], recipe[foo-dev]]
==> default: [2015-03-10T13:01:16-07:00] INFO: Run List expands to [apt, foo-dev]
==> default: [2015-03-10T13:01:16-07:00] INFO: Starting Chef Run for dev
==> default: [2015-03-10T13:01:16-07:00] INFO: Running start handlers
==> default: [2015-03-10T13:01:16-07:00] INFO: Start handlers complete.
==> default: [2015-03-10T13:01:16-07:00] INFO: Chef Run complete in 0.327699092 seconds
==> default: [2015-03-10T13:01:16-07:00] INFO: Skipping removal of unused files from the cache
==> default: [2015-03-10T13:01:16-07:00] INFO: Running report handlers
==> default: [2015-03-10T13:01:16-07:00] INFO: Report handlers complete
==> default: Running provisioner: serverspec...
An action 'up' was attempted on the machine 'default',
but another process is already executing an action on the machine.
Vagrant locks each machine for access by only one process at a time.
Please wait until the other Vagrant process finishes modifying this
machine, then try again.

If you believe this message is in error, please check the process
listing for any "ruby" or "vagrant" processes and kill them. Then
try again.
The process cannot access the file because it is being used by another process.
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
[email protected]'s password:
RSpec is shutting down and will print the summary report... Interrupt again to force quit.

Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :
#


Vagrant.configure('2') do |config|

  config.berkshelf.enabled = true

  config.vm.box = 'codasys/xubuntu-desktop-14.04.1'
  config.vm.hostname = 'dev'

  config.vm.provider 'vmware_workstation' do |p|
    p.gui = true
    p.vmx["memsize"]  = 4096
    p.vmx["numvcpus"] = 2
    p.vmx["vhv.enable"] = 'TRUE'
  end

  config.vm.provision :chef_solo do |chef|
    chef.add_recipe 'apt'
    chef.add_recipe 'foo-dev'
  end

  config.vm.provision :serverspec do |spec|
    spec.pattern = 'spec/dev/*_spec.rb'
  end

end

Vagrant plugins:

vagrant-berkshelf (4.0.3)
vagrant-omnibus (1.4.1)
vagrant-serverspec (1.0.1)
vagrant-share (1.1.4, system)
vagrant-vmware-workstation (3.2.4)

Using two serverspec suites on two separate VMs

I have two vm's setup like this:

    config.vm.define "ubuntu" do |ubuntu|
      ubuntu.vm.box = "ubuntu/vivid64"
      ubuntu.vm.provision :serverspec do |ubuntu_spec|
        ubuntu_spec.pattern = ['**/acceptance/ubuntu/**/*_spec.rb', '**/acceptance/all/**/*_spec.rb']
      end

    end

    config.vm.define "centos" do |centos|
      centos.vm.box = "opscode-centos-6.7"

      centos.vm.provision :serverspec do |centos_spec|
        centos_spec.pattern = ['**/acceptance/centos/**/*_spec.rb', '**/acceptance/all/**/*_spec.rb']
      end
    end

centos suite is run for CentOS VM and ubuntu suite for the Ubuntu VM. The"all" suite should be run for both VMs. Everything works fine when running

vagrant provision centos --provision-with serverspec

or

vagrant provision ubuntu --provision-with serverspec

but when running

vagrant provision --provision-with serverspec

it tries to run both centos and ubuntu suites in both VMs and some of the test cases of course fails.

Support for WinRM

Are there any plans to support the Vagrant 1.6+ WinRM communicator in parallel to the SSH communicator?

I have seen that serverspec itself also has

include SpecInfra::Helper::WinRM

inside. But at the moment I'm still happy with SSH only for windows boxes.

BTW: Thanks for that great plugin.
I have learned about this in box-cutter Repos to build base boxes for different OS and run serverspec tests after building the base box with packer.

Support for AWS

Hi,

It does not work for me on AWS. I suspect its not supported. Could you add support please?

Thanks.
-Tennis

Specinfra failed os detection for suse11 only

Hi
We build many types of OS machines
We upgraded lately to vagrant 1.9.1 and 1.9.3
Till then all our tests where ok , but now we got a new failure only for the SUSE11 image
all the tests fails , seems like because it fails to identify the OS

Anyone seen this before?

C:\tests\DevOps>vagrant plugin list
vagrant-aws (0.6.0)

  • Version Constraint: 0.6.0
    vagrant-omnibus (1.5.0)
  • Version Constraint: 1.5.0
    vagrant-serverspec (1.1.1)
  • Version Constraint: 1.1.1
    vagrant-share (1.1.6, system)
    vagrant-winrm-syncedfolders (1.0.1)
  • Version Constraint: 1.0.1
    winrm-fs (0.3.2)
  • Version Constraint: 0.3.2

Failures:


  1) File "/home/vagrant/stdout/get_params.bat" content 
     On host `35.158.82.159'
     Failure/Error: its(:content) { should match /aws_suse11_trial_v8_pg/ }
     NotImplementedError:
       Specinfra failed os detection.
       /bin/sh -c uname\ -s
       Linux

     # C:/Users/tabramso/.vagrant.d/gems/2.2.5/gems/specinfra-2.67.6/lib/specinfra/helper/os.rb:30:in `detect_os'
     # C:/Users/tabramso/.vagrant.d/gems/2.2.5/gems/specinfra-2.67.6/lib/specinfra/helper/os.rb:9:in `os'
     # C:/Users/tabramso/.vagrant.d/gems/2.2.5/gems/specinfra-2.67.6/lib/specinfra/runner.rb:7:in `method_missing'
     # C:/Users/tabramso/.vagrant.d/gems/2.2.5/gems/serverspec-2.38.0/lib/serverspec/type/file.rb:113:in `content'
     # ./kitchen/spec/Tests_spec.rb:4:in `block (2 levels) in <top (required)>'
     # C:/Users/tabramso/.vagrant.d/gems/2.2.5/gems/vagrant-serverspec-1.1.1/lib/vagrant-serverspec/provisioner.rb:66:in `provision'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/provision.rb:133:in `run_provisioner'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:95:in `call'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builder.rb:116:in `call'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `block in run'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/util/busy.rb:19:in `busy'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `run'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/environment.rb:479:in `hook'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/provision.rb:121:in `call'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/provision.rb:121:in `block in call'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/provision.rb:103:in `each'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/provision.rb:103:in `call'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builder.rb:116:in `call'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `block in run'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/util/busy.rb:19:in `busy'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `run'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/call.rb:53:in `call'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builder.rb:116:in `call'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `block in run'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/util/busy.rb:19:in `busy'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `run'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/machine.rb:225:in `action_raw'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/machine.rb:200:in `block in action'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/environment.rb:567:in `lock'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/machine.rb:186:in `call'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/machine.rb:186:in `action'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/plugins/commands/provision/command.rb:30:in `block in execute'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/plugin/v2/command.rb:235:in `block in with_target_vms'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/plugin/v2/command.rb:229:in `each'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/plugin/v2/command.rb:229:in `with_target_vms'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/plugins/commands/provision/command.rb:29:in `execute'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/cli.rb:42:in `execute'
     # C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/environment.rb:308:in `cli'

Finished in 6.93 seconds (files took 0.10059 seconds to load)
1 example, 1 failure

How to pass parameters into server spec script?

Hey @vvchik, thanks for your amazing work. Been using this one for a while, total success.

Wonder if it's possible to pass parameters, args to server spe script? Someting like that:

 vm_config.vm.provision :serverspec do |spec| 
          spec.pattern = [specs_file_path] 
          spec.args: args
        end

That way we would be able to parametrize specs. For instance, specifying which yum packafes to be installed in provisioning scripts and then passing the same varibale to the server spec script.

Coudn't find a way to get this done by looking into the source code of the pluging. May be there is a fast way to get this done?

Cannot Install With Vagrant 1.9.2

Trying to install vagrant-serverspec with Vagrant 1.9.2 fails with following:

~ ➜ vagrant plugin list
vagrant-share (1.1.7, system)
~ ➜ vagrant plugin install vagrant-serverspec
Installing the 'vagrant-serverspec' plugin. This can take a few minutes...
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

conflicting dependencies nokogiri (~> 1.5.0) and nokogiri (= 1.6.7.1)
  Activated nokogiri-1.6.7.1
  which does not match conflicting dependency (~> 1.5.0)

  Conflicting dependency chains:
    vagrant-share (> 0), 1.1.7 activated, depends on
    vagrant (>= 1.9.2), 1.9.2 activated, depends on
    nokogiri (= 1.6.7.1), 1.6.7.1 activated

  versus:
    vagrant-serverspec (> 0), 1.1.1 activated, depends on
    winrm (>= 1.1.0, ~> 1.1), 1.1.0 activated, depends on
    nokogiri (~> 1.5.0)

System:
MacOS X 10.12.3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.