Skip to content

Instantly share code, notes, and snippets.

@kwilczynski
Created March 16, 2012 18:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kwilczynski/2051811 to your computer and use it in GitHub Desktop.
Save kwilczynski/2051811 to your computer and use it in GitHub Desktop.
Facter.add(:noop) do
confine :kernel => :linux
result = false
setcode do
unless Facter.value(:environment).match(/^(test|dev|qa)$/)
result = true unless Time.now.utc.hour.between?(1, 10)
end
result
end
end
@kwilczynski
Copy link
Author

Note: this will work given that "environment" fact is set / present. Otherwise, there has to be a conditional guarding it from failure due to NilClass yielding as "environment".

@stschulte
Copy link

instead of writing Time.now.utc.to_a[2] you can also use Time.now.utc.hour which is more readable

@kwilczynski
Copy link
Author

+1 :)

Edit: Amended as per Stefan's suggestion :)

@glarizza
Copy link

Good stuff, guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment