vagrant-powerdns 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acb0cb8a88a2a042926f73b8413195f26f54296b
|
4
|
+
data.tar.gz: a9884828fe4222180e4e60bc4d85ab499a2ef8b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e85525301d3762ae8eeb431a70d567e7e49363c14a942820db88cbad19339c7212609cc24c0e158ec3113e3377bfbce2fbf5fe5dea33321ddc4ce3b9c6b183f7
|
7
|
+
data.tar.gz: 7fe9fc614097755d8af7b5e9243bcf0531ce7f5b820e658b2ea89da832f0082e9022af301bd823f2f1fff2ec2b25efa64da4a3e34a05ad38be107d83f695966d
|
@@ -28,10 +28,11 @@ module Vagrant
|
|
28
28
|
p = PdnsRestApiClient.new(env[:machine].config.powerdns.api_url,
|
29
29
|
env[:machine].config.powerdns.api_key)
|
30
30
|
|
31
|
-
# Only update if IP changed
|
32
|
-
|
33
|
-
|
31
|
+
# Only update if IP changed or inactive
|
32
|
+
record_not_found = p.zone(@zone)["records"].select {|v| v["type"] == "A" and v["name"] == @domain and v["content"] == ip}.empty?
|
33
|
+
record_disabled = p.zone(@zone)["records"].select { |v| v["type"] == "A" and v["name"] == @domain and v["disable"]}.empty?
|
34
34
|
|
35
|
+
if record_not_found or record_disabled
|
35
36
|
env[:ui].info "PowerDNS action..."
|
36
37
|
# Append new comment
|
37
38
|
new_comment = {
|
@@ -22,57 +22,39 @@ module Vagrant
|
|
22
22
|
@default_zone = Zone.new @default_zone;
|
23
23
|
end
|
24
24
|
|
25
|
+
@api_url = nil if @api_url == UNSET_VALUE
|
26
|
+
@api_key = nil if @api_key == UNSET_VALUE
|
25
27
|
@disable = false if @disable == UNSET_VALUE
|
26
28
|
|
27
|
-
# default way to obtain ip address
|
28
|
-
if @ip == UNSET_VALUE
|
29
|
-
@ip = proc do |guest_machine|
|
30
|
-
ips = nil
|
31
|
-
puts "SUDO SUUUUUU............"
|
32
|
-
guest_machine.communicate.sudo("hostname -I") do |type, data|
|
33
|
-
ips = data.scan /[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/
|
34
|
-
end
|
35
|
-
ips
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
29
|
end
|
40
30
|
|
41
31
|
def enabled?
|
42
|
-
|
32
|
+
@api_url.is_a?(String) or @api_key.is_a?(String) or @default_zone.is_a?(String)
|
43
33
|
end
|
44
34
|
|
45
35
|
def validate(machine)
|
46
|
-
|
36
|
+
if enabled?
|
37
|
+
#return if not @api_url.nil? and not @api_key.nil? and not @default_zone.nil?
|
47
38
|
|
48
|
-
|
39
|
+
errors = []
|
49
40
|
|
50
|
-
|
51
|
-
|
41
|
+
# verify @disable
|
42
|
+
if @disable != true and @disable != false then errors << 'invalid disable setting' end
|
52
43
|
|
53
|
-
|
54
|
-
|
44
|
+
# verify zone
|
45
|
+
begin @default_zone = Zone.new @default_zone; rescue => e; errors << e.message end
|
55
46
|
|
56
|
-
|
57
|
-
|
58
|
-
@ip.map!{|ip| begin Ip.new(ip); rescue => e; errors << e.message end}
|
47
|
+
# verify api_url
|
48
|
+
begin @api_url = String.new @api_url; rescue => e; errors << "powerdns.api_url: Invalid URL. It should be like `http://ns.example.com:8081'" end
|
59
49
|
|
60
|
-
|
61
|
-
begin @
|
62
|
-
@ip = [@ip]
|
50
|
+
# verify api_key
|
51
|
+
begin @api_key = String.new @api_key; rescue => e; errors << "powerdns.api_key: Invalid API Key. It should be like `api_key_of_powerdns'" end
|
63
52
|
|
64
|
-
|
65
|
-
#
|
66
|
-
else
|
67
|
-
@ip = nil
|
68
|
-
end
|
53
|
+
# verify zone
|
54
|
+
#begin @default_zone = Zone.new @default_zone; rescue => e; errors << "config.powerdns.default_zone: Invalid Zone #{@default_zone}. It should be like: `dev.example.com'" end
|
69
55
|
|
70
|
-
|
71
|
-
|
72
|
-
# errors << "file '#{@dnsmasqconf}' does not exist" unless File.exists? @dnsmasqconf
|
73
|
-
#end
|
74
|
-
|
75
|
-
return { 'PowerDNS configuration' => errors }
|
56
|
+
return { 'PowerDNS configuration' => errors }
|
57
|
+
end
|
76
58
|
end
|
77
59
|
|
78
60
|
end
|
@@ -12,7 +12,8 @@ class Zone
|
|
12
12
|
name = name.dotted
|
13
13
|
end
|
14
14
|
|
15
|
-
raise ArgumentError, "
|
15
|
+
raise ArgumentError, "Invalid Zone: #{name.to_s}" if !name.is_a?(String)
|
16
|
+
raise ArgumentError, "no zone name given" if name.empty?
|
16
17
|
|
17
18
|
# parse domain name ...
|
18
19
|
name = name.to_s
|
data/lib/vagrant-powerdns.rb
CHANGED
@@ -12,20 +12,20 @@ module Vagrant
|
|
12
12
|
description "A PowerDNS Vagrant plugin that manages the zone record via vagrant up/destroy"
|
13
13
|
|
14
14
|
inc_path = Pathname.new(File.expand_path("../vagrant-powerdns/includes", __FILE__))
|
15
|
-
|
16
|
-
require inc_path.join("Ip.class.rb")
|
17
|
-
|
15
|
+
lib_path = Pathname.new(File.expand_path("../vagrant-powerdns", __FILE__))
|
18
16
|
util_path = Pathname.new(File.expand_path("../vagrant-powerdns/util", __FILE__))
|
19
|
-
require util_path.join("pdns_api")
|
20
17
|
|
21
|
-
|
22
|
-
require
|
18
|
+
require inc_path.join("Zone.class.rb")
|
19
|
+
require inc_path.join("Ip.class.rb")
|
23
20
|
|
24
21
|
config "powerdns" do
|
25
22
|
require lib_path.join("config")
|
26
23
|
Config
|
27
24
|
end
|
28
25
|
|
26
|
+
require util_path.join("pdns_api")
|
27
|
+
require lib_path.join("action")
|
28
|
+
|
29
29
|
action_hook(:powerdns, :machine_action_up) do |hook|
|
30
30
|
hook.append(Vagrant::Action::Up)
|
31
31
|
end
|