So far Serverspec is working out great. I'm testing my servers, everything looks good.

Let's say I want to test my LDAP cluster via running a few LDAP commands from my local workstation, say ldapsearch. The reason I would do this on my workstation rather than any of the servers is to ensure everything works remotely, including load balancing.

What's the convention? How is this accomplished? What changes would I have to make to my Rakefile? I have generated a Rakefile via serverspec-init. Any examples of this somewhere?


As far as I understand, serverspec is a tool to check servers' configuration state for correctness and make sure that it is in the desired state. This is achieved by logging into the server and executing commands that check given configuration items/values and returns output. So, I have my doubts if serverspec is the right tool for what you want to do.

The site's about section states:

Serverspec tests your servers' actual state by executing command locally, via SSH, via WinRM, via Docker API and so on.

The only option close to what you are looking for seems to me, is to use the command resourc type to run and check the ouptput of some commands you wish to. http://serverspec.org/resource_types.html#command


Command resource type. its(:stdout), its(:stderr), its(:exit_status)

You can get the stdout, stderr and exit status of the command result, and can use any matchers RSpec supports.

describe command('ls -al /') do
  its(:stdout) { should match /bin/ }

describe command('ls /foo') do
  its(:stderr) { should match /No such file or directory/ }

describe command('ls /foo') do
  its(:exit_status) { should eq 0 }

You could set a command that runs on loopback( rather than the external server. It'll still ssh locally but it'll do what you need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.