Sha256: c73509a04541b50454f433c8e249277f532e078556cec3b9054f5b3650c1500c
Contents?: true
Size: 1.42 KB
Versions: 4
Compression:
Stored size: 1.42 KB
Contents
module DanarchyDeploy class Groups def self.new(deployment, options) return deployment if ! deployment[:groups] puts "\n" + self.name (groupadd_result, groupdel_result) = nil deployment[:groups].each do |group| puts " > Checking if group '#{group[:groupname]}' already exists." groupcheck_result = groupcheck(group, options) if groupcheck_result[:stdout] puts " - Group: #{group[:groupname]} already exists!" else puts " |+ Adding group: #{group[:groupname]}" groupadd_result = groupadd(group, options) end end deployment end private def self.groupadd(group, options) groupadd_cmd = "groupadd #{group[:groupname]} " groupadd_cmd += "--gid #{group[:gid]} " if group[:gid] groupadd_cmd += "--system " if group[:system] if options[:pretend] puts "\tFake run: #{groupadd_cmd}" else DanarchyDeploy::Helpers.run_command(groupadd_cmd, options) end end def self.groupdel(group, options) groupdel_cmd = "groupdel #{group[:groupname]}" if options[:pretend] puts "\tFake run: #{groupdel_cmd}" else DanarchyDeploy::Helpers.run_command(groupdel_cmd, options) end end def self.groupcheck(group, options) DanarchyDeploy::Helpers.run_command("/usr/bin/getent group #{group[:groupname]}", options) end end end
Version data entries
4 entries across 4 versions & 1 rubygems