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, inherited, #initialize, #resource_type, #run

Constructor Details

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

Instance Method Details

#action_create(options) ⇒ Object



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

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



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

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