Last active
June 21, 2016 12:08
-
-
Save scarolan/49e30bcbc793be056291bc1f381e4581 to your computer and use it in GitHub Desktop.
Some sample inspec tests to get you started!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
execute "sed -i '/requiretty/d' /etc/sudoers" do | |
action :run | |
end | |
package 'httpd' do | |
action :install | |
end | |
file '/var/www/html/index.html' do | |
action :create | |
content 'Hello World!' | |
end | |
service 'httpd' do | |
action [ :enable, :start ] | |
# truthiness false | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For all your apache Hello World testing needs... | |
# use basic tests | |
describe package('httpd') do | |
it { should be_installed } | |
end | |
# extend tests with metadata | |
control '01' do | |
impact 0.7 | |
title 'Verify httpd service' | |
desc 'Ensures httpd service is up and running' | |
describe service('httpd') do | |
it { should be_enabled } | |
it { should be_installed } | |
it { should be_running } | |
end | |
end | |
# implement os dependent tests | |
web_user = 'apache' | |
web_user = 'apache' if os[:family] == 'centos' | |
describe user(web_user) do | |
it { should exist } | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Windows default.rb recipe | |
powershell_script 'Install IIS' do | |
code 'Add-WindowsFeature Web-Server' | |
guard_interpreter :powershell_script | |
not_if "(Get-WindowsFeature -Name Web-Server).Installed" | |
end | |
service 'w3svc' do | |
action [:enable, :start] | |
end | |
file 'c:\inetpub\wwwroot\Default.htm' do | |
content '<html> | |
<body> | |
<h1>hello world</h1> | |
</body> | |
</html>' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment