Class: Resource::Group
Instance Method Summary collapse
-
#initialize(groupname, &block) ⇒ Group
constructor
A new instance of Group.
- #run ⇒ Object
Methods inherited from Base
inherited, #not_if, #set_base_defaults, #should_skip?, #unix_mode
Methods included from ClassAttr
Methods included from BlockAttr
Constructor Details
#initialize(groupname, &block) ⇒ Group
Returns a new instance of Group.
7 8 9 10 11 |
# File 'lib/resource/group.rb', line 7 def initialize groupname, &block set_base_defaults @groupname = groupname self.instance_eval(&block) end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/resource/group.rb', line 13 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 |