【问题标题】:serverspec keeps failing on one and only one fileserverspec 在一个且只有一个文件上一直失败
【发布时间】:2017-11-16 07:40:58
【问题描述】:

我有一本设置 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个权限

与其他几个文件完全一样。此外,我可以从 Chef 融合的标准中看到,创建的文件具有正确的权限和所有权以及内容。

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

我不知道为什么这没有通过。

【问题讨论】:

  • 该测试的详细失败输出是什么?
  • 您是否启用并执行了 SELinux?如果是这样,在 audit.log 中是否有任何有关 inputs.conf 的条目?

标签: chef-infra serverspec


【解决方案1】:

我怀疑测试中的错字是你的敌人。

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

尝试删除该支架并再次运行测试。

【讨论】:

    猜你喜欢
    • 2014-05-03
    • 2016-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-01
    • 1970-01-01
    相关资源
    最近更新 更多