Puppet Function: get_jails
- Defined in:
- lib/puppet/parser/functions/get_jails.rb
- Function type:
- Ruby 3.x API
Overview
Retrieves a list of jails from FreeNAS
Credentials must be available in /etc/freenas_api.yml
See api.freenas.org/resources/jails.html#id2 for response format
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/puppet/parser/functions/get_jails.rb', line 6 newfunction(:get_jails, :type => :rvalue, :doc => <<-EOS Retrieves a list of jails from FreeNAS Credentials must be available in /etc/freenas_api.yml See http://api.freenas.org/resources/jails.html#id2 for response format EOS ) do |args| credentials = YAML.load_file('/etc/freenas_api.yml') uri = URI.parse("#{credentials[:base_url]}/api/v1.0/jails/jails/") req = Net::HTTP::Get.new(uri.path) req.basic_auth credentials[:username], credentials[:password] http = Net::HTTP.new(uri.host, uri.port) response = http.start { |cx| cx.request(req) } JSON.parse(response.body) end |