Sha256: 8202b59b29755963a7f68dd45a6c0657343187bd5b4b40b0f4f0ff28fc0fb81d

Contents?: true

Size: 969 Bytes

Versions: 1

Compression:

Stored size: 969 Bytes

Contents

require 'itamae'

module Itamae
  module Resource
    class User < Base
      define_attribute :action, default: :create
      define_attribute :username, type: String, default_name: true
      define_attribute :gid, type: String
      define_attribute :home, type: String
      define_attribute :password, type: String
      define_attribute :system_user, type: [TrueClass, FalseClass]
      define_attribute :uid, type: [String, Integer]

      def create_action
        if run_specinfra(:check_user_exists, username)
          Logger.warn "User already exists. Currently, user resources do not support to modify attributes."
        else
          args = ["useradd"]
          args << "-g" << gid if gid
          args << "-d" << home if home
          args << "-p" << password if password
          args << "-r" if system_user
          args << "-u" << uid.to_s if uid
          args << username
          run_command(args)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
itamae-1.0.0.beta24 lib/itamae/resource/user.rb