serverspec | RSpec tests for your servers | Continuous Deployment library
kandi X-RAY | serverspec Summary
kandi X-RAY | serverspec Summary
RSpec tests for your servers configured by Puppet, Chef or anything else. You can see the details of serverspec on serverspec.org.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Returns an error message for this example .
- Checks if the file contains all lines for the given file .
- Determines whether a service level is enabled .
- Parse a status map
- Specify the given protocol protocol .
- Set the value
serverspec Key Features
serverspec Examples and Code Snippets
Community Discussions
Trending Discussions on serverspec
QUESTION
I have a solution for deleting files in a given directory and keeping first-generation children directories of the parent while deleting the rest.
For example, given this structure:
...ANSWER
Answered 2019-Jul-10 at 23:41No, this is linear -- O(N) -- on the quantity of files + directories
in the structure. You deal with each of these elements once each.
The nested and sequential loops are merely the mechanics you use to reach each one exactly once.
QUESTION
I hear I should be using expectations rather than "should" statements in Serverspec
I have been Googling around for expectations that can be used for file matching but all of the tutorials I see for Serverspec use should rather than expect. Is this because Serverspec hasn't been updated to use expectations?
...ANSWER
Answered 2019-May-22 at 11:54Your first question:
... all of the tutorials I see for Serverspec use should rather than expect. Is this because Serverspec hasn't been updated to use expectations?
No, it is mostly because the author of the Serverspec project has a preference for the "should" syntax, and that's why the Serverspec documentation continues to use it. He has explained here that:
I'm using
should
syntax instead ofexpect
syntax because I thinkshould
syntax is more readable thanexpect
syntax and I like it.Using
expect
syntax is recommended way because addingshould
to every object causes failures when used with BasicObject-subclassed proxy objects.But the one-liner syntax used with the examples in this page doesn't add should to any objects, so this syntax doesn't cause the above problems. That's why I'm using the one-liner should syntax.
Be aware that should
and expect
come from the rspec-expectations project, and the Serverspec author is correct "should" rather than "expect" is fine the way he is using it.
There is more info on the original motivation for the expect syntax from the Rspec author Myron Marston here.
Your second question:
... how would I write the test using expectations instead of should?
If you still want to use the expect
syntax, just replace should
everywhere with is_expected.to
everywhere. This works fine:
QUESTION
I have 2 spec files that use different docker images and therefore are suppose to start separate and different docker containers to run the examples.
In the snippets below I'm using the serverspec
gem to test my containers
ANSWER
Answered 2019-Apr-09 at 18:58I found a way to solve the problem, albeit a pretty hacky one. The key to this problem lay in how the container is finally released. When there are no longer any references pointing to the Docker
instance it will be garbage collected and the container killed and deleted. However the object instance is held in a class level variable as a singleton in the base class. It would seem to me the only way to "reset" specinfra is to call the clear
method inherited on the Docker
class.
In the end the following solved the problem and the correct class is being used to run each spec.
QUESTION
I'm using redhat centos 7 and am attempting to install R:
...ANSWER
Answered 2018-Nov-06 at 22:44So it appears you have conflicting packages installed from possibly 'odd' locations.
1:java-1.8.0-openjdk-devel-1.8.0.181-3.b13.el7_5.i686 is obsoleted by 2000:gd-jdk8-1.8.0_92-fcs.x86_64
is telling us that gd-jdk8
is providing the same thing as java-1.8.0-openjdk-devel
but R
doesn't like that name and wants a proper java
and java-devel
package.
First thing you need to do is disable all of these odd repos you have enabled and only use the epel
base
and updates
repos.
If you navigate to; /etc/yum.repos.d/
you should find a folder full of files. open them up and change enabled=1
to enabled=0
which will disable them.
Now you should be able to yum erase gd-jdk8
and remove that along with any deps. Then you should be able to do yum install java-devel
which should give you the correct version.
Once you have done that you will need to downgrade you R-core
and libRmath
packages as it appears from our chat you have some how managed to install newer versions of those that R
also wants.
Do; yum downgrade R-core libRmath
and say 'yes' to the deps. That should bring you down to the correct version you need.
Lastly do yum install R
and with a bit of luck it should install for you!
It looks like a lot of packages my be provided by an internal repo or something, as you had a lot of things prefixed 'gd' which are not actually gd
as people might expect! I'd have a word with your operations/IT team to see what's going on.
Lastly remember you disabled all those other repos - well you may wish to re-enable them now BUT... if you ever do a yum update
make very sure you know what it's going to do as it might try and replace things with those 'gd' prefixed packages.
Yum did actually tell you what was wrong with the is obsoleted
line. But granted digging into the deps requires a little more knowledge especially when your not sure what your looking at, and it's not a 'stock' install of CentOS!
QUESTION
I'm currently having an issue with testing Docker image builds by means of Serverspec. In a nutshell, what I want to do is ensuring that during the image build the Ruby gems build cache gets cleared explicitly, e.g. by issuing rm -rf /usr/lib/ruby/gems/*/cache/*.gem
in the Dockerfile.
The Dockerfile skeleton I'm working with looks like this:
...ANSWER
Answered 2018-Feb-13 at 12:25I finally figured out what went wrong, and actually it's pretty simple:
Let's assume that we have a single Serverspec test case like this one:
QUESTION
I had been using ServerSpec for my integration testing with Chef.
Since ServerSpec is "deprecated" and InSpec is supported by Chef, I've change to use only InSpec, which is also supported in Puppet.
However I'm not 100% sure is InSpec is the best tool for integration testing with Puppet. Is there a better or more recommended solution?
How can I use inspec with Puppet?
...ANSWER
Answered 2017-Dec-16 at 16:46Inspec is better than serverspec to do integration testing since it is more readable and helps to represent compliance as code. I use it with chef but Inspec is supported in puppet as well. You can refer the github link for examples
QUESTION
I'm trying to learn Ansible with Vagrant (Ubuntu/trusty64) and I'm trying to use test-kitchen to assert my setup.
The problem I am having is the Vagrant machine has an old version of Ruby (1.9.1) and therefore one of the dependencies (busser) fails to run. The error I am receiving is:
...ANSWER
Answered 2018-Jan-04 at 21:30Thanks to Hubert above, I changed
this
QUESTION
I have a cookbook setting up a Splunk Forwarder. I've created a number of integration - serverspec tests for the configuration files. One in particular, /opt/splunkforwarder/etc/apps/search/local/inputs.conf
keeps failing all the tests the other files are passing. My code looks like this:
ANSWER
Answered 2017-Nov-15 at 23:40I suspect that typo in the test is your enemy.
describe file('/opt/splunkforwarder/etc/apps/search/local/inputs.conf
}') do
Try to remove that bracket and run test again.
QUESTION
I am struggling to run serverspec test on GCP packer instance from local machine. I have created a packer json config file as follows to create an image on GCP:
...ANSWER
Answered 2017-Nov-15 at 07:28It seems like you are missing the password for centos
user.
Add this to spec_helper.rb
:
QUESTION
I'm looking to create a test in serverspec for an nginx rewrite call like the one below (it re-directs requests for the ^/folder/file.json URL to the @redirect_url variable):
...ANSWER
Answered 2017-Jul-21 at 15:25A redirect severspec using curl command is like this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install serverspec
On a UNIX-like operating system, using your system’s package manager is easiest. However, the packaged Ruby version may not be the newest one. There is also an installer for Windows. Managers help you to switch between multiple Ruby versions on your system. Installers can be used to install a specific or multiple Ruby versions. Please refer ruby-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page