vagrant-powerdns 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72d6438d5052854280b1685c92c883236e22a28c
|
4
|
+
data.tar.gz: 135fdbd6e654a8e405f23ab8afc21e1092589676
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f6f74dec4825318bbee4c43d67ee7aca986ce0492e65066644544cdbaa28fc0ed355e4b53f4e70e533ce9d678636b70341447d06e7614dd5a4128878bed4bb0
|
7
|
+
data.tar.gz: 3abc1137238395a9f5a81ec2a727ec89be1b88e64d2dbda5948716e36d4700aa98ad2592a6eb9df0b5930ad4d2e06072ec7a35766c608253e3498fc599709a62
|
@@ -5,13 +5,12 @@ module Vagrant
|
|
5
5
|
def initialize(app, env)
|
6
6
|
@app = app
|
7
7
|
@machine = env[:machine]
|
8
|
+
@zone = env[:machine].config.powerdns.default_zone
|
8
9
|
@host = env[:machine].config.vm.hostname.nil? ?
|
9
10
|
env[:machine].name.to_s : env[:machine].config.vm.hostname.to_s
|
10
|
-
@domain = @host +
|
11
|
-
@zone = env[:machine].config.powerdns.default_zone.name
|
11
|
+
@domain = @host.include?(@zone.name)? @host : @host + @zone.dotted
|
12
12
|
|
13
13
|
# Identify who i am
|
14
|
-
@myname = Etc.getpwuid[:gecos]
|
15
14
|
@myuser = Etc.getlogin.gsub(/\s+/, '')
|
16
15
|
@myhost = Socket.gethostname
|
17
16
|
end
|
@@ -24,27 +23,28 @@ module Vagrant
|
|
24
23
|
if !stdout.empty?
|
25
24
|
re = /src ([0-9\.]+)/
|
26
25
|
ip = stdout.match(re)[1]
|
26
|
+
zone = @zone.name
|
27
27
|
|
28
28
|
p = PdnsRestApiClient.new(env[:machine].config.powerdns.api_url,
|
29
29
|
env[:machine].config.powerdns.api_key)
|
30
30
|
|
31
31
|
# Only update if IP changed or inactive
|
32
|
-
record_not_found = p.zone(
|
33
|
-
record_disabled = p.zone(
|
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
35
|
if record_not_found or record_disabled
|
36
36
|
env[:ui].info "PowerDNS action..."
|
37
37
|
# Append new comment
|
38
38
|
new_comment = {
|
39
|
-
content: "#{@
|
40
|
-
account: @
|
39
|
+
content: "#{@myuser} added this record from #{@myhost}",
|
40
|
+
account: @myuser,
|
41
41
|
name: @domain,
|
42
42
|
type: "A"
|
43
43
|
}
|
44
|
-
comments = p.zone(
|
44
|
+
comments = p.zone(zone)["comments"].delete_if { |v| v["name"] != @domain }
|
45
45
|
comments << new_comment
|
46
46
|
|
47
|
-
ret = p.modify_domain(domain: @domain, ip: ip, zone_id:
|
47
|
+
ret = p.modify_domain(domain: @domain, ip: ip, zone_id: zone,
|
48
48
|
comments: comments)
|
49
49
|
|
50
50
|
# Check return
|
@@ -61,9 +61,9 @@ module Vagrant
|
|
61
61
|
|
62
62
|
# Display ui
|
63
63
|
if error.nil?
|
64
|
-
env[:ui].detail "=> record #{@domain}(#{ip}) in zone #{
|
64
|
+
env[:ui].detail "=> record #{@domain}(#{ip}) in zone #{zone} added !"
|
65
65
|
else
|
66
|
-
env[:ui].detail "=> failed to add record #{@domain}(#{ip}) in zone #{
|
66
|
+
env[:ui].detail "=> failed to add record #{@domain}(#{ip}) in zone #{zone}. Error was: #{error}"
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -79,13 +79,12 @@ module Vagrant
|
|
79
79
|
def initialize(app, env)
|
80
80
|
@app = app
|
81
81
|
@machine = env[:machine]
|
82
|
+
@zone = env[:machine].config.powerdns.default_zone
|
82
83
|
@host = env[:machine].config.vm.hostname.nil? ?
|
83
84
|
env[:machine].name.to_s : env[:machine].config.vm.hostname.to_s
|
84
|
-
@domain = @host +
|
85
|
-
@zone = env[:machine].config.powerdns.default_zone.name
|
85
|
+
@domain = @host.include?(@zone.name)? @host : @host + @zone.dotted
|
86
86
|
|
87
87
|
# Identify who i am
|
88
|
-
@myname = Etc.getpwuid[:gecos]
|
89
88
|
@myuser = Etc.getlogin.gsub(/\s+/, '')
|
90
89
|
@myhost = Socket.gethostname
|
91
90
|
end
|
@@ -95,17 +94,18 @@ module Vagrant
|
|
95
94
|
p = PdnsRestApiClient.new(env[:machine].config.powerdns.api_url,
|
96
95
|
env[:machine].config.powerdns.api_key)
|
97
96
|
|
97
|
+
zone = @zone.name
|
98
98
|
# Get A record
|
99
|
-
record = p.zone(
|
99
|
+
record = p.zone(zone)["records"].find {|v| v["name"] == @domain}
|
100
100
|
|
101
101
|
# only disable if active
|
102
|
-
if
|
102
|
+
if !record.nil? and not record["disabled"]
|
103
103
|
env[:ui].info "PowerDNS action..."
|
104
104
|
|
105
105
|
# Prepare comment to be appended
|
106
106
|
new_comment = {
|
107
|
-
content: "#{@
|
108
|
-
account: @
|
107
|
+
content: "#{@myuser} disabled this record from #{@myhost}",
|
108
|
+
account: @myuser,
|
109
109
|
name: @domain,
|
110
110
|
type: "A"
|
111
111
|
}
|
@@ -115,7 +115,7 @@ module Vagrant
|
|
115
115
|
# Get the old IP
|
116
116
|
ip = record["records"].find {|v| v["name"] == @domain}["content"]
|
117
117
|
|
118
|
-
ret = p.disable_domain(domain: @domain, ip: ip, zone_id:
|
118
|
+
ret = p.disable_domain(domain: @domain, ip: ip, zone_id: zone,
|
119
119
|
comments: comments)
|
120
120
|
|
121
121
|
# Check return
|
@@ -132,9 +132,9 @@ module Vagrant
|
|
132
132
|
|
133
133
|
# Display ui
|
134
134
|
if error.nil?
|
135
|
-
env[:ui].detail "=> record #{@domain}(#{ip}) in zone #{
|
135
|
+
env[:ui].detail "=> record #{@domain}(#{ip}) in zone #{zone} disabled !"
|
136
136
|
else
|
137
|
-
env[:ui].detail "=> failed to disab;e record #{@domain} in zone #{
|
137
|
+
env[:ui].detail "=> failed to disab;e record #{@domain} in zone #{zone}. Error was: #{error}"
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-powerdns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sayid Munawar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -83,8 +83,6 @@ files:
|
|
83
83
|
- bin/setup
|
84
84
|
- lib/vagrant-powerdns.rb
|
85
85
|
- lib/vagrant-powerdns/action.rb
|
86
|
-
- lib/vagrant-powerdns/action/add_record.rb
|
87
|
-
- lib/vagrant-powerdns/action/del_record.rb
|
88
86
|
- lib/vagrant-powerdns/config.rb
|
89
87
|
- lib/vagrant-powerdns/errors.rb
|
90
88
|
- lib/vagrant-powerdns/includes/Ip.class.rb
|
File without changes
|
File without changes
|