Inspec Chef でのログのカスタマイズ
概要
Ruby/chef/inspec の初心者はここにいます。
Linuxでユーザーの存在をテストするためにinspec Chefを使用しています。
次のようなものを実行するとき
describe user(username) do
it "should exist" do
# The existence check itself is included in the custom description.
expect(subject.exists?).to eq(true)
end
end
次のメッセージが出力されます。
User user1 is expected to exist
メッセージを抑制したりカスタマイズしたりする方法はありますか?
ありがとう
解決策
Inspec は、出力をカスタマイズするためのレポーターをサポートしています。 出力から何を変更したいのかは完全には明らかではありませんが、もっと簡潔なものが必要な場合は、進行状況バーまたは進行状況バーのレポーターが適しているようです。
inspec exec example_profile --reporter progress
古典的なドットの進行が得られるようです。
行の出力をカスタマイズしたい場合は、 User クラスは inspec で定義されています。 https://translate.google.com/translate?hl=ja&sl=en&tl=ja&u=https://github.com/inspec/inspec/blob/main/lib/inspec/resources/users.rb#L314
単純な to_s メソッドがあるだけです。
セットアップでそのメソッドをオーバーライドできます。例えば、
module Inspec::Resources
class User
def to_s
"User (redacted)"
end
end
end