Class: Itamae::Resource::Group

Inherits:
Base
  • Object
show all
Defined in:
lib/itamae/resource/group.rb

Instance Attribute Summary

Attributes inherited from Base

#attributes, #current_attributes, #notifications, #recipe, #resource_name, #subscriptions, #updated

Instance Method Summary collapse

Methods inherited from Base

#action_nothing, define_attribute, #do_not_run_because_of_not_if?, #do_not_run_because_of_only_if?, inherited, #initialize, #resource_type, #run

Constructor Details

This class inherits a constructor from Itamae::Resource::Base

Instance Method Details

#action_create(options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/itamae/resource/group.rb', line 16

def action_create(options)
  if run_specinfra(:check_group_exists, attributes.groupname)
    if attributes.gid && attributes.gid != current.gid
      run_specinfra(:update_group_gid, attributes.groupname, attributes.gid)
      updated!
    end
  else
    options = {
      gid: attributes.gid,
    }

    run_specinfra(:add_group, attributes.groupname, options)

    updated!
  end
end

#set_current_attributesObject



8
9
10
11
12
13
14
# File 'lib/itamae/resource/group.rb', line 8

def set_current_attributes
  current.exist = exist?

  if current.exist
    current.gid = run_specinfra(:get_group_gid, attributes.groupname).stdout.strip.to_i
  end
end