Skip to content

Instantly share code, notes, and snippets.

@gsarjeant
Created October 17, 2014 21:42
Show Gist options
  • Save gsarjeant/e408d0cd055b6124a0b0 to your computer and use it in GitHub Desktop.
Save gsarjeant/e408d0cd055b6124a0b0 to your computer and use it in GitHub Desktop.
Basic serverspec test
# spec/localhost/httpd_spec.rb
require 'spec_helper'
describe package('httpd') do
it { should be_installed }
end
describe service('httpd') do
it { should be_enabled }
it { should be_running }
end
describe port(80) do
it { should be_listening }
end
describe file('/etc/httpd/conf/httpd.conf') do
it { should be_file }
its(:content) { should match /ServerName localhost/ }
end
@gsarjeant
Copy link
Author

This serverspec test validates the state of apache on a RHEL-based target system. It verifies the following:

  • The httpd package is installed
  • The httpd service is enabled
  • The httpd service is running
  • Port 80 is listening (accepting requests)
  • The httpd.conf file exists
  • The httpd.conf file has a line that contains the text "ServerName localhost"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment