Sha256: 1d9b662822b491c4157138f982768ed6b8d5bce7c3d1639579e1a49cb09e1cf4

Contents?: true

Size: 640 Bytes

Versions: 4

Compression:

Stored size: 640 Bytes

Contents

module Resource

  class Group < Base

    block_attr :groupname, :gid

    def initialize groupname, &block
      set_base_defaults
      @groupname = groupname
      self.instance_eval(&block)
    end

    def run
      Execution.block 'Creating new group', @groupname, 'root' do |b|
        b.always_run @always_run
        groups = `cat /etc/group | cut -d: -f1`
        groups = groups.scan(/[a-zA-Z\-_]+/)
        if groups.include? @groupname
          Output.warn 'Aborted, I think this group already exists', groups.inspect
        else
          b.run "groupadd -g #{@gid} #{@groupname}"
        end
      end
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
atesta-0.0.4 lib/resource/group.rb
atesta-0.0.3 lib/resource/group.rb
atesta-0.0.2 lib/resource/group.rb
atesta-0.0.1 lib/resource/group.rb