palletjack-tools 0.4.1 → 0.5.0

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: 9b2e6d3100dfd7ca28d45f9a8b549a9f1788b74c
4
- data.tar.gz: 7a260f0932900de7c14979b98b06fdfb35dfe20f
3
+ metadata.gz: 0ecc29649c0b152d19482c91b6f8fe8520516744
4
+ data.tar.gz: fb8bc8d57f9088c9a75807133a21db6e0a16b101
5
5
  SHA512:
6
- metadata.gz: 379923a2b20867bb022573661424926fd78ce314c5a305200cfaae68c9058eb39b1d5739ea59c3e80af2866f4185564a3a7bd5542d59fb0659c8a9123583c90c
7
- data.tar.gz: 362a13e767e93511d8105e372fc224af14e52aa76fbd16bd9a9188c1daf937a7d9eec4c0085258a814913803d3c7b59c6d870954d4b43d0829b2a993bc44e673
6
+ metadata.gz: 1ef02ba48e7cc6cb9019dd6f2057e3757f23b9c70b3fab0c8e0602937254dcbac822a724ac38064171e2952bb17a04ba565d1fdc7fe99fab67155633f8470b71
7
+ data.tar.gz: f203988f774dcfede6fa9e6d76a1a10a820f0eb2524774f0a12567728325b789b2366521f5ea9ed013a17f3e5bc67ef955b41a9617b39b165696c6ee24b46238
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
data/exe/create_domain CHANGED
@@ -29,21 +29,21 @@ Create domain and ipv4_network objects in a warehouse"
29
29
 
30
30
  pallet_dir 'ipv4_network', :network
31
31
  pallet_box 'ipv4_network', :network, 'dhcp' do
32
- { net:{ dhcp:{ 'tftp-server' => '', 'boot-file' => '' } } }
32
+ { net: { dhcp: { 'tftp-server' => '', 'boot-file' => '' } } }
33
33
  end
34
34
  pallet_box 'ipv4_network', :network, 'identity' do
35
- { net:{ ipv4:{ gateway:'' },
36
- dns:{ resolver:[''] } } }
35
+ { net: { ipv4: { gateway: '' },
36
+ dns: { resolver: [''] } } }
37
37
  end
38
38
 
39
39
  # Create the DNS domain object
40
40
 
41
41
  pallet_dir 'domain', :domain
42
42
  pallet_box 'domain', :domain, 'dns' do
43
- { net:{ dns:{ ns:[''], 'soa-ns' => '', 'soa-contact' => '' } } }
43
+ { net: { dns: { ns: [''], 'soa-ns' => '', 'soa-contact' => '' } } }
44
44
  end
45
45
  pallet_box 'domain', :domain, 'services' do
46
- { net:{ service:{ syslog:[{address:'', port:'514', protocol:'udp' } ] } } }
46
+ { net: { service: { syslog: [{address: '', port: '514', protocol: 'udp' }] } } }
47
47
  end
48
48
  pallet_links 'domain', :domain, 'ipv4_network' => ['ipv4_network', :network]
49
49
  end
@@ -14,7 +14,7 @@ Create phy_nic and ipv4_interface objects in a warehouse"
14
14
 
15
15
  opts.on('-s SYSTEM', '--system SYSTEM', 'system name', String) {|system|
16
16
  options[:system] = system }
