The following is an example of a test for Serverspec that checks the availability of Git in a specific version and the Let's Encrypt configuration file:
# We want to have git 1:2.1.4 installed if we're running Debian
describe package('git'), :if => os[:family] == 'debian' do it { should be_installed.with_version('1:2.1.4') } end
# We want the file /etc/letsencrypt/config/example.com.conf to: describe file('/etc/letsencrypt/config/example.com.conf') do it { should be_file } # be a regular file it { should be_owned_by 'letsencrypt' } # owned by the letsencrypt user it { should be_mode 600 } # access mode 0600 it { should contain('example.com') } # contain the text example.com
# in the content
end
The Ruby DSL syntax should be readable even by those who do not use Ruby daily. You may need to get used to writing the code.