Sha256: d0d15f141c0f564044bbad4daffdc658f24d640c13c2c92b44a3da8b28933c9d

Contents?: true

Size: 783 Bytes

Versions: 3

Compression:

Stored size: 783 Bytes

Contents

module Sprinkle
  module Verifiers
    # = Users and groups Verifier
    #
    # Tests for the existance of users and groups.
    #
    # == Example Usage
    #
    #   verify do
    #     has_user 'ntp'
    #     has_user 'noone', :in_group => 'nobody'
    #     has_group 'nobody'
    #   end
    #
    module UsersGroups
      Sprinkle::Verify.register(Sprinkle::Verifiers::UsersGroups)
      
      # Tests that the user exists
      def has_user(user, opts = {})
        if opts[:in_group]
          @commands << "id -G #{user} | xargs -n1 echo | grep #{opts[:in_group]}"
        else
          @commands << "id #{user}"
        end
      end
      
      # Tests that the group exists
      def has_group(group)
        @commands << "id -g #{group}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sprinkle-0.4.2 lib/sprinkle/verifiers/users_groups.rb
sprinkle-0.4.1 lib/sprinkle/verifiers/users_groups.rb
sprinkle-0.4.0 lib/sprinkle/verifiers/users_groups.rb