17
- opts.on('-d DOMAIN', '--domain DOMAIN', 'domain name',String) {|domain|
17
+ opts.on('-d DOMAIN', '--domain DOMAIN', 'domain name', String) {|domain|
18
18
  options[:domain] = domain }
19
19
  opts.on('-m MAC', '--mac MAC', 'MAC address', String) {|mac|
20
20
  options[:mac] = mac }
@@ -35,7 +35,7 @@ Create phy_nic and ipv4_interface objects in a warehouse"
35
35
 
36
36
  pallet_dir 'phy_nic', :mac
37
37
  pallet_box 'phy_nic', :mac, 'identity' do
38
- { net:{ layer2:{ name:'' } } }
38
+ { net: { layer2: { name: '' } } }
39
39
  end
40
40
 
41
41
  # Create IPv4 Interface object
data/exe/create_system CHANGED
@@ -30,7 +30,7 @@ Create system objects in a warehouse"
30
30
  def output
31
31
  pallet_dir 'system', :system
32
32
  pallet_box 'system', :system, 'role' do
33
- { system:{ role:[ '' ] } }
33
+ { system: { role: [''] } }
34
34
  end
35
35
  pallet_links 'system', :system, 'domain' => ['domain', :domain]
36
36
  pallet_links 'system', :system,
data/exe/dump_pallet CHANGED
@@ -6,7 +6,6 @@ require 'palletjack/tool'
6
6
 
7
7
  class DumpPallet < PalletJack::Tool
8
8
  def parse_options(parser)
9
-
10
9
  parser.banner = "Usage: #{$PROGRAM_NAME} [options] [<name> ...]
11
10
 
12
11
  Dump the YAML representation of all named pallets in a Palletjack warehouse
@@ -18,7 +17,7 @@ pallets of the specified type."
18
17
  # the parse! method of the parser is eventually run and finds
19
18
  # a --type option. Keep declarations in that order for clarity.
20
19
 
21
- options[:type]='system'
20
+ options[:type] = 'system'
22
21
  parser.on('-t TYPE', '--type TYPE',
23
22
  'type (default "system")',
24
23
  String) {|type| options[:type] = type }
@@ -26,17 +25,17 @@ pallets of the specified type."
26
25
  options[:match_name] = :leaf_name
27
26
  parser.on('-f', '--[no-]full-name',
28
27
  'match full_name of pallets instead of leaf_name'
29
- ) {|maybe| options[:match_name] = if maybe
30
- :full_name
31
- else
32
- :leaf_name
33
- end
28
+ ) {|maybe| options[:match_name] = if maybe
29
+ :full_name
30
+ else
31
+ :leaf_name
32
+ end
34
33
  }
35
34
 
36
35
  options[:position] = false
37
36
  parser.on('-p', '--[no-]position',
38
37
  'output source file name and position of each value'
39
- ) {|maybe| TraceableString.debug = maybe }
38
+ ) {|maybe| TraceableString.debug = maybe }
40
39
  end
41
40
 
42
41
  # Dump the yaml contents of all pallets given to STDOUT
@@ -45,7 +44,7 @@ pallets of the specified type."
45
44
  abort('No matching pallets found.') if pallets.empty?
46
45
 
47
46
  pallets.each do |p|
48
- puts "---"
47
+ puts '---'
49
48
  puts "# #{p.kind}: #{p.name}"
50
49
  puts p.to_yaml.gsub(' =^.^= ', '   # ')
51
50
  end
data/exe/palletjack2kea CHANGED
@@ -36,17 +36,17 @@ Write configuration for the Kea DHCP server from a Palletjack warehouse"
36
36
 
37
37
  def process
38
38
  @kea_config = { 'Dhcp4' =>
39
- jack.fetch(kind:'service',
40
- parent_name:'dhcp-server',
41
- name:options[:service])['service.kea_v4']
39
+ jack.fetch(kind: 'service',
40
+ parent_name: 'dhcp-server',
41
+ name: options[:service])['service.kea_v4']
42
42
  }
43
43
 
44
44
  @kea_config['Dhcp4']['subnet4'] = []
45
45
 
46
- jack.each(kind:'ipv4_network') do |net|
46
+ jack.each(kind: 'ipv4_network') do |net|
47
47
  net_config = {'subnet' => net['net.ipv4.cidr'],
48
- 'reservations' => [],
49
- 'option-data' => []}
48
+ 'reservations' => [],
49
+ 'option-data' => []}
50
50
  if net['net.ipv4.gateway']
51
51
  net_config['option-data'] <<
