notes/sandbox/serverspec/getting-started/spec/localhost/sample_spec.rb
Aravinth Manivannan a24e814a1a
feat: try serverspec
DESCRIPTION
    Used local runner to perform the following tasks on my Arch Linux
    dev machine

    1. Check if apache is installed on arch
    2. Check if httpd service is enabled and running
    3. Check if port 80 is listening

COMMENTS
    Limited capabilities but seems to have support for basic testing
    on mulitple environments: local, SSH and Docker API  using multiple
    configuration management tools like Puppet and Ansible.

REFERENCES

[0]: https://serverspec.org/tutorial.html
[1]: https://serverspec.org/resource_types.html
2022-10-06 16:11:49 +05:30

38 lines
833 B
Ruby

require 'spec_helper'
describe package('apache'), if: os[:family] == 'arch' do
it { should be_installed }
end
describe service('httpd'), if: os[:family] == 'arch' do
it { should be_enabled }
it { should be_running }
end
describe package('httpd'), if: os[:family] == 'redhat' do
it { should be_installed }
end
describe package('apache2'), if: os[:family] == 'ubuntu' do
it { should be_installed }
end
describe service('httpd'), if: os[:family] == 'redhat' do
it { should be_enabled }
it { should be_running }
end
describe service('apache2'), if: os[:family] == 'ubuntu' do
it { should be_enabled }
it { should be_running }
end
describe service('org.apache.httpd'), if: os[:family] == 'darwin' do
it { should be_enabled }
it { should be_running }
end
describe port(80) do
it { should be_listening }
end