puppetmodule-netdev_stdlib 0.10.0

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.
Files changed (66) hide show
  1. data/.gitignore +27 -0
  2. data/.travis.yml +9 -0
  3. data/Gemfile +4 -0
  4. data/Guardfile +15 -0
  5. data/LICENSE +202 -0
  6. data/Modulefile +9 -0
  7. data/README.md +330 -0
  8. data/Rakefile +1 -0
  9. data/lib/netdev_stdlib.rb +4 -0
  10. data/lib/netdev_stdlib/version.rb +3 -0
  11. data/lib/puppet/type/domain_name.rb +17 -0
  12. data/lib/puppet/type/name_server.rb +17 -0
  13. data/lib/puppet/type/network_interface.rb +60 -0
  14. data/lib/puppet/type/network_trunk.rb +83 -0
  15. data/lib/puppet/type/network_vlan.rb +53 -0
  16. data/lib/puppet/type/ntp_config.rb +25 -0
  17. data/lib/puppet/type/ntp_server.rb +20 -0
  18. data/lib/puppet/type/port_channel.rb +82 -0
  19. data/lib/puppet/type/radius.rb +20 -0
  20. data/lib/puppet/type/radius_global.rb +40 -0
  21. data/lib/puppet/type/radius_server.rb +95 -0
  22. data/lib/puppet/type/radius_server_group.rb +25 -0
  23. data/lib/puppet/type/search_domain.rb +17 -0
  24. data/lib/puppet/type/snmp_community.rb +29 -0
  25. data/lib/puppet/type/snmp_contact.rb +17 -0
  26. data/lib/puppet/type/snmp_location.rb +17 -0
  27. data/lib/puppet/type/snmp_notification.rb +20 -0
  28. data/lib/puppet/type/snmp_notification_receiver.rb +77 -0
  29. data/lib/puppet/type/snmp_protocol.rb +20 -0
  30. data/lib/puppet/type/snmp_user.rb +77 -0
  31. data/lib/puppet/type/syslog_server.rb +42 -0
  32. data/lib/puppet/type/syslog_settings.rb +25 -0
  33. data/lib/puppet/type/tacacs.rb +20 -0
  34. data/lib/puppet/type/tacacs_global.rb +40 -0
  35. data/lib/puppet/type/tacacs_server.rb +50 -0
  36. data/lib/puppet/type/tacacs_server_group.rb +25 -0
  37. data/netdev_stdlib.gemspec +36 -0
  38. data/spec/spec_helper.rb +15 -0
  39. data/spec/support/shared_examples_for_types.rb +412 -0
  40. data/spec/unit/puppet/type/domain_name_spec.rb +8 -0
  41. data/spec/unit/puppet/type/name_server_spec.rb +8 -0
  42. data/spec/unit/puppet/type/network_interface_spec.rb +44 -0
  43. data/spec/unit/puppet/type/network_trunk_spec.rb +55 -0
  44. data/spec/unit/puppet/type/network_vlan_spec.rb +57 -0
  45. data/spec/unit/puppet/type/ntp_config_spec.rb +8 -0
  46. data/spec/unit/puppet/type/ntp_server_spec.rb +8 -0
  47. data/spec/unit/puppet/type/port_channel_spec.rb +87 -0
  48. data/spec/unit/puppet/type/radius_global_spec.rb +27 -0
  49. data/spec/unit/puppet/type/radius_server_group_spec.rb +12 -0
  50. data/spec/unit/puppet/type/radius_server_spec.rb +51 -0
  51. data/spec/unit/puppet/type/radius_spec.rb +8 -0
  52. data/spec/unit/puppet/type/search_domain_spec.rb +8 -0
  53. data/spec/unit/puppet/type/snmp_community_spec.rb +27 -0
  54. data/spec/unit/puppet/type/snmp_contact_spec.rb +8 -0
  55. data/spec/unit/puppet/type/snmp_location_spec.rb +8 -0
  56. data/spec/unit/puppet/type/snmp_notification_receiver_spec.rb +50 -0
  57. data/spec/unit/puppet/type/snmp_notification_spec.rb +8 -0
  58. data/spec/unit/puppet/type/snmp_protocol_spec.rb +8 -0
  59. data/spec/unit/puppet/type/snmp_user_spec.rb +63 -0
  60. data/spec/unit/puppet/type/syslog_server_spec.rb +20 -0
  61. data/spec/unit/puppet/type/syslog_settings_spec.rb +19 -0
  62. data/spec/unit/puppet/type/tacacs_global_spec.rb +27 -0
  63. data/spec/unit/puppet/type/tacacs_server_group_spec.rb +12 -0
  64. data/spec/unit/puppet/type/tacacs_server_spec.rb +25 -0
  65. data/spec/unit/puppet/type/tacacs_spec.rb +8 -0
  66. metadata +338 -0
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,4 @@
1
+ require "netdev_stdlib/version"
2
+
3
+ module NetdevStdlib
4
+ end
@@ -0,0 +1,3 @@
1
+ module NetdevStdlib
2
+ VERSION = '0.10.0'
3
+ end
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ Puppet::Type.newtype(:domain_name) do
4
+ @doc = 'Configure the domain name of the device'
5
+
6
+ ensurable
7
+
8
+ newparam(:name, namevar: true) do
9
+ desc 'The domain name of the device'
10
+
11
+ validate do |value|
12
+ if value.is_a? String then super(value)
13
+ else fail "value #{value.inspect} is invalid, must be a String."
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ Puppet::Type.newtype(:name_server) do
4
+ @doc = 'Configure the resolver to use the specified DNS server'
5
+
6
+ ensurable
7
+
8
+ newparam(:name, namevar: true) do
9
+ desc 'The hostname or address of the DNS server'
10
+
11
+ validate do |value|
12
+ if value.is_a? String then super(value)
13
+ else fail "value #{value.inspect} is invalid, must be a String."
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,60 @@
1
+ # encoding: utf-8
2
+
3
+ Puppet::Type.newtype(:network_interface) do
4
+ @doc = 'Manage physical network interfaces, e.g. Ethernet1'
5
+
6
+ newproperty(:enable) do
7
+ desc 'Enable the interface, true or false'
8
+ newvalues(:true, :false)
9
+ end
10
+
11
+ # Parameters (additional data)
12
+
13
+ newparam(:name, namevar: true) do
14
+ desc 'Interface Name, e.g. Ethernet1'
15
+
16
+ validate do |value|
17
+ case value
18
+ when String then super(value)
19
+ else fail "value #{value.inspect} is invalid, must be a String."
20
+ end
21
+ end
22
+ end
23
+
24
+ # Properties (state)
25
+
26
+ newproperty(:description) do
27
+ desc 'Interface physical port description'
28
+
29
+ validate do |value|
30
+ case value
31
+ when String
32
+ super(value)
33
+ validate_features_per_value(value)
34
+ else fail "value #{value.inspect} is invalid, must be a string."
35
+ end
36
+ end
37
+ end
38
+
39
+ newproperty(:mtu) do
40
+ desc 'Interface Maximum Transmission Unit in bytes'
41
+ munge { |v| Integer(v) }
42
+ validate do |v|
43
+ begin
44
+ Integer(v) ? true : false
45
+ rescue TypeError => err
46
+ error "Cannot convert #{v.inspect} to an integer: #{err.message}"
47
+ end
48
+ end
49
+ end
50
+
51
+ newproperty(:speed) do
52
+ desc 'Link speed [auto*|10m|100m|1g|10g|40g|56g|100g]'
53
+ newvalues(:auto, '1g', '10g', '40g', '56g', '100g', '100m', '10m')
54
+ end
55
+
56
+ newproperty(:duplex) do
57
+ desc 'Duplex mode [auto*|full|half]'
58
+ newvalues(:auto, :full, :half)
59
+ end
60
+ end
@@ -0,0 +1,83 @@
1
+ # encoding: utf-8
2
+ # rubocop:disable Style/PredicateName
3
+
4
+ Puppet::Type.newtype(:network_trunk) do
5
+ @doc = 'Ethernet logical (switch-port) interface. Configures VLAN trunking.'
6
+
7
+ ensurable
8
+
9
+ newparam(:name, namevar: true) do
10
+ desc 'The switch interface name, e.g. "Ethernet1"'
11
+
12
+ validate do |value|
13
+ case value
14
+ when String then super(value)
15
+ else fail "value #{value.inspect} is invalid, must be a String."
16
+ end
17
+ end
18
+ end
19
+
20
+ newproperty(:encapsulation) do
21
+ desc 'The vlan-tagging encapsulation protocol, usually dot1q'
22
+ newvalues(:dot1q, :isl, :negotiate, :none)
23
+ end
24
+
25
+ newproperty(:mode) do
26
+ desc 'The L2 interface mode, enables or disables trunking'
27
+ newvalues(:access, :trunk, :dynamic_auto, :dynamic_desirable)
28
+ end
29
+
30
+ newproperty(:untagged_vlan) do
31
+ desc 'VLAN used for untagged VLAN traffic. a.k.a Native VLAN'
32
+
33
+ validate do |value|
34
+ unless value.between?(1, 4095)
35
+ fail "value #{value.inspect} is not between 1 and 4095"
36
+ end
37
+ end
38
+ end
39
+
40
+ newproperty(:tagged_vlans, array_matching: :all) do
41
+ desc 'Array of VLAN names used for tagged packets'
42
+
43
+ validate do |value|
44
+ unless value.between?(1, 4095)
45
+ fail "value #{value.inspect} is not between 1 and 4095"
46
+ end
47
+ end
48
+
49
+ def insync?(is)
50
+ is.sort == @should.sort.map(&:to_s)
51
+ end
52
+
53
+ def should_to_s(val)
54
+ "[#{[*val].join(',')}]"
55
+ end
56
+
57
+ def is_to_s(val)
58
+ "[#{[*val].join(',')}]"
59
+ end
60
+ end
61
+
62
+ newproperty(:pruned_vlans, array_matching: :all) do
63
+ desc 'Array of VLAN ID numbers used for VLAN pruning'
64
+
65
+ validate do |value|
66
+ unless value.between?(1, 4095)
67
+ fail "value #{value.inspect} is not between 1 and 4095"
68
+ end
69
+ end
70
+
71
+ def insync?(is)
72
+ is.sort == @should.sort.map(&:to_s)
73
+ end
74
+
75
+ def should_to_s(val)
76
+ "[#{[*val].join(',')}]"
77
+ end
78
+
79
+ def is_to_s(val)
80
+ "[#{[*val].join(',')}]"
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ Puppet::Type.newtype(:network_vlan) do
4
+ @doc = "Manage VLAN's. Layer-2 VLAN's are managed by this resource type."
5
+
6
+ ensurable
7
+
8
+ feature :describable, 'The ability to add a description to a VLAN.'
9
+
10
+ # Parameters
11
+
12
+ newparam(:id, namevar: true) do
13
+ desc 'The VLAN ID, e.g. 100'
14
+
15
+ # Make sure we have a string for the ID
16
+ munge do |value|
17
+ Integer(value).to_s
18
+ end
19
+ end
20
+
21
+ # Properties (state management)
22
+
23
+ newproperty(:vlan_name) do
24
+ desc 'The VLAN name, e.g. VLAN100'
25
+
26
+ validate do |value|
27
+ case value
28
+ when String
29
+ super(value)
30
+ validate_features_per_value(value)
31
+ else fail "value #{value.inspect} is invalid, must be a string."
32
+ end
33
+ end
34
+ end
35
+
36
+ newproperty(:shutdown) do
37
+ desc 'VLAN shutdown if true, not shutdown if false'
38
+ newvalues(:true, :false)
39
+ end
40
+
41
+ newproperty(:description, required_features: ['describable']) do
42
+ desc "The VLAN Description, e.g. 'Engineering'"
43
+
44
+ validate do |value|
45
+ case value
46
+ when String
47
+ super(value)
48
+ validate_features_per_value(value)
49
+ else fail "value #{value.inspect} is invalid, must be a string."
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ Puppet::Type.newtype(:ntp_config) do
4
+ @doc = 'Global configuration for the NTP system'
5
+
6
+ newparam(:name, namevar: true) do
7
+ desc 'Resource name, not used to configure the device'
8
+
9
+ validate do |value|
10
+ if value.is_a? String then super(value)
11
+ else fail "value #{value.inspect} is invalid, must be a String."
12
+ end
13
+ end
14
+ end
15
+
16
+ newproperty(:source_interface) do
17
+ desc 'The source interface for the NTP system'
18
+
19
+ validate do |value|
20
+ if value.is_a? String then super(value)
21
+ else fail "value #{value.inspect} is invalid, must be a String."
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ Puppet::Type.newtype(:ntp_server) do
4
+ @doc = 'Specify an NTP server'
5
+
6
+ newparam(:name, namevar: true) do
7
+ desc 'The hostname or address of the NTP server'
8
+
9
+ validate do |value|
10
+ if value.is_a? String then super(value)
11
+ else fail "value #{value.inspect} is invalid, must be a String."
12
+ end
13
+ end
14
+ end
15
+
16
+ newproperty(:prefer) do
17
+ desc 'Prefer this NTP server [true|false]'
18
+ newvalues(:true, :false)
19
+ end
20
+ end
@@ -0,0 +1,82 @@
1
+ # encoding: utf-8
2
+
3
+ Puppet::Type.newtype(:port_channel) do
4
+ @doc = 'Network Device Link Aggregation Group'
5
+
6
+ ensurable
7
+
8
+ newparam(:name, namevar: true) do
9
+ desc 'LAG Name'
10
+
11
+ validate do |value|
12
+ case value
13
+ when String then super(value)
14
+ else fail "value #{value.inspect} is invalid, must be a String."
15
+ end
16
+ end
17
+ end
18
+
19
+ newparam(:force) do
20
+ desc 'Force configuration (true / false)'
21
+ newvalues(:true, :false)
22
+ end
23
+
24
+ newproperty(:id) do
25
+ desc 'Channel Group ID, e.g. 10'
26
+ munge { |v| Integer(v) }
27
+ end
28
+
29
+ newproperty(:description) do
30
+ desc 'Port Channel description'
31
+
32
+ validate do |value|
33
+ if value.is_a? String
34
+ super(value)
35
+ validate_features_per_value(value)
36
+ else fail "value #{value.inspect} is invalid, must be a string."
37
+ end
38
+ end
39
+ end
40
+
41
+ newproperty(:mode) do
42
+ desc 'LACP mode [ passive | active | disabled* ]'
43
+ newvalues(:active, :passive, :disabled)
44
+ end
45
+
46
+ newproperty(:minimum_links) do
47
+ desc 'Number of active links required for LAG to be up'
48
+ munge { |v| Integer(v) }
49
+ end
50
+
51
+ newproperty(:interfaces, array_matching: :all) do
52
+ desc 'Array of Physical Interfaces'
53
+
54
+ validate do |val|
55
+ fail "value #{val.inspect} must be a string" unless val.is_a? String
56
+ fail "value #{val.inspect} has no digits" unless /\d+/.match(val)
57
+ end
58
+
59
+ def insync?(is)
60
+ is.sort == @should.sort.map(&:to_s)
61
+ end
62
+ end
63
+
64
+ newproperty(:speed) do
65
+ desc 'Link speed [auto*|10m|100m|1g|10g|40g|56g|100g]'
66
+ newvalues(:auto, '1g', '10g', '40g', '56g', '100g', '100m', '10m')
67
+ end
68
+
69
+ newproperty(:duplex) do
70
+ desc 'Duplex mode [auto*|full|half]'
71
+ newvalues(:auto, :full, :half)
72
+ end
73
+
74
+ newproperty(:flowcontrol_send) do
75
+ desc 'Flow control (send) [desired|on|off]'
76
+ newvalues(:desired, :on, :off)
77
+ end
78
+ newproperty(:flowcontrol_receive) do
79
+ desc 'Flow control (receive) [desired|on|off]'
80
+ newvalues(:desired, :on, :off)
81
+ end
82
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ Puppet::Type.newtype(:radius) do
4
+ @doc = 'Enable or disable radius functionality'
5
+
6
+ newparam(:name, namevar: true) do
7
+ desc 'Resource name, not used to manage the device'
8
+
9
+ validate do |value|
10
+ if value.is_a? String then super(value)
11
+ else fail "value #{value.inspect} is invalid, must be a String."
12
+ end
13
+ end
14
+ end
15
+
16
+ newproperty(:enable) do
17
+ desc 'Enable or disable radius functionality [true|false]'
18
+ newvalues(:true, :false)
19
+ end
20
+ end
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ Puppet::Type.newtype(:radius_global) do
4
+ @doc = 'Configure global radius settings'
5
+
6
+ newparam(:name, namevar: true) do
7
+ desc 'Resource identifier, not used to manage the device'
8
+
9
+ validate do |value|
10
+ if value.is_a? String then super(value)
11
+ else fail "value #{value.inspect} is invalid, must be a String."
12
+ end
13
+ end
14
+ end
15
+
16
+ newproperty(:key) do
17
+ desc 'Encryption key (plaintext or in hash form depending on key_format)'
18
+
19
+ validate do |value|
20
+ if value.is_a? String then super(value)
21
+ else fail "value #{value.inspect} is invalid, must be a String."
22
+ end
23
+ end
24
+ end
25
+
26
+ newproperty(:key_format) do
27
+ desc 'Encryption key format [0-7]'
28
+ munge { |v| Integer(v) }
29
+ end
30
+
31
+ newproperty(:timeout) do
32
+ desc 'Number of seconds before the timeout period ends'
33
+ munge { |v| Integer(v) }
34
+ end
35
+
36
+ newproperty(:retransmit_count) do
37
+ desc 'How many times to retransmit'
38
+ munge { |v| Integer(v) }
39
+ end
40
+ end
@@ -0,0 +1,95 @@
1
+ # encoding: utf-8
2
+
3
+ Puppet::Type.newtype(:radius_server) do
4
+ @doc = 'Configure a radius server'
5
+
6
+ newparam(:name, namevar: true) do
7
+ desc 'The name of the radius server group'
8
+
9
+ validate do |value|
10
+ if value.is_a? String then super(value)
11
+ else fail "value #{value.inspect} is invalid, must be a String."
12
+ end
13
+ end
14
+ end
15
+
16
+ newproperty(:key) do
17
+ desc 'Encryption key (plaintext or in hash form depending on key_format)'
18
+
19
+ validate do |value|
20
+ if value.is_a? String then super(value)
21
+ else fail "value #{value.inspect} is invalid, must be a String."
22
+ end
23
+ end
24
+ end
25
+
26
+ newproperty(:key_format) do
27
+ desc 'Encryption key format [0-7]'
28
+ munge { |v| Integer(v) }
29
+ end
30
+
31
+ newproperty(:group) do
32
+ desc 'Server group associated with this server'
33
+
34
+ validate do |value|
35
+ if value.is_a? String then super(value)
36
+ else fail "value #{value.inspect} is invalid, must be a String."
37
+ end
38
+ end
39
+ end
40
+
41
+ newproperty(:deadtime) do
42
+ desc 'Number of minutes to ignore an unresponsive server'
43
+ munge { |v| Integer(v) }
44
+ end
45
+
46
+ newproperty(:timeout) do
47
+ desc 'Number of seconds before the timeout period ends'
48
+ munge { |v| Integer(v) }
49
+ end
50
+
51
+ newproperty(:vrf) do
52
+ desc 'Interface to send syslog data from, e.g. "management"'
53
+
54
+ validate do |value|
55
+ if value.is_a? String then super(value)
56
+ else fail "value #{value.inspect} is invalid, must be a String."
57
+ end
58
+ end
59
+ end
60
+
61
+ newproperty(:source_interface) do
62
+ desc 'Source interface to send syslog data from, e.g. "ethernet 2/1"'
63
+
64
+ validate do |value|
65
+ if value.is_a? String then super(value)
66
+ else fail "value #{value.inspect} is invalid, must be a String."
67
+ end
68
+ end
69
+ end
70
+
71
+ newproperty(:retransmit_count) do
72
+ desc 'How many times to retransmit'
73
+ munge { |v| Integer(v) }
74
+ end
75
+
76
+ newproperty(:acct_port) do
77
+ desc 'Port number to use for accounting'
78
+ munge { |v| Integer(v) }
79
+ end
80
+
81
+ newproperty(:accounting_only) do
82
+ desc 'Enable this server for accounting only'
83
+ newvalues(:true, :false)
84
+ end
85
+
86
+ newproperty(:auth_port) do
87
+ desc 'Port number to use for accounting'
88
+ munge { |v| Integer(v) }
89
+ end
90
+
91
+ newproperty(:authentication_only) do
92
+ desc 'Enable this server for authentication only'
93
+ newvalues(:true, :false)
94
+ end
95
+ end