Chef + InSpec using only_if for users

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 = [

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/ }


You can only use only_if and similar APIs from inside a control block. You would probably want to use the user InSpec resource for this in the first place but also check out the users API.

Need Your Help

Any difference between ctx.write() and in netty?

java netty

I noticed that the ctx is different from handler to handler even these handlers are in the same pipeline, for example

Format JodaTime DateTime with preferred DateFormat

java android datetime jodatime date-formatting

I'm using Joda Time and need to display a date in the user's preferred format (note that before Android M, the format could be changed).