Skip to content

Instantly share code, notes, and snippets.

@natemccurdy
Last active August 29, 2015 14:14
Show Gist options
  • Save natemccurdy/1326c603ebcecc2245ed to your computer and use it in GitHub Desktop.
Save natemccurdy/1326c603ebcecc2245ed to your computer and use it in GitHub Desktop.
Check if Wordpress is installed for Fundamentals Capstone Lab
#/etc/puppetlabs/puppet/modules/classroom/lib/facter/has_wordpress.rb
require 'net/http'
Facter.add('has_wordpress') do
setcode do
begin
http = Net::HTTP.new(Facter.value("ipaddress"), '80')
req = Net::HTTP::Get.new('/wp-login.php')
req['Content-Type'] = 'plain/html'
resp = http.request(req)
case resp.code
when '200'
'configured'
when '302'
'unconfigured'
end
rescue => e
Facter.debug(e.message)
end
end
end
@natemccurdy
Copy link
Author

Doesn't work if they put wordpress in a vhost.

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