52
52
  dhcp4_option(3, 'routers', net['net.ipv4.gateway'])
@@ -77,8 +77,8 @@ Write configuration for the Kea DHCP server from a Palletjack warehouse"
77
77
  dhcp4_option(67, 'boot-file-name', net['net.dhcp.boot-file'])
78
78
  end
79
79
 
80
- net.children(kind:'ipv4_interface',
81
- none?:{ 'net.layer2.address' => nil }
80
+ net.children(kind: 'ipv4_interface',
81
+ none?: { 'net.layer2.address' => nil }
82
82
  ) do |interface|
83
83
  net_config['reservations'] << {
84
84
  'hw-address' => interface['net.layer2.address'],
@@ -87,7 +87,7 @@ Write configuration for the Kea DHCP server from a Palletjack warehouse"
87
87
  'option-data' =>
88
88
  [
89
89
  dhcp4_option(15, 'domain-name',
90
- interface.parents(kind:'system').first['net.dns.domain'])
90
+ interface.parents(kind: 'system').first['net.dns.domain'])
91
91
  ]
92
92
  }
93
93
  end
data/exe/palletjack2knot CHANGED
@@ -24,7 +24,7 @@ Write DNS server zone files from a Palletjack warehouse"
24
24
 
25
25
  opts.on('-o DIR', '--output DIR', 'output directory', String) {|dir|
26
26
  options[:output] = dir
27
- options[:zone_dir] = config_path(:output, "zones")
27
+ options[:zone_dir] = config_path(:output, 'zones')
28
28
  }
29
29
 
30
30
  required_option :output
@@ -94,7 +94,7 @@ Write DNS server zone files from a Palletjack warehouse"
94
94
  end
95
95
  end
96
96
 
97
- domain.children(kind:'ipv4_interface') do |interface|
97
+ domain.children(kind: 'ipv4_interface') do |interface|
98
98
  a = DNS::Zone::RR::A.new
99
99
  a.label = interface['net.dns.name']
100
100
  a.address = interface['net.ipv4.address']
@@ -113,7 +113,6 @@ Write DNS server zone files from a Palletjack warehouse"
113
113
  @forward_zones[domain['net.dns.domain']] = zone
114
114
  end
115
115
 
116
-
117
116
  # Generate and store reverse zone data for the IPv4 network
118
117
  # associated with a Pallet Jack domain object.
119
118
 
@@ -126,7 +125,7 @@ Write DNS server zone files from a Palletjack warehouse"
126
125
  absolute_reverse_zone_name = IP.new(domain['net.ipv4.cidr']).to_arpa
127
126
 
128
127
  prefix_octets, _ = domain['net.ipv4.prefixlen'].to_i.divmod(8)
129
- zone_file_name = absolute_reverse_zone_name.split('.')[-(2 + prefix_octets) .. 5].join('.')
128
+ zone_file_name = absolute_reverse_zone_name.split('.')[-(2 + prefix_octets)..5].join('.')
130
129
  reverse_zone.origin = zone_file_name + '.'
131
130
 
132
131
  reverse_zone.ttl = domain['net.dns.ttl']
@@ -143,7 +142,7 @@ Write DNS server zone files from a Palletjack warehouse"
143
142
  reverse_zone.records << ns
144
143
  end
145
144
 
146
- domain.children(kind:'ipv4_interface') do |interface|
145
+ domain.children(kind: 'ipv4_interface') do |interface|
147
146
  ptr = DNS::Zone::RR::PTR.new
148
147
  ptr.label = IP.new(interface['net.ipv4.address']).to_arpa
149
148
  ptr.name = "#{interface['net.dns.fqdn']}."
@@ -153,7 +152,6 @@ Write DNS server zone files from a Palletjack warehouse"
153
152
  @reverse_zones[zone_file_name] = reverse_zone
154
153
  end
155
154
 
156
-
157
155
  def process
158
156
  config_dir :zone_dir
159
157
 
