lex-infoblox 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 +7 -0
- data/.github/workflows/ci.yml +16 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +53 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +12 -0
- data/README.md +56 -0
- data/lex-infoblox.gemspec +30 -0
- data/lib/legion/extensions/infoblox/client.rb +31 -0
- data/lib/legion/extensions/infoblox/helpers/client.rb +25 -0
- data/lib/legion/extensions/infoblox/runners/networks.rb +26 -0
- data/lib/legion/extensions/infoblox/runners/records.rb +54 -0
- data/lib/legion/extensions/infoblox/version.rb +9 -0
- data/lib/legion/extensions/infoblox.rb +15 -0
- metadata +72 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 347e8129b671eca46da2d9a33f28156db53b3fa8c7c9be662f796446fd8d222c
|
|
4
|
+
data.tar.gz: 9f0757d43d693b22a615429bea3c1a94aa26ca2642ea15a138751e65a106a3ee
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e85d0f1b96d534eb8f100303e19d5075cd14bf6819d344907d1141be9d36f38e414ce6dfdb78efb2f2f2758f634c87670d12a7199d1356139444a238e9e6e143
|
|
7
|
+
data.tar.gz: ec7c07f5eeda41652a1775fe6b84dba94618d6ab000857b01e30182e46331de9b2e75362baa04895135e7fc1d8ab6f8d6b2f817a4fca7450e75978b4c2116105
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [origin]
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
ci:
|
|
9
|
+
uses: LegionIO/.github/.github/workflows/ci.yml@main
|
|
10
|
+
|
|
11
|
+
release:
|
|
12
|
+
needs: ci
|
|
13
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/origin'
|
|
14
|
+
uses: LegionIO/.github/.github/workflows/release.yml@main
|
|
15
|
+
secrets:
|
|
16
|
+
rubygems-api-key: ${{ secrets.RUBYGEMS_API_KEY }}
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 3.4
|
|
3
|
+
NewCops: enable
|
|
4
|
+
SuggestExtensions: false
|
|
5
|
+
|
|
6
|
+
Layout/LineLength:
|
|
7
|
+
Max: 160
|
|
8
|
+
|
|
9
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
|
10
|
+
EnforcedStyle: space
|
|
11
|
+
|
|
12
|
+
Layout/HashAlignment:
|
|
13
|
+
EnforcedHashRocketStyle: table
|
|
14
|
+
EnforcedColonStyle: table
|
|
15
|
+
|
|
16
|
+
Metrics/MethodLength:
|
|
17
|
+
Max: 50
|
|
18
|
+
|
|
19
|
+
Metrics/ClassLength:
|
|
20
|
+
Max: 1500
|
|
21
|
+
|
|
22
|
+
Metrics/ModuleLength:
|
|
23
|
+
Max: 1500
|
|
24
|
+
|
|
25
|
+
Metrics/BlockLength:
|
|
26
|
+
Max: 40
|
|
27
|
+
Exclude:
|
|
28
|
+
- 'spec/**/*'
|
|
29
|
+
|
|
30
|
+
Metrics/ParameterLists:
|
|
31
|
+
Max: 10
|
|
32
|
+
|
|
33
|
+
Metrics/AbcSize:
|
|
34
|
+
Max: 60
|
|
35
|
+
|
|
36
|
+
Metrics/CyclomaticComplexity:
|
|
37
|
+
Max: 15
|
|
38
|
+
|
|
39
|
+
Metrics/PerceivedComplexity:
|
|
40
|
+
Max: 17
|
|
41
|
+
|
|
42
|
+
Style/Documentation:
|
|
43
|
+
Enabled: false
|
|
44
|
+
|
|
45
|
+
Style/SymbolArray:
|
|
46
|
+
Enabled: true
|
|
47
|
+
|
|
48
|
+
Style/FrozenStringLiteralComment:
|
|
49
|
+
Enabled: true
|
|
50
|
+
EnforcedStyle: always
|
|
51
|
+
|
|
52
|
+
Naming/FileName:
|
|
53
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.1.0] - 2026-03-21
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Initial release
|
|
7
|
+
- `Helpers::Client` — Faraday connection builder targeting Infoblox WAPI with Basic Auth and configurable SSL verification
|
|
8
|
+
- `Runners::Records` — list_records (type: a/cname/host/ptr, zone filter), get_record (ref), create_record (type, name, value), delete_record (ref)
|
|
9
|
+
- `Runners::Networks` — list_networks, get_network (ref), next_available_ip (network_ref, count)
|
|
10
|
+
- Standalone `Client` class for use outside the Legion framework
|
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# lex-infoblox
|
|
2
|
+
|
|
3
|
+
LegionIO extension for Infoblox WAPI integration. Manages DNS records and network resources via the Infoblox Web API (WAPI).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add to your Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'lex-infoblox'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Standalone Usage
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
require 'legion/extensions/infoblox'
|
|
17
|
+
|
|
18
|
+
client = Legion::Extensions::Infoblox::Client.new(
|
|
19
|
+
url: 'https://infoblox.example.com/wapi/v2.12',
|
|
20
|
+
username: 'admin',
|
|
21
|
+
password: 'secret',
|
|
22
|
+
verify_ssl: true
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
# DNS Records
|
|
26
|
+
client.list_records(type: 'a', zone: 'example.com')
|
|
27
|
+
client.list_records(type: 'cname')
|
|
28
|
+
client.list_records(type: 'host')
|
|
29
|
+
client.list_records(type: 'ptr')
|
|
30
|
+
|
|
31
|
+
client.get_record(ref: 'record:a/ZG5z...')
|
|
32
|
+
|
|
33
|
+
client.create_record(type: 'a', name: 'server.example.com', value: '10.0.0.5')
|
|
34
|
+
client.create_record(type: 'cname', name: 'alias.example.com', value: 'server.example.com')
|
|
35
|
+
client.create_record(type: 'host', name: 'host.example.com', value: '10.0.0.6')
|
|
36
|
+
client.create_record(type: 'ptr', name: 'server.example.com', value: '10.0.0.5')
|
|
37
|
+
|
|
38
|
+
client.delete_record(ref: 'record:a/ZG5z...')
|
|
39
|
+
|
|
40
|
+
# Networks
|
|
41
|
+
client.list_networks
|
|
42
|
+
client.get_network(ref: 'network/ZG5z...')
|
|
43
|
+
client.next_available_ip(network_ref: 'network/ZG5z...', count: 1)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Authentication
|
|
47
|
+
|
|
48
|
+
Infoblox WAPI uses HTTP Basic Authentication. Provide `username` and `password` when creating the client.
|
|
49
|
+
|
|
50
|
+
## SSL Verification
|
|
51
|
+
|
|
52
|
+
SSL verification is enabled by default (`verify_ssl: true`). Set to `false` for environments using self-signed certificates.
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
MIT
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/legion/extensions/infoblox/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'lex-infoblox'
|
|
7
|
+
spec.version = Legion::Extensions::Infoblox::VERSION
|
|
8
|
+
spec.authors = ['Esity']
|
|
9
|
+
spec.email = ['matthewdiverson@gmail.com']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'LEX::Infoblox'
|
|
12
|
+
spec.description = 'Used to connect Legion to Infoblox WAPI for DNS and network management'
|
|
13
|
+
spec.homepage = 'https://github.com/LegionIO/lex-infoblox'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
spec.required_ruby_version = '>= 3.4'
|
|
16
|
+
|
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/LegionIO/lex-infoblox'
|
|
19
|
+
spec.metadata['changelog_uri'] = 'https://github.com/LegionIO/lex-infoblox/blob/main/CHANGELOG.md'
|
|
20
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
21
|
+
|
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
24
|
+
end
|
|
25
|
+
spec.bindir = 'exe'
|
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
27
|
+
spec.require_paths = ['lib']
|
|
28
|
+
|
|
29
|
+
spec.add_dependency 'faraday', '~> 2.0'
|
|
30
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'helpers/client'
|
|
4
|
+
require_relative 'runners/records'
|
|
5
|
+
require_relative 'runners/networks'
|
|
6
|
+
|
|
7
|
+
module Legion
|
|
8
|
+
module Extensions
|
|
9
|
+
module Infoblox
|
|
10
|
+
class Client
|
|
11
|
+
include Helpers::Client
|
|
12
|
+
include Runners::Records
|
|
13
|
+
include Runners::Networks
|
|
14
|
+
|
|
15
|
+
attr_reader :opts
|
|
16
|
+
|
|
17
|
+
def initialize(url:, username:, password:, verify_ssl: true, **extra)
|
|
18
|
+
@opts = { url: url, username: username, password: password, verify_ssl: verify_ssl, **extra }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def settings
|
|
22
|
+
{ options: @opts }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def connection(**override)
|
|
26
|
+
super(**@opts, **override)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'faraday'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Infoblox
|
|
8
|
+
module Helpers
|
|
9
|
+
module Client
|
|
10
|
+
def connection(url: 'https://infoblox.example.com/wapi/v2.12', username: nil, password: nil,
|
|
11
|
+
verify_ssl: true, **)
|
|
12
|
+
Faraday.new(url: url, ssl: { verify: verify_ssl }) do |conn|
|
|
13
|
+
conn.request :authorization, :basic, username, password if username && password
|
|
14
|
+
conn.request :json
|
|
15
|
+
conn.response :json, content_type: /\bjson$/
|
|
16
|
+
conn.headers['Content-Type'] = 'application/json'
|
|
17
|
+
conn.headers['Accept'] = 'application/json'
|
|
18
|
+
conn.adapter Faraday.default_adapter
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Infoblox
|
|
6
|
+
module Runners
|
|
7
|
+
module Networks
|
|
8
|
+
def list_networks(**)
|
|
9
|
+
resp = connection(**).get('/network')
|
|
10
|
+
{ networks: resp.body }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def get_network(ref:, **)
|
|
14
|
+
resp = connection(**).get("/#{ref}")
|
|
15
|
+
{ network: resp.body }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def next_available_ip(network_ref:, count: 1, **)
|
|
19
|
+
resp = connection(**).post("/#{network_ref}?_function=next_available_ip", { num: count })
|
|
20
|
+
{ ips: resp.body }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Infoblox
|
|
6
|
+
module Runners
|
|
7
|
+
module Records
|
|
8
|
+
def list_records(type: 'a', zone: nil, **)
|
|
9
|
+
params = {}
|
|
10
|
+
params[:zone] = zone if zone
|
|
11
|
+
resp = connection(**).get("/#{type_path(type)}", params)
|
|
12
|
+
{ records: resp.body }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def get_record(ref:, **)
|
|
16
|
+
resp = connection(**).get("/#{encode_ref(ref)}")
|
|
17
|
+
{ record: resp.body }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def create_record(type:, name:, value:, **)
|
|
21
|
+
body = build_record_body(type, name, value)
|
|
22
|
+
resp = connection(**).post("/#{type_path(type)}", body)
|
|
23
|
+
{ ref: resp.body }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def delete_record(ref:, **)
|
|
27
|
+
resp = connection(**).delete("/#{encode_ref(ref)}")
|
|
28
|
+
{ deleted: resp.status == 200, ref: ref }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def type_path(type)
|
|
34
|
+
"record:#{type}"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def encode_ref(ref)
|
|
38
|
+
ref
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def build_record_body(type, name, value)
|
|
42
|
+
case type.to_s.downcase
|
|
43
|
+
when 'a' then { name: name, ipv4addr: value }
|
|
44
|
+
when 'cname' then { name: name, canonical: value }
|
|
45
|
+
when 'ptr' then { ptrdname: name, ipv4addr: value }
|
|
46
|
+
when 'host' then { name: name, ipv4addrs: [{ ipv4addr: value }] }
|
|
47
|
+
else { name: name, value: value }
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/infoblox/version'
|
|
4
|
+
require 'legion/extensions/infoblox/helpers/client'
|
|
5
|
+
require 'legion/extensions/infoblox/runners/records'
|
|
6
|
+
require 'legion/extensions/infoblox/runners/networks'
|
|
7
|
+
require 'legion/extensions/infoblox/client'
|
|
8
|
+
|
|
9
|
+
module Legion
|
|
10
|
+
module Extensions
|
|
11
|
+
module Infoblox
|
|
12
|
+
extend Legion::Extensions::Core if Legion::Extensions.const_defined? :Core
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: lex-infoblox
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Esity
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: faraday
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '2.0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '2.0'
|
|
26
|
+
description: Used to connect Legion to Infoblox WAPI for DNS and network management
|
|
27
|
+
email:
|
|
28
|
+
- matthewdiverson@gmail.com
|
|
29
|
+
executables: []
|
|
30
|
+
extensions: []
|
|
31
|
+
extra_rdoc_files: []
|
|
32
|
+
files:
|
|
33
|
+
- ".github/workflows/ci.yml"
|
|
34
|
+
- ".gitignore"
|
|
35
|
+
- ".rspec"
|
|
36
|
+
- ".rubocop.yml"
|
|
37
|
+
- CHANGELOG.md
|
|
38
|
+
- Gemfile
|
|
39
|
+
- README.md
|
|
40
|
+
- lex-infoblox.gemspec
|
|
41
|
+
- lib/legion/extensions/infoblox.rb
|
|
42
|
+
- lib/legion/extensions/infoblox/client.rb
|
|
43
|
+
- lib/legion/extensions/infoblox/helpers/client.rb
|
|
44
|
+
- lib/legion/extensions/infoblox/runners/networks.rb
|
|
45
|
+
- lib/legion/extensions/infoblox/runners/records.rb
|
|
46
|
+
- lib/legion/extensions/infoblox/version.rb
|
|
47
|
+
homepage: https://github.com/LegionIO/lex-infoblox
|
|
48
|
+
licenses:
|
|
49
|
+
- MIT
|
|
50
|
+
metadata:
|
|
51
|
+
homepage_uri: https://github.com/LegionIO/lex-infoblox
|
|
52
|
+
source_code_uri: https://github.com/LegionIO/lex-infoblox
|
|
53
|
+
changelog_uri: https://github.com/LegionIO/lex-infoblox/blob/main/CHANGELOG.md
|
|
54
|
+
rubygems_mfa_required: 'true'
|
|
55
|
+
rdoc_options: []
|
|
56
|
+
require_paths:
|
|
57
|
+
- lib
|
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
59
|
+
requirements:
|
|
60
|
+
- - ">="
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: '3.4'
|
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
68
|
+
requirements: []
|
|
69
|
+
rubygems_version: 3.6.9
|
|
70
|
+
specification_version: 4
|
|
71
|
+
summary: LEX::Infoblox
|
|
72
|
+
test_files: []
|