Sha256: 6c536e87008134df77de1e4bf4ed6d46ccac60e23ff71bf7c66a2febd3f414b4

Contents?: true

Size: 1.03 KB

Versions: 90

Compression:

Stored size: 1.03 KB

Contents

require 'itamae-mitsurin'

module ItamaeMitsurin
  module Resource
    class Group < Base
      define_attribute :action, default: :create
      define_attribute :groupname, type: String, default_name: true
      define_attribute :gid, type: Integer

      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

      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

      private
      def exist?
        run_specinfra(:check_group_exists, attributes.groupname)
      end
    end
  end
end

Version data entries

90 entries across 47 versions & 1 rubygems

Version Path
itamae-mitsurin-1.0.3 lib/itamae-mitsurin/resource/group.rb
itamae-mitsurin-1.0.2 lib/itamae-mitsurin/resource/group.rb
itamae-mitsurin-1.0.1 lib/itamae-mitsurin/resource/group.rb
itamae-mitsurin-1.0.0 lib/itamae-mitsurin/resource/group.rb
itamae-mitsurin-0.50 lib/itamae-mitsurin/resource/group.rb
itamae-mitsurin-0.50 test/test_itamae-mitsurin/resource/test_group.rb
itamae-mitsurin-0.49 lib/itamae-mitsurin/resource/group.rb
itamae-mitsurin-0.49 test/test_itamae-mitsurin/resource/test_group.rb
itamae-mitsurin-0.48 lib/itamae-mitsurin/resource/group.rb
itamae-mitsurin-0.48 test/test_itamae-mitsurin/resource/test_group.rb
itamae-mitsurin-0.47 lib/itamae-mitsurin/resource/group.rb
itamae-mitsurin-0.47 test/test_itamae-mitsurin/resource/test_group.rb
itamae-mitsurin-0.46 lib/itamae-mitsurin/resource/group.rb
itamae-mitsurin-0.46 test/test_itamae-mitsurin/resource/test_group.rb
itamae-mitsurin-0.45 lib/itamae-mitsurin/resource/group.rb
itamae-mitsurin-0.45 test/test_itamae-mitsurin/resource/test_group.rb
itamae-mitsurin-0.44 lib/itamae-mitsurin/resource/group.rb
itamae-mitsurin-0.44 test/test_itamae-mitsurin/resource/test_group.rb
itamae-mitsurin-0.43 lib/itamae-mitsurin/resource/group.rb
itamae-mitsurin-0.43 test/test_itamae-mitsurin/resource/test_group.rb