@@ -165,13 +163,12 @@ Write DNS server zone files from a Palletjack warehouse"
165
163
  # the same one
166
164
  @serial = Time.now.utc.to_i
167
165
 
168
- jack.each(kind:'domain') do |domain|
166
+ jack.each(kind: 'domain') do |domain|
169
167
  process_forward_zone(domain)
170
168
  process_reverse_zone(domain)
171
169
  end
172
170
  end
173
171
 
174
-
175
172
  def output
176
173
  config_file :output, 'zones.conf' do |conf_file|
177
174
  conf_file << git_header('palletjack2knot')
@@ -51,7 +51,6 @@ require 'palletjack/tool'
51
51
  require 'fileutils'
52
52
 
53
53
  class PalletJack2PXELinux < PalletJack::Tool
54
-
55
54
  def parse_options(opts)
56
55
  opts.banner =
57
56
  "Usage: #{$PROGRAM_NAME} -w <warehouse> -o <output directory>
@@ -67,11 +66,11 @@ Write PXELINUX boot configuration files from a Palletjack warehouse"
67
66
  # Generate pxe menus for each OS configuration
68
67
 
69
68
  def pxemenu_for_netinstall(netinstall)
70
- config=netinstall['host.pxelinux.config']
71
- os_label=netinstall['system.os'].gsub(/-/, ' ')
72
- ks_label=netinstall['host.kickstart.label']
73
- kernel=netinstall['host.pxelinux.kernel']
74
- append=netinstall['host.pxelinux.append']
69
+ config = netinstall['host.pxelinux.config']
70
+ os_label = netinstall['system.os'].gsub(/-/, ' ')
71
+ ks_label = netinstall['host.kickstart.label']
72
+ kernel = netinstall['host.pxelinux.kernel']
73
+ append = netinstall['host.pxelinux.append']
75
74
 
76
75
  config_file :output, 'config', "#{config}.menu" do |menufile|
77
76
  menufile << git_header('palletjack2pxelinux')
@@ -101,10 +100,10 @@ LABEL MainMenu
101
100
  # Generate pxe menus for each OS version
102
101
 
103
102
  def pxemenu_for_operating_system(os)
104
- config=os['host.pxelinux.config']
105
- os_label=config.gsub(/-/, ' ')
106
- kernel=os['host.pxelinux.kernel']
107
- append=os['host.pxelinux.append']
103
+ config = os['host.pxelinux.config']
104
+ os_label = config.gsub(/-/, ' ')
105
+ kernel = os['host.pxelinux.kernel']
106
+ append = os['host.pxelinux.append']
108
107
 
109
108
  config_file :output, 'config', "#{config}.menu" do |menufile|
110
109
  menufile << git_header('palletjack2pxelinux')
@@ -116,11 +115,11 @@ MENU INCLUDE /config/graphics.conf
116
115
  MENU TITLE #{os_label} Installation Menu
117
116
  "
118
117
 
119
- os.descendants(kind:'netinstall') do |netinstall|
120
- next unless ks_label=netinstall['host.kickstart.label']
121
- config=netinstall['host.pxelinux.config']
122
- kernel=netinstall['host.pxelinux.kernel']
123
- append=netinstall['host.pxelinux.append']
118
+ os.descendants(kind: 'netinstall') do |netinstall|
119
+ next unless ks_label = netinstall['host.kickstart.label']
120
+ config = netinstall['host.pxelinux.config']
121
+ kernel = netinstall['host.pxelinux.kernel']
122
+ append = netinstall['host.pxelinux.append']
124
123
 
125
124
  pxemenu_for_netinstall(netinstall)
126
125
 
@@ -155,10 +154,10 @@ MENU INCLUDE /config/graphics.conf
155
154
  MENU TITLE Linux Installation Menu
156
155
  "
157
156
 
158
- jack.each(kind:'os') do |os|
159
- next unless config=os['host.pxelinux.config']
157
+ jack.each(kind: 'os') do |os|
158
+ next unless config = os['host.pxelinux.config']
160
159
 
