Sha256: cd3e04ca2e11aa83ed1f40ba4ca94d47ccd575c349a7467a0c6c20a3c10682d7
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
require 'wright/dry_run' require 'wright/provider' require 'wright/provider/user' module Wright class Provider class User # GNU passwd user provider. Used as a provider for # {Resource::User} on GNU systems. class GnuPasswd < Wright::Provider::User private def add_user user = @resource.name cmd = 'useradd' args = [*user_options, user] exec_or_fail(cmd, args, "cannot create user '#{user}'") end def update_user user = @resource.name cmd = 'usermod' args = [*user_options, user] exec_or_fail(cmd, args, "cannot create user '#{user}'") end def user_options options = { '-u' => @resource.uid, '-g' => @resource.primary_group, '-c' => comment, '-G' => groups, '-s' => @resource.shell, '-d' => @resource.home }.reject { |_k, v| v.nil? }.flatten options << '-r' if @resource.system options.map(&:to_s) end def comment @resource.full_name.nil? ? nil : "#{@resource.full_name},,," end def groups @resource.groups.nil? ? nil : @resource.groups.join(',') end def delete_user user = @resource.name exec_or_fail('userdel', [user], "cannot remove user '#{user}'") end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wright-0.2.0 | lib/wright/provider/user/gnu_passwd.rb |