Sha256: 5104e54c92c3e695e3ca4d0c21e80852bb435915a88d7084905e0ca79e8d0317

Contents?: true

Size: 1.43 KB

Versions: 92

Compression:

Stored size: 1.43 KB

Contents

require_relative '../../../puppet/util/posix'

module Puppet
  # Manage file group ownership.
  Puppet::Type.type(:file).newproperty(:group) do
    desc <<-EOT
      Which group should own the file.  Argument can be either a group
      name or a group ID.

      On Windows, a user (such as "Administrator") can be set as a file's group
      and a group (such as "Administrators") can be set as a file's owner;
      however, a file's owner and group shouldn't be the same. (If the owner
      is also the group, files with modes like `"0640"` will cause log churn, as
      they will always appear out of sync.)
    EOT

    validate do |group|
      raise(Puppet::Error, "Invalid group name '#{group.inspect}'") unless group and group != ""
    end

    def insync?(current)
      # We don't want to validate/munge groups until we actually start to
      # evaluate this property, because they might be added during the catalog
      # apply.
      @should.map! do |val|
        gid = provider.name2gid(val)
        if gid
          gid
        elsif provider.resource.noop?
          return false
        else
          raise "Could not find group #{val}"
        end
      end

      @should.include?(current)
    end

    # We want to print names, not numbers
    def is_to_s(currentvalue)
      super(provider.gid2name(currentvalue) || currentvalue)
    end

    def should_to_s(newvalue)
      super(provider.gid2name(newvalue) || newvalue)
    end
  end
end

Version data entries

92 entries across 92 versions & 1 rubygems

Version Path
puppet-7.34.0 lib/puppet/type/file/group.rb
puppet-7.34.0-x86-mingw32 lib/puppet/type/file/group.rb
puppet-7.34.0-x64-mingw32 lib/puppet/type/file/group.rb
puppet-7.34.0-universal-darwin lib/puppet/type/file/group.rb
puppet-7.33.0 lib/puppet/type/file/group.rb
puppet-7.33.0-x86-mingw32 lib/puppet/type/file/group.rb
puppet-7.33.0-x64-mingw32 lib/puppet/type/file/group.rb
puppet-7.33.0-universal-darwin lib/puppet/type/file/group.rb
puppet-7.32.1 lib/puppet/type/file/group.rb
puppet-7.32.1-x86-mingw32 lib/puppet/type/file/group.rb
puppet-7.32.1-x64-mingw32 lib/puppet/type/file/group.rb
puppet-7.32.1-universal-darwin lib/puppet/type/file/group.rb
puppet-7.31.0 lib/puppet/type/file/group.rb
puppet-7.31.0-x86-mingw32 lib/puppet/type/file/group.rb
puppet-7.31.0-x64-mingw32 lib/puppet/type/file/group.rb
puppet-7.31.0-universal-darwin lib/puppet/type/file/group.rb
puppet-7.30.0 lib/puppet/type/file/group.rb
puppet-7.30.0-x86-mingw32 lib/puppet/type/file/group.rb
puppet-7.30.0-x64-mingw32 lib/puppet/type/file/group.rb
puppet-7.30.0-universal-darwin lib/puppet/type/file/group.rb