161
- label=config.gsub(/-/, ' ')
160
+ label = config.gsub(/-/, ' ')
162
161
 
163
162
  pxemenu_for_operating_system(os)
164
163
 
@@ -173,8 +172,8 @@ LABEL #{config}
173
172
 
174
173
  # Generate pxe default menu links for each system
175
174
 
176
- jack.each(kind:'system') do |system|
177
- system.children(kind:'ipv4_interface') do |nic|
175
+ jack.each(kind: 'system') do |system|
176
+ system.children(kind: 'ipv4_interface') do |nic|
178
177
  if system['host.pxelinux.config']
179
178
  menuname = "#{system['host.pxelinux.config']}.menu"
180
179
  linkname = "01-#{nic['net.layer2.address'].gsub(':', '-').downcase}"
data/exe/palletjack2salt CHANGED
@@ -47,7 +47,7 @@ class PalletJack2Salt < PalletJack::Tool
47
47
  Write Salt pillar data from a Palletjack warehouse."
48
48
 
49
49
  opts.on('-g DIR', '--global DIR', 'global pillar directory',
50
- String ) {|dir| options[:global_pillar] = dir }
50
+ String) {|dir| options[:global_pillar] = dir }
51
51
  opts.on('-m DIR', '--minion DIR', 'per-minion pillar directory',
52
52
  String) {|dir| options[:minion_pillar] = dir }
53
53
 
@@ -75,7 +75,7 @@ Write Salt pillar data from a Palletjack warehouse."
75
75
  def ipv4_interfaces(system)
76
76
  result = Hash.new
77
77
 
