bolt 0.21.7 → 0.21.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bolt might be problematic. Click here for more details.

Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bolt/transport/ssh/connection.rb +4 -5
  3. data/lib/bolt/transport/ssh.rb +4 -1
  4. data/lib/bolt/transport/winrm/connection.rb +3 -4
  5. data/lib/bolt/transport/winrm.rb +4 -1
  6. data/lib/bolt/version.rb +1 -1
  7. data/libexec/apply_catalog.rb +10 -2
  8. data/vendored/puppet/lib/puppet/application/apply.rb +20 -9
  9. data/vendored/puppet/lib/puppet/application/cert.rb +3 -1
  10. data/vendored/puppet/lib/puppet/application/device.rb +22 -5
  11. data/vendored/puppet/lib/puppet/configurer/fact_handler.rb +5 -1
  12. data/vendored/puppet/lib/puppet/configurer.rb +15 -2
  13. data/vendored/puppet/lib/puppet/defaults.rb +36 -25
  14. data/vendored/puppet/lib/puppet/face/certificate.rb +2 -0
  15. data/vendored/puppet/lib/puppet/feature/base.rb +0 -3
  16. data/vendored/puppet/lib/puppet/functions/call.rb +37 -0
  17. data/vendored/puppet/lib/puppet/functions.rb +5 -0
  18. data/vendored/puppet/lib/puppet/indirector/ldap.rb +6 -0
  19. data/vendored/puppet/lib/puppet/node/environment.rb +4 -2
  20. data/vendored/puppet/lib/puppet/parser/scope.rb +2 -2
  21. data/vendored/puppet/lib/puppet/pops/adapters.rb +14 -0
  22. data/vendored/puppet/lib/puppet/pops/evaluator/deferred_resolver.rb +128 -0
  23. data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +4 -1
  24. data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +2 -0
  25. data/vendored/puppet/lib/puppet/pops/issues.rb +9 -1
  26. data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +0 -16
  27. data/vendored/puppet/lib/puppet/pops/loaders.rb +1 -3
  28. data/vendored/puppet/lib/puppet/pops/parser/eparser.rb +6 -6
  29. data/vendored/puppet/lib/puppet/pops/pcore.rb +11 -0
  30. data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +17 -0
  31. data/vendored/puppet/lib/puppet/pops/validation/tasks_checker.rb +13 -5
  32. data/vendored/puppet/lib/puppet/pops.rb +1 -0
  33. data/vendored/puppet/lib/puppet/provider/service/debian.rb +1 -0
  34. data/vendored/puppet/lib/puppet/provider/service/smf.rb +2 -3
  35. data/vendored/puppet/lib/puppet/provider/service/upstart.rb +10 -2
  36. data/vendored/puppet/lib/puppet/ssl/certificate_authority.rb +6 -84
  37. data/vendored/puppet/lib/puppet/ssl/certificate_request.rb +11 -3
  38. data/vendored/puppet/lib/puppet/type/file.rb +3 -0
  39. data/vendored/puppet/lib/puppet/type/user.rb +17 -3
  40. data/vendored/puppet/lib/puppet/util/autoload.rb +36 -31
  41. data/vendored/puppet/lib/puppet/util.rb +2 -0
  42. metadata +3 -43
  43. data/vendored/puppet/lib/puppet/indirector/node/write_only_yaml.rb +0 -39
  44. data/vendored/puppet/lib/puppet/provider/augeas/augeas.rb +0 -573
  45. data/vendored/puppet/lib/puppet/provider/cisco.rb +0 -9
  46. data/vendored/puppet/lib/puppet/provider/computer/computer.rb +0 -20
  47. data/vendored/puppet/lib/puppet/provider/host/parsed.rb +0 -46
  48. data/vendored/puppet/lib/puppet/provider/interface/cisco.rb +0 -27
  49. data/vendored/puppet/lib/puppet/provider/macauthorization/macauthorization.rb +0 -298
  50. data/vendored/puppet/lib/puppet/provider/mcx/mcxcontent.rb +0 -173
  51. data/vendored/puppet/lib/puppet/provider/mount/parsed.rb +0 -282
  52. data/vendored/puppet/lib/puppet/provider/mount.rb +0 -76
  53. data/vendored/puppet/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +0 -590
  54. data/vendored/puppet/lib/puppet/provider/selboolean/getsetsebool.rb +0 -47
  55. data/vendored/puppet/lib/puppet/provider/selmodule/semodule.rb +0 -140
  56. data/vendored/puppet/lib/puppet/provider/ssh_authorized_key/parsed.rb +0 -105
  57. data/vendored/puppet/lib/puppet/provider/sshkey/parsed.rb +0 -50
  58. data/vendored/puppet/lib/puppet/provider/vlan/cisco.rb +0 -28
  59. data/vendored/puppet/lib/puppet/provider/yumrepo/inifile.rb +0 -315
  60. data/vendored/puppet/lib/puppet/type/augeas.rb +0 -211
  61. data/vendored/puppet/lib/puppet/type/computer.rb +0 -66
  62. data/vendored/puppet/lib/puppet/type/host.rb +0 -95
  63. data/vendored/puppet/lib/puppet/type/interface.rb +0 -121
  64. data/vendored/puppet/lib/puppet/type/k5login.rb +0 -165
  65. data/vendored/puppet/lib/puppet/type/macauthorization.rb +0 -167
  66. data/vendored/puppet/lib/puppet/type/mcx.rb +0 -98
  67. data/vendored/puppet/lib/puppet/type/mount.rb +0 -314
  68. data/vendored/puppet/lib/puppet/type/router.rb +0 -17
  69. data/vendored/puppet/lib/puppet/type/scheduled_task.rb +0 -183
  70. data/vendored/puppet/lib/puppet/type/selboolean.rb +0 -26
  71. data/vendored/puppet/lib/puppet/type/selmodule.rb +0 -59
  72. data/vendored/puppet/lib/puppet/type/ssh_authorized_key.rb +0 -143
  73. data/vendored/puppet/lib/puppet/type/sshkey.rb +0 -83
  74. data/vendored/puppet/lib/puppet/type/vlan.rb +0 -26
  75. data/vendored/puppet/lib/puppet/type/yumrepo.rb +0 -430
  76. data/vendored/puppet/lib/puppet/util/network_device/cisco/device.rb +0 -285
  77. data/vendored/puppet/lib/puppet/util/network_device/cisco/facts.rb +0 -72
  78. data/vendored/puppet/lib/puppet/util/network_device/cisco/interface.rb +0 -94
  79. data/vendored/puppet/lib/puppet/util/network_device/cisco.rb +0 -4
  80. data/vendored/puppet/lib/puppet/util/network_device/ipcalc.rb +0 -68
  81. data/vendored/puppet/lib/puppet/util/network_device/transport/ssh.rb +0 -126
  82. data/vendored/puppet/lib/puppet/util/network_device/transport/telnet.rb +0 -47
  83. data/vendored/puppet/lib/puppet/util/windows/taskscheduler.rb +0 -1267
