Show Menu
Cheatography

serverspec Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Assertions

should
means "­assert true"
should_not
means "­assert false"

file

describe file('/path/to/file') do

  #INode type
  it { should be_file }       # or be_directory, or be_symlink
  it { should exist }

  #Permissions
  it { should be_owned_by 'username' }
  it { should be_grouped_into 'groupname' }

  it { should be_mode 440 }

  it { should be_readable }               # or be_writable or be_executable
  it { should be_readable.by('owner') }   # or 'group' or 'others'
  it { should be_readable.by_user('username') }

  #Links
  if { should be_linked_to '/path/to/target' }

  #Contents
  its(:md5sum)    { should eq '...' }    # or, and rspec matcher
  its(:sha256sum) { should eq '...' }
  its(:size)      { should < 1024 }
  its(:content)   { should match /some pattern/ }

end
Files, direct­ories, and devices.