Using serverspec with ansible

Hello,

I would like to use serverspec with ansible so I can test if the services a running and listing, but I didn’t find any informationen about how I can use it, especially how I call the test in the playbook.
I would very thankful if someone can give me please some information about the usage.
best regards
Dan

For what it’s worth I tend to like the Testinfra project a bit more:

http://testinfra.readthedocs.io/en/latest/

I try and follow the practice of “cattle not pets” as much as possible and with all of the infrastructure I manage in AWS don’t have a use case for testing a set of servers that are long-lived. I do, though, make heavy use of Packer and Ansible for creating an image from which I’ll deploy my VMs. I’ve used Serverspec before as a final provisioning step, started by a shell script and executing something like this to perform my tests
cd tests/directory bundle exec rake spec

Doing it that way ensures that my AMI is only created by Packer if all of my tests pass.

That said, I think it’s important to not duplicate your Ansible code just to have tests written in Serverspec or Testinfra. Ansible is purposely built to configure the desired state of your server/image. If all you want is to make sure a service is running and/or listening then re-run your Ansible playbook. If you’re running these tests out-of-band from, say, Nagios or on a security team to validate the configuration of your image, checking whether a service is running with Serverspec or Testinfra makes sense.