Sha256: 33f3ce8884a63ac1b148097ea160135d48cdbb2b035cd95c8cbb4bebdd5f4571
Contents?: true
Size: 756 Bytes
Versions: 8
Compression:
Stored size: 756 Bytes
Contents
module Unix::User include Beaker::CommandFactory def user_list() execute("getent passwd") do |result| users = [] result.stdout.each_line do |line| users << (line.match( /^([^:]+)/) or next)[1] end yield result if block_given? users end end def user_get(name) execute("getent passwd #{name}") do |result| fail_test "failed to get user #{name}" unless /^#{name}:/.match?(result.stdout) yield result if block_given? result end end def user_present(name, &block) execute("if ! getent passwd #{name}; then useradd #{name}; fi", {}, &block) end def user_absent(name, &block) execute("if getent passwd #{name}; then userdel #{name}; fi", {}, &block) end end
Version data entries
8 entries across 8 versions & 1 rubygems