In a module I'm working on, I need to check if specific users exist on a machine. The idea was to create a custom fact that contains an array of all users. In the module, it should iterate through the array and check if a specific user is part of the array.
My Custom Fact:
Facter.add("users") do
setcode do
IO.readlines("/etc/passwd").collect do |line|
line.split(":").first
end
end
end
The output of the fact is a String like this: ["user1", "user2", "user3"]
Because it is just a string and no array, I'm unable to iterate through it in my puppet module.
I then tried
shell_split($::users).each |String $user| {
notify { "$user":}
}
But now, each user contains a comma after the username.
Do you have an idea for a working and better solution?