78
- system.children(kind:'ipv4_interface') do |interface|
78
+ system.children(kind: 'ipv4_interface') do |interface|
79
79
  result[interface['net.layer2.name']] = {
80
80
  interface['net.ipv4.address'] =>
81
81
  interface.filter('net.ipv4', 'net.layer2').to_hash
@@ -88,7 +88,7 @@ Write Salt pillar data from a Palletjack warehouse."
88
88
  def process_minion_pillars
89
89
  result = {}
90
90
 
91
- jack.each(kind:'system') do |system|
91
+ jack.each(kind: 'system') do |system|
92
92
  yaml_output = {}
93
93
  yaml_output['ipv4_interfaces'] = ipv4_interfaces(system)
94
94
 
@@ -18,11 +18,9 @@ require 'ip'
18
18
  require 'resolv'
19
19
 
20
20
  class PalletJack2Unbound < PalletJack::Tool
21
-
22
21
  # Representation of a stub zone configuration for Unbound
23
22
 
24
23
  class StubZone
25
-
26
24
  # :call-seq:
27
25
  # new(TOOL, ZONE, AUTH-NS, ...)
28
26
  # new(TOOL, ZONE, AUTH-NS, ..., transparent: true)
@@ -66,7 +64,7 @@ stub-zone:
66
64
  def initialize(service_name)
67
65
  @tool = PalletJack2Unbound.instance
68
66
  @service_name = service_name
69
- @service_config = @tool.jack.fetch(kind:'service',
67
+ @service_config = @tool.jack.fetch(kind: 'service',
70
68
  parent_name: 'dns-resolver',
71
69
  name: @service_name)
72
70
  end
@@ -76,7 +74,7 @@ stub-zone:
76
74
  def output
77
75
  @tool.config_file :local_dir, "#{@service_name}.conf" do |configfile|
78
76
  configfile << @tool.git_header('palletjack2unbound')
79
- @service_config["service.unbound.server"].each do |config|
77
+ @service_config['service.unbound.server'].each do |config|
80
78
  config.each do |key, value|
81
79
  configfile << "#{key}: #{value}\n"
82
80
  end
@@ -126,7 +124,7 @@ E.g.
126
124
  def process_stub_zones
127
125
  @stub_zones = []
128
126
 
129
- jack.each(kind:'domain') do |domain|
127
+ jack.each(kind: 'domain') do |domain|
130
128
  zone = domain['net.dns.domain']
131
129
  stub_addrs = []
132
130
 
@@ -135,8 +133,8 @@ E.g.
135
133
  nsname =
136
134
  Resolv::DNS::Name.create("#{ns}.#{zone}.") unless nsname.absolute?
137
135
 
138
- jack.each(kind:'ipv4_interface',
139
- all?:{'net.dns.fqdn' => nsname.to_s}) do |ipv4|
136
+ jack.each(kind: 'ipv4_interface',
137
+ all?: {'net.dns.fqdn' => nsname.to_s}) do |ipv4|
140
138
  stub_addrs << ipv4['net.ipv4.address']
141
139
  end
142
140
  end
@@ -152,7 +150,7 @@ E.g.
152
150
  reverse_zone = ip_net.to_arpa
153
151
  prefix_octets, _ = domain['net.ipv4.prefixlen'].to_i.divmod(8)
154
152
  reverse_zone =
155
- ip_net.to_arpa.split('.')[-(2 + prefix_octets) .. 5].join('.')
153
+ ip_net.to_arpa.split('.')[-(2 + prefix_octets)..5].join('.')
156
154
 
157
155
  # Make the same assumption that palletjack2knot does;
158
156
  # reverse delegations are made to the same nameserver
@@ -14,10 +14,10 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = 'https://github.com/saab-simc-admin/palletjack'
15
15
  spec.license = 'MIT'
16
16
 
17
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
18
  f.match(%r{^(test|spec|features)/})
19
19
  end
20
- spec.bindir = "exe"
20
+ spec.bindir = 'exe'
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
 
23
23
  spec.platform = Gem::Platform::RUBY
@@ -27,11 +27,11 @@ Gem::Specification.new do |spec|
27
27
  spec.add_runtime_dependency 'dns-zone', '~> 0.3'
28
28
  spec.add_runtime_dependency 'ruby-ip', '~> 0.9'
29
29
 
30
- spec.add_development_dependency "bundler", "~> 1.13"
31
- spec.add_development_dependency "rake", "~> 10.0"
32
- spec.add_development_dependency "rspec", "~> 3.0"
33
- spec.add_development_dependency "rspec_structure_matcher", "~> 0.0.6"
34
- spec.add_development_dependency "rspec-collection_matchers", "~> 1.1.2"
30
+ spec.add_development_dependency 'bundler', '~> 1.13'
31
+ spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'rspec', '~> 3.0'
33
+ spec.add_development_dependency 'rspec_structure_matcher', '~> 0.0.6'
34
+ spec.add_development_dependency 'rspec-collection_matchers', '~> 1.1.2'
35
35
 
36
36
  spec.has_rdoc = true
37
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: palletjack-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl-Johan Karlsson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  f8wtQllq82VF0AXUYeLtTh1f+DW3WW5BO1e2OCu5eOV7dbyaVPaNK/+rHjCN8kM/
32
32
  DGZSwUoNADmVkQ==
33
33
  -----END CERTIFICATE-----
34
- date: 2016-11-30 00:00:00.000000000 Z
34
+ date: 2017-01-30 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: palletjack
@@ -39,14 +39,14 @@ dependencies:
39
39
  requirements:
40
40
  - - '='
41
41
  - !ruby/object:Gem::Version
42
- version: 0.4.1
42
+ version: 0.5.0
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - '='
48
48
  - !ruby/object:Gem::Version
49
- version: 0.4.1
49
+ version: 0.5.0
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: dns-zone
52
52
  requirement: !ruby/object:Gem::Requirement
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  requirements: []
195
195
  rubyforge_project:
196
- rubygems_version: 2.0.14
196
+ rubygems_version: 2.0.14.1
197
197
  signing_key:
198
198
  specification_version: 4
199
199
  summary: Tools for the Pallet Jack Lightweight Configuration Management Database
metadata.gz.sig CHANGED
Binary file