Sha256: e51347522fededb6359852ad1861364d75ed177ea04105acc0274d72eee21508
Contents?: true
Size: 1.19 KB
Versions: 8
Compression:
Stored size: 1.19 KB
Contents
require "inspec/resources/command" module Inspec::Resources class ZfsPool < Inspec.resource(1) name "zfs_pool" supports platform: "unix" desc " Use the zfs_pool InSpec audit resource to test if the named ZFS Pool is present and/or has certain properties. " example <<~EXAMPLE describe zfs_pool('tank') do its('failmode') { should eq('continue') } end EXAMPLE def initialize(zfs_pool) return skip_resource "The `zfs_pool` resource is not supported on your OS yet." if !inspec.os.bsd? @zfs_pool = zfs_pool @params = gather end # method called by 'it { should exist }' def exists? inspec.command("/sbin/zpool get -Hp all #{@zfs_pool}").exit_status == 0 end def to_s "ZFS Pool #{@zfs_pool}" end def gather cmd = inspec.command("/sbin/zpool get -Hp all #{@zfs_pool}") return nil if cmd.exit_status.to_i != 0 # parse data cmd.stdout.chomp.split("\n").each_with_object(Hash.new(0)) do |line, h| t = line.split("\t") h[t[1].to_s] = t[2].to_s end end # expose all parameters def method_missing(name) @params[name.to_s] end end end
Version data entries
8 entries across 8 versions & 2 rubygems