Class: Chef::Provider::DnsMadeEasy

Inherits:
Chef::Provider show all
Defined in:
lib/chef/providers/dns_dnsmadeeasy_provider.rb

Instance Method Summary collapse

Instance Method Details

#action_registerObject

Register DNS with DNS Made Easy service This relies on ‘curl’ being available on the system

Return

true

Always return true

Raise

Chef::Exceptions::Dns

DNS registration request returned an error



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/chef/providers/dns_dnsmadeeasy_provider.rb', line 43

def action_register
  Chef::Log.info("Updating DNS for #{@new_resource.name} to point to #{@new_resource.ip_address}")
  query="username=#{@new_resource.user}&password=#{@new_resource.passwd}&id=#{@new_resource.name}&ip=#{@new_resource.ip_address}"
  Chef::Log.debug("QUERY: #{query}")
  result = post_change(query)
  if result =~ /success|error-record-ip-same/
    Chef::Log.info("DNSID #{@new_resource.name} set to this instance IP: #{@new_resource.ip_address}")
  else
    raise(Chef::Exceptions::Dns, "#{self.class.name}: Error setting #{@new_resource.name} to instance IP: #{@new_resource.ip_address}: Result: #{result}")
  end
  true
end

#load_current_resourceObject

No concept of a ‘current’ resource for DNS registration, this is a no-op

Return

true

Always return true



31
32
33
# File 'lib/chef/providers/dns_dnsmadeeasy_provider.rb', line 31

def load_current_resource
  true
end

#post_change(query) ⇒ Object

Make the HTTPS request using ‘curl’

Parameters

query(String)

Query string used to build request

Return

res(String)

Response content



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/chef/providers/dns_dnsmadeeasy_provider.rb', line 63

def post_change(query)
  # use double-quotes for Window but use single-quotes for security
  # reasons in Linux.
  curl_options = '-S -s --retry 7 -k -o - -g -f'
  dns_made_easy_url = 'https://www.dnsmadeeasy.com/servlet/updateip'
  if !!(RUBY_PLATFORM =~ /mswin/)
    res = `curl #{curl_options} \"#{dns_made_easy_url}?#{query}\"`
  else
    res = `curl #{curl_options} '#{dns_made_easy_url}?#{query}'`
  end
  return res
end