A
Asif Iqbal
#!/usr/bin/ruby
ARGF.each do |line|
sunetid, tmp, uid, gid, name, homedir, shell = line.split(/\:/)
puts " user { \"" + sunetid + "\":"
puts " ensure => \"present\","
puts " uid => \"" + uid + "\","
puts " gid => \"" + gid + "\","
puts " comment => \"" + name + "\","
puts " home => \"" + homedir + "\","
puts " shell => \"" + shell.chomp + "\","
puts " }"
puts ""
end
This file take the a password file and generate some output per user.
How do I feed it passwd and shadow files and generate
a file per user with another key => value like password => 'hashkey
from shadow'
along with the key => value then it already generates?
So instead of the current output like
user { "dbbkp":
ensure => "present",
uid => "12346",
gid => "70006",
comment => "DB Backup User - See rsync in cron",
home => "/home/dbbkp",
shell => "/usr/local/bin/bash",
}
I want it to generate an output like this
user { "dbbkp":
ensure => "present",
uid => "12346",
gid => "70006",
shadow => "iaUGiJld2XMKM" # it will get that value from shadow file
comment => "DB Backup User - See rsync in cron",
home => "/home/dbbkp",
shell => "/usr/local/bin/bash",
}
here passwd file entry looks like this
dbbkp:x:12346:70006B Backup User - See rsync in
cron:/home/dbbkp:/usr/local/bin/bash
and shadow file entry looks like this
dbbkp:iaUGiJld2XMKM:::::::
Thanks for the help
ARGF.each do |line|
sunetid, tmp, uid, gid, name, homedir, shell = line.split(/\:/)
puts " user { \"" + sunetid + "\":"
puts " ensure => \"present\","
puts " uid => \"" + uid + "\","
puts " gid => \"" + gid + "\","
puts " comment => \"" + name + "\","
puts " home => \"" + homedir + "\","
puts " shell => \"" + shell.chomp + "\","
puts " }"
puts ""
end
This file take the a password file and generate some output per user.
How do I feed it passwd and shadow files and generate
a file per user with another key => value like password => 'hashkey
from shadow'
along with the key => value then it already generates?
So instead of the current output like
user { "dbbkp":
ensure => "present",
uid => "12346",
gid => "70006",
comment => "DB Backup User - See rsync in cron",
home => "/home/dbbkp",
shell => "/usr/local/bin/bash",
}
I want it to generate an output like this
user { "dbbkp":
ensure => "present",
uid => "12346",
gid => "70006",
shadow => "iaUGiJld2XMKM" # it will get that value from shadow file
comment => "DB Backup User - See rsync in cron",
home => "/home/dbbkp",
shell => "/usr/local/bin/bash",
}
here passwd file entry looks like this
dbbkp:x:12346:70006B Backup User - See rsync in
cron:/home/dbbkp:/usr/local/bin/bash
and shadow file entry looks like this
dbbkp:iaUGiJld2XMKM:::::::
Thanks for the help