serverspec在一个且只有一个文件

时间:2017-09-25 03:28:51

标签: chef serverspec

我有一本食谱,设置了Splunk Forwarder。我已经为配置文件创建了许多集成 - serverspec测试。特别是,/opt/splunkforwarder/etc/apps/search/local/inputs.conf使其他文件传递的所有测试都失败。我的代码如下所示:

require 'spec_helper'

describe file('/opt/splunkforwarder/etc/apps/search/local/') do
  it { should be_directory }
  it { should be_owned_by 'nobody' }
  it { should be_mode 755 }
end

describe file('/opt/splunkforwarder/etc/system/local/') do
  it { should be_directory }
  it { should be_owned_by 'nobody' }
  it { should be_mode 755 }
end

describe file('/opt/splunkforwarder/etc/system/local/outputs.conf') do
  it { should exist }
  it { should be_owned_by 'nobody' }
  it { should be_mode 600 }
end

describe file('/opt/splunkforwarder/etc/system/local/inputs.conf') do
  it { should exist }
  it { should be_owned_by 'nobody' }
  it { should be_mode 600 }
end

describe file('/opt/splunkforwarder/etc/apps/search/local/inputs.conf}') do
  it { should exist }
  it { should be_owned_by 'nobody' }
  it { should be_mode 600 }
end

describe file('/opt/splunkforwarder/etc/apps/SplunkUniversalForwarder/default/limits.conf') do
  it { should exist }
  it { should be_owned_by 'nobody' }
  it { should be_mode 444 }
end

describe file('/opt/splunkforwarder/etc/system/local/web.conf') do
  it { should exist }
  it { should be_owned_by 'nobody' }
  it { should be_mode 600 }
end

此规范文件中的每个文件和目录都会通过/opt/splunkforwarder/etc/apps/search/local/inputs.conf除外。我正在使用Docker实例和Test Kitchen,所以当我登录时,我发现:

  1. 文件存在
  2. 该文件归“nobody”所有
  3. 该文件具有600个权限
  4. 与其他几个文件完全一样。此外,我可以从我的Chef融合标准中看到使用正确的权限和所有权以及内容创建的文件。

    我已经检查了其中一个父目录是否未正确拥有,或者是否具有与通过的其他文件不同的权限,但事实并非如此。

    我不知道为什么这不会过去。

1 个答案:

答案 0 :(得分:2)

我怀疑测试中的拼写错误是你的敌人。

describe file('/opt/splunkforwarder/etc/apps/search/local/inputs.conf} ') do

尝试删除该括号并再次运行测试。