Serverspec ユーザとグループの書き方のサンプル

環境
Serverspec
Ansible

操作例
1.グループ「cftuser」が存在するか確認する

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
describe group('cftuser') do
it { should exist }
end
describe group('cftuser') do it { should exist } end
describe group('cftuser') do
  it { should exist }
end

2.ユーザ「cftuser」が指定のグループに所属しているか確認する

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
describe user('cftuser') do
it { should belong_to_group 'cftuser' }
end
describe user('cftuser') do it { should belong_to_group 'cftuser' } end
describe user('cftuser') do
  it { should belong_to_group 'cftuser' }
end

3.ユーザが指定のUIDを持っているか確認する

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
describe user('cftuser') do
it { should have_uid 809 }
end
describe user('cftuser') do it { should have_uid 809 } end
describe user('cftuser') do
  it { should have_uid 809 }
end

 

Ansible

Posted by arkgame