@@ -1,72 +0,0 @@
1
-
2
- require 'puppet/util/network_device/cisco'
3
- require 'puppet/util/network_device/ipcalc'
4
-
5
- # this retrieves facts from a cisco device
6
- class Puppet::Util::NetworkDevice::Cisco::Facts
7
-
8
- attr_reader :transport
9
-
10
- def initialize(transport)
11
- @transport = transport
12
- end
13
-
14
- def retrieve
15
- facts = {}
16
- facts.merge(parse_show_ver)
17
- end
18
-
19
- def parse_show_ver
20
- facts = {}
21
- out = @transport.command("sh ver")
22
- lines = out.split("\n")
23
- lines.shift; lines.pop
24
- lines.each do |l|
25
- case l
26
- # cisco WS-C2924C-XL (PowerPC403GA) processor (revision 0x11) with 8192K/1024K bytes of memory.
27
- # Cisco 1841 (revision 5.0) with 355328K/37888K bytes of memory.
28
- # Cisco 877 (MPC8272) processor (revision 0x200) with 118784K/12288K bytes of memory.
29
- # cisco WS-C2960G-48TC-L (PowerPC405) processor (revision C0) with 61440K/4088K bytes of memory.
30
- # cisco WS-C2950T-24 (RC32300) processor (revision R0) with 19959K bytes of memory.
31
- when /[cC]isco ([\w-]+) (?:\(([\w-]+)\) processor )?\(revision (.+)\) with (\d+[KMG])(?:\/(\d+[KMG]))? bytes of memory\./
32
- facts[:hardwaremodel] = $1
33
- facts[:processor] = $2 if $2
34
- facts[:hardwarerevision] = $3
35
- facts[:memorysize] = $4
36
- # uptime
37
- # Switch uptime is 1 year, 12 weeks, 6 days, 22 hours, 32 minutes
38
- # c2950 uptime is 3 weeks, 1 day, 23 hours, 36 minutes
39
- # c2960 uptime is 2 years, 27 weeks, 5 days, 21 hours, 30 minutes
40
- # router uptime is 5 weeks, 1 day, 3 hours, 30 minutes
41
- when /^\s*([\w-]+)\s+uptime is (.*?)$/
42
- facts[:hostname] = $1
43
- facts[:uptime] = $2
44
- facts[:uptime_seconds] = uptime_to_seconds($2)
45
- facts[:uptime_days] = facts[:uptime_seconds] / 86400
46
- # "IOS (tm) C2900XL Software (C2900XL-C3H2S-M), Version 12.0(5)WC10, RELEASE SOFTWARE (fc1)"=> { :operatingsystem => "IOS", :operatingsystemrelease => "12.0(5)WC10", :operatingsystemmajrelease => "12.0", :operatingsystemfeature => "C3H2S"},
47
- # "IOS (tm) C2950 Software (C2950-I6K2L2Q4-M), Version 12.1(22)EA8a, RELEASE SOFTWARE (fc1)"=> { :operatingsystem => "IOS", :operatingsystemrelease => "12.1(22)EA8a", :operatingsystemmajrelease => "12.1", :operatingsystemfeature => "I6K2L2Q4"},
48
- # "Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 12.2(44)SE, RELEASE SOFTWARE (fc1)"=>{ :operatingsystem => "IOS", :operatingsystemrelease => "12.2(44)SE", :operatingsystemmajrelease => "12.2", :operatingsystemfeature => "LANBASEK9"},
49
- # "Cisco IOS Software, C870 Software (C870-ADVIPSERVICESK9-M), Version 12.4(11)XJ4, RELEASE SOFTWARE (fc2)"=>{ :operatingsystem => "IOS", :operatingsystemrelease => "12.4(11)XJ40", :operatingsystemmajrelease => "12.4XJ", :operatingsystemfeature => "ADVIPSERVICESK9"},
50
- # "Cisco IOS Software, 1841 Software (C1841-ADVSECURITYK9-M), Version 12.4(24)T4, RELEASE SOFTWARE (fc2)" =>{ :operatingsystem => "IOS", :operatingsystemrelease => "12.4(24)T4", :operatingsystemmajrelease => "12.4T", :operatingsystemfeature => "ADVSECURITYK9"},
51
- when /(?:Cisco )?(IOS)\s*(?:\(tm\) |Software, )?(?:\w+)\s+Software\s+\(\w+-(\w+)-\w+\), Version ([0-9.()A-Za-z]+),/
52
- facts[:operatingsystem] = $1
53
- facts[:operatingsystemrelease] = $3
54
- facts[:operatingsystemmajrelease] = ios_major_version(facts[:operatingsystemrelease])
55
- facts[:operatingsystemfeature] = $2
56
- end
57
- end
58
- facts
59
- end
60
-
61
- def ios_major_version(version)
62
- version.gsub(/^(\d+)\.(\d+)\(.+\)([A-Z]+)([\da-z]+)?/, '\1.\2\3')
63
- end
64
-
65
- def uptime_to_seconds(uptime)
66
- captures = (uptime.match(/^(?:(\d+) years?,)?\s*(?:(\d+) weeks?,)?\s*(?:(\d+) days?,)?\s*(?:(\d+) hours?,)?\s*(\d+) minutes?$/)).captures
67
- captures.zip([31536000, 604800, 86400, 3600, 60]).inject(0) do |total, (x,y)|
68
- total + (x.nil? ? 0 : x.to_i * y)
69
- end
70
- end
71
-
72
- end
@@ -1,94 +0,0 @@
1
- require 'puppet/util/network_device/cisco'
2
- require 'puppet/util/network_device/ipcalc'
3
-
4
- # this manages setting properties to an interface in a cisco switch or router
5
- class Puppet::Util::NetworkDevice::Cisco::Interface
6
-
7
- include Puppet::Util::NetworkDevice::IPCalc
8
- extend Puppet::Util::NetworkDevice::IPCalc
9
-
10
- attr_reader :transport, :name
11
-
12
- def initialize(name, transport)
13
- @name = name
14
- @transport = transport
15
- end
16
-
17
- COMMANDS = {
18
- # property => order, ios command/block/array
19
- :description => [1, "description %s"],
20
- :speed => [2, "speed %s"],
21
- :duplex => [3, "duplex %s"],
22
- :encapsulation => [4, "switchport trunk encapsulation %s"],
23
- :mode => [5, "switchport mode %s"],
24
- :access_vlan => [6, "switchport access vlan %s"],
25
- :native_vlan => [7, "switchport trunk native vlan %s"],
26
- :allowed_trunk_vlans => [8, "switchport trunk allowed vlan %s"],
27
- :etherchannel => [9, ["channel-group %s", "port group %s"]],
28
- :ipaddress => [10,
29
- lambda do |prefix,ip,option|
30
- ip.ipv6? ? "ipv6 address #{ip.to_s}/#{prefix} #{option}" :
31
- "ip address #{ip.to_s} #{netmask(Socket::AF_INET,prefix)}"
32
- end],
33
- :ensure => [11, lambda { |value| value == :present ? "no shutdown" : "shutdown" } ]
34
- }
35
-
36
- def update(is={}, should={})
37
- Puppet.debug("Updating interface #{name}")
38
- command("conf t")
39
- command("interface #{name}")
40
-
41
- # apply changes in a defined order for cisco IOS devices
42
- [is.keys, should.keys].flatten.uniq.sort {|a,b| COMMANDS[a][0] <=> COMMANDS[b][0] }.each do |property|
43
- # Work around for old documentation which shows :native_vlan used for access vlan
44
- if property == :access_vlan and should[:mode] != :trunk and should[:access_vlan].nil?
45
- should[:access_vlan] = should[:native_vlan]
46
- end
47
-
48
- Puppet.debug("comparing #{property}: #{is[property]} == #{should[property]}")
49
-
50
- # They're equal, so do nothing.
51
- next if is[property] == should[property]
52
-
53
- # We're deleting it
54
- if should[property] == :absent or should[property].nil?
55
- execute(property, is[property], "no ")
56
- next
57
- end
58
-
59
- # We're replacing an existing value or creating a new one
60
- execute(property, should[property])
61
- end
62
-
63
- command("exit")
64
- command("exit")
65
- end
66
-
67
- def execute(property, value, prefix='')
68
- case COMMANDS[property][1]
69
- when Array
70
- COMMANDS[property][1].each do |command|
71
- transport.command(prefix + command % value) do |out|
72
- break unless out =~ /^%/
73
- end
74
- end
75
- when String
76
- command(prefix + COMMANDS[property][1] % value)
77
- when Proc
78
- value = [value] unless value.is_a?(Array)
79
- value.each do |v|
80
- command(prefix + COMMANDS[property][1].call(*v))
81
- end
82
- end
83
- end
84
-
85
- def command(command)
86
- transport.command(command) do |out|
87
- if out =~ /^%/mo or out =~ /^Command rejected:/mo
88
- # strip off the command just sent
89
- error = out.sub(command,'')
90
- Puppet.err _("Error while executing '%{command}', device returned: %{error}") % { command: command, error: error }
91
- end
92
- end
93
- end
94
- end
@@ -1,4 +0,0 @@
1
-
2
- module Puppet::Util::NetworkDevice::Cisco
3
-
4
- end
@@ -1,68 +0,0 @@
1
- require 'puppet/util/network_device'
2
-
3
- module Puppet::Util::NetworkDevice::IPCalc
4
-
5
- # This is a rip-off of authstore
6
- Octet = '(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])'
7
- IPv4 = "#{Octet}\.#{Octet}\.#{Octet}\.#{Octet}"
8
- IPv6_full = "_:_:_:_:_:_:_:_|_:_:_:_:_:_::_?|_:_:_:_:_::((_:)?_)?|_:_:_:_::((_:){0,2}_)?|_:_:_::((_:){0,3}_)?|_:_::((_:){0,4}_)?|_::((_:){0,5}_)?|::((_:){0,6}_)?"
9
- IPv6_partial = "_:_:_:_:_:_:|_:_:_:_::(_:)?|_:_::(_:){0,2}|_::(_:){0,3}"
10
- IP = "#{IPv4}|#{IPv6_full}".gsub(/_/,'([0-9a-fA-F]{1,4})').gsub(/\(/,'(?:')
11
-
12
- def parse(value)
13
- case value
14
- when /^(#{IP})\/(\d+)$/ # 12.34.56.78/24, a001:b002::efff/120, c444:1000:2000::9:192.168.0.1/112
15
- [$2.to_i,IPAddr.new($1)]
16
- when /^(#{IP})$/ # 10.20.30.40,
17
- value = IPAddr.new(value)
18
- [bits(value.family),value]
19
- end
20
- end
21
-
22
- def bits(family)
23
- family == Socket::AF_INET6 ? 128 : 32
24
- end
25
-
26
- def fullmask(family)
27
- (1 << bits(family)) - 1
28
- end
29
-
30
- def mask(family, length)
31
- (1 << (bits(family) - length)) - 1
32
- end
33
-
34
- # returns ip address netmask from prefix length
35
- def netmask(family, length)
36
- IPAddr.new(fullmask(family) & ~mask(family, length) , family)
37
- end
38
-
39
- # returns an IOS wildmask
40
- def wildmask(family, length)
41
- IPAddr.new(mask(family, length) , family)
42
- end
43
-
44
- # returns ip address prefix length from netmask
45
- def prefix_length(netmask)
46
- mask_addr = netmask.to_i
47
- return 0 if mask_addr == 0
48
- length=32
49
- if (netmask.ipv6?)
50
- length=128
51
- end
52
-
53
- mask = mask_addr < 2**length ? length : 128
54
-
55
- mask.times do
56
- if ((mask_addr & 1) == 1)
57
- break
58
- end
59
- mask_addr = mask_addr >> 1
60
- mask = mask - 1
61
- end
62
- mask
63
- end
64
-
65
- def linklocal?(ip)
66
- end
67
-
68
- end
@@ -1,126 +0,0 @@
1
-
2
- require 'puppet/util/network_device'
3
- require 'puppet/util/network_device/transport'
4
- require 'puppet/util/network_device/transport/base'
5
-
6
- # This is an adaptation/simplification of gem net-ssh-telnet, which aims to have
7
- # a sane interface to Net::SSH. Credits goes to net-ssh-telnet authors
8
- class Puppet::Util::NetworkDevice::Transport::Ssh < Puppet::Util::NetworkDevice::Transport::Base
9
-
10
- attr_accessor :buf, :ssh, :channel
11
-
12
- def initialize(verbose = false)
13
- super()
14
- @verbose = verbose
15
- unless Puppet.features.ssh?
16
- raise _('Connecting with ssh to a network device requires the \'net/ssh\' ruby library')
17
- end
18
- end
19
-
20
- def handles_login?
21
- true
22
- end
23
-
24
- def eof?
25
- !! @eof
26
- end
27
-
28
- def connect(&block)
29
- @output = []
30
- @channel_data = ""
31
-
32
- begin
33
- Puppet.debug("connecting to #{host} as #{user}")
34
- @ssh = Net::SSH.start(host, user, :port => port, :password => password, :timeout => timeout)
35
- rescue TimeoutError
36
- raise TimeoutError, _("timed out while opening an ssh connection to the host"), $!.backtrace
37
- rescue Net::SSH::AuthenticationFailed
38
- raise Puppet::Error, _("SSH authentication failure connecting to %{host} as %{user}") % { host: host, user: user }, $!.backtrace
39
- rescue Net::SSH::Exception
40
- raise Puppet::Error, _("SSH connection failure to %{host}") % { host: host }, $!.backtrace
41
- end
42
-
43
- @buf = ""
44
- @eof = false
45
- @channel = nil
46
- @ssh.open_channel do |channel|
47
- channel.request_pty { |ch,success| raise _("failed to open pty") unless success }
48
-
49
- channel.send_channel_request("shell") do |ch, success|
50
- raise _("failed to open ssh shell channel") unless success
51
-
52
- ch.on_data { |_,data| @buf << data }
53
- ch.on_extended_data { |_,type,data| @buf << data if type == 1 }
54
- ch.on_close { @eof = true }
55
-
56
- @channel = ch
57
- expect(default_prompt, &block)
58
- # this is a little bit unorthodox, we're trying to escape
59
- # the ssh loop there while still having the ssh connection up
60
- # otherwise we wouldn't be able to return ssh stdout/stderr
61
- # for a given call of command.
62
- return
63
- end
64
-
65
- end
66
- @ssh.loop
67
-
68
- end
69
-
70
- def close
71
- begin
72
- @channel.close if @channel
73
- @channel = nil
74
- @ssh.close if @ssh
75
- rescue IOError
76
- Puppet.debug "device terminated ssh session impolitely"
77
- end
78
- end
79
-
80
- def expect(prompt)
81
- line = ''
82
- sock = @ssh.transport.socket
83
-
84
- while not @eof
85
- break if line =~ prompt and @buf == ''
86
- break if sock.closed?
87
-
88
- IO::select([sock], [sock], nil, nil)
89
-
90
- process_ssh
91
-
92
- # at this point we have accumulated some data in @buf
93
- # or the channel has been closed
94
- if @buf != ""
95
- line += @buf.gsub(/\r\n/no, "\n")
96
- @buf = ''
97
- yield line if block_given?
98
- elsif @eof
99
- # channel has been closed
100
- break if line =~ prompt
101
- if line == ''
102
- line = nil
103
- yield nil if block_given?
104
- end
105
- break
106
- end
107
- end
108
- Puppet.debug("ssh: expected #{line}") if @verbose
109
- line
110
- end
111
-
112
- def send(line)
113
- Puppet.debug("ssh: send #{line}") if @verbose
114
- @channel.send_data(line + "\n")
115
- end
116
-
117
- def process_ssh
118
- while @buf == "" and not eof?
119
- begin
120
- @channel.connection.process(0.1)
121
- rescue IOError
122
- @eof = true
123
- end
124
- end
125
- end
126
- end
@@ -1,47 +0,0 @@
1
- require 'puppet/util/network_device'
2
- require 'puppet/util/network_device/transport'
3
- require 'puppet/util/network_device/transport/base'
4
-
5
- if Puppet.features.telnet?
6
- require 'net/telnet'
7
-
8
- class Puppet::Util::NetworkDevice::Transport::Telnet < Puppet::Util::NetworkDevice::Transport::Base
9
- def initialize(verbose = false)
10
- super()
11
- @verbose = verbose
12
- end
13
-
14
- def handles_login?
15
- false
16
- end
17
-
18
- def connect
19
- @telnet = Net::Telnet::new("Host" => host, "Port" => port || 23,
20
- "Timeout" => 10,
21
- "Prompt" => default_prompt)
22
- end
23
-
24
- def close
25
- @telnet.close if @telnet
26
- @telnet = nil
27
- end
28
-
29
- def expect(prompt)
30
- @telnet.waitfor(prompt) do |out|
31
- yield out if block_given?
32
- end
33
- end
34
-
35
- def command(cmd, options = {})
36
- send(cmd)
37
- expect(options[:prompt] || default_prompt) do |output|
38
- yield output if block_given?
39
- end
40
- end
41
-
42
- def send(line)
43
- Puppet.debug("telnet: send #{line}") if @verbose
44
- @telnet.puts(line)
45
- end
46
- end
47
- end