blob: 29ffdbf957384c52527263dafd54d3121f9a9d34 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/usr/bin/ruby -w
#--------------------
# Convert a passwd-format file to Puppet users
#
require 'getoptlong'
result = GetoptLong.new(
[ "--help", "-h", GetoptLong::NO_ARGUMENT ]
)
result.each { |opt,arg|
case opt
when "--help"
puts "There is no help yet"
exit
else
raise "Invalid option '#{opt}'"
end
}
fields = %w{uid gid comment home shell}
puts "user {"
ARGV.each do |file|
File.open(file) do |of|
of.sort.each do |line|
next if line =~ /^\s*#/
next if line =~ /^\s*$/
ary = line.chomp.split(":")
puts " " + ary.shift + ":"
ary.shift # get rid of that password field
puts fields.zip(ary).collect { |field, val|
" %s => \"%s\"" % [field, val]
}.join(",\n") + ";"
end
end
end
puts "}"
# $Id$
|