I need to go through a list of users and determine whether they are in a locked state, I can do this just fine but my issue is that I don't know how inspec will let me ignore users on my list that don't exist on the operating system. I've tried a few different methods using only_if (including below) with no luck.
Here is my code below:
system_accounts = [
'user1'
'user2'
'user3'
system_accounts.each do |name|
only_if command("getent passwd #{name}") do
describe command("passwd -S #{name}").stdout.split[1] do
it { should match /LK|NP|NL/ }
end
end
end
end