bolt 0.23.0 → 0.24.0

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 (192) hide show
  1. checksums.yaml +4 -4
  2. data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +5 -2
  3. data/bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb +5 -1
  4. data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +5 -8
  5. data/lib/bolt/applicator.rb +11 -8
  6. data/lib/bolt/boltdir.rb +13 -5
  7. data/lib/bolt/catalog.rb +22 -47
  8. data/lib/bolt/config.rb +1 -26
  9. data/lib/bolt/executor.rb +1 -1
  10. data/lib/bolt/outputter.rb +0 -9
  11. data/lib/bolt/outputter/human.rb +29 -14
  12. data/lib/bolt/outputter/json.rb +12 -1
  13. data/lib/bolt/pal.rb +12 -10
  14. data/lib/bolt/target.rb +0 -6
  15. data/lib/bolt/task.rb +53 -10
  16. data/lib/bolt/transport/base.rb +1 -6
  17. data/lib/bolt/transport/local.rb +11 -13
  18. data/lib/bolt/transport/local/shell.rb +2 -2
  19. data/lib/bolt/transport/ssh.rb +16 -11
  20. data/lib/bolt/transport/winrm.rb +8 -11
  21. data/lib/bolt/version.rb +1 -1
  22. data/lib/bolt_ext/schemas/task.json +12 -5
  23. data/libexec/apply_catalog.rb +3 -1
  24. data/libexec/bolt_catalog +4 -0
  25. data/vendored/puppet/lib/puppet.rb +2 -1
  26. data/vendored/puppet/lib/puppet/application/agent.rb +2 -6
  27. data/vendored/puppet/lib/puppet/application/apply.rb +100 -60
  28. data/vendored/puppet/lib/puppet/application/cert.rb +26 -291
  29. data/vendored/puppet/lib/puppet/application/device.rb +0 -5
  30. data/vendored/puppet/lib/puppet/application/lookup.rb +1 -1
  31. data/vendored/puppet/lib/puppet/application/ssl.rb +133 -0
  32. data/vendored/puppet/lib/puppet/application_support.rb +1 -2
  33. data/vendored/puppet/lib/puppet/configurer.rb +34 -50
  34. data/vendored/puppet/lib/puppet/configurer/downloader.rb +1 -1
  35. data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +1 -1
  36. data/vendored/puppet/lib/puppet/daemon.rb +1 -1
  37. data/vendored/puppet/lib/puppet/defaults.rb +40 -117
  38. data/vendored/puppet/lib/puppet/face/epp.rb +2 -2
  39. data/vendored/puppet/lib/puppet/face/help.rb +21 -7
  40. data/vendored/puppet/lib/puppet/face/node/clean.rb +14 -10
  41. data/vendored/puppet/lib/puppet/feature/base.rb +7 -23
  42. data/vendored/puppet/lib/puppet/feature/eventlog.rb +1 -1
  43. data/vendored/puppet/lib/puppet/file_serving/base.rb +2 -2
  44. data/vendored/puppet/lib/puppet/file_serving/fileset.rb +1 -1
  45. data/vendored/puppet/lib/puppet/file_serving/metadata.rb +2 -2
  46. data/vendored/puppet/lib/puppet/functions.rb +133 -0
  47. data/vendored/puppet/lib/puppet/functions/eyaml_lookup_key.rb +4 -5
  48. data/vendored/puppet/lib/puppet/functions/filter.rb +7 -6
  49. data/vendored/puppet/lib/puppet/functions/new.rb +37 -53
  50. data/vendored/puppet/lib/puppet/functions/warning.rb +1 -1
  51. data/vendored/puppet/lib/puppet/functions/yaml_data.rb +4 -5
  52. data/vendored/puppet/lib/puppet/gettext/config.rb +1 -1
  53. data/vendored/puppet/lib/puppet/graph.rb +0 -2
  54. data/vendored/puppet/lib/puppet/indirector/catalog/json.rb +14 -3
  55. data/vendored/puppet/lib/puppet/indirector/catalog/yaml.rb +0 -16
  56. data/vendored/puppet/lib/puppet/indirector/certificate/file.rb +0 -1
  57. data/vendored/puppet/lib/puppet/indirector/facts/yaml.rb +4 -2
  58. data/vendored/puppet/lib/puppet/indirector/key/file.rb +1 -6
  59. data/vendored/puppet/lib/puppet/indirector/node/exec.rb +1 -3
  60. data/vendored/puppet/lib/puppet/indirector/node/yaml.rb +0 -6
  61. data/vendored/puppet/lib/puppet/indirector/request.rb +1 -1
  62. data/vendored/puppet/lib/puppet/indirector/ssl_file.rb +3 -44
  63. data/vendored/puppet/lib/puppet/indirector/yaml.rb +4 -4
  64. data/vendored/puppet/lib/puppet/info_service/task_information_service.rb +7 -3
  65. data/vendored/puppet/lib/puppet/loaders.rb +1 -0
  66. data/vendored/puppet/lib/puppet/module/task.rb +198 -29
  67. data/vendored/puppet/lib/puppet/module_tool/applications/unpacker.rb +1 -1
  68. data/vendored/puppet/lib/puppet/network/format_support.rb +13 -8
  69. data/vendored/puppet/lib/puppet/network/formats.rb +93 -2
  70. data/vendored/puppet/lib/puppet/network/http/api/indirected_routes.rb +10 -3
  71. data/vendored/puppet/lib/puppet/node/facts.rb +11 -1
  72. data/vendored/puppet/lib/puppet/parser/catalog_compiler.rb +56 -0
  73. data/vendored/puppet/lib/puppet/parser/compiler.rb +3 -1
  74. data/vendored/puppet/lib/puppet/parser/functions.rb +3 -1
  75. data/vendored/puppet/lib/puppet/parser/functions/filter.rb +1 -1
  76. data/vendored/puppet/lib/puppet/parser/functions/generate.rb +1 -1
  77. data/vendored/puppet/lib/puppet/parser/functions/sprintf.rb +12 -1
  78. data/vendored/puppet/lib/puppet/parser/functions/tagged.rb +1 -4
  79. data/vendored/puppet/lib/puppet/parser/scope.rb +1 -1
  80. data/vendored/puppet/lib/puppet/parser/script_compiler.rb +7 -2
  81. data/vendored/puppet/lib/puppet/pops/evaluator/deferred_resolver.rb +5 -3
  82. data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_converter.rb +23 -4
  83. data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_support.rb +3 -4
  84. data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +4 -0
  85. data/vendored/puppet/lib/puppet/pops/issues.rb +8 -0
  86. data/vendored/puppet/lib/puppet/pops/loader/loader.rb +2 -2
  87. data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +3 -1
  88. data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +30 -9
  89. data/vendored/puppet/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +62 -0
  90. data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +0 -1
  91. data/vendored/puppet/lib/puppet/pops/loader/task_instantiator.rb +13 -70
  92. data/vendored/puppet/lib/puppet/pops/loaders.rb +19 -29
  93. data/vendored/puppet/lib/puppet/pops/lookup/hiera_config.rb +1 -1
  94. data/vendored/puppet/lib/puppet/pops/model/model_label_provider.rb +4 -1
  95. data/vendored/puppet/lib/puppet/pops/pcore.rb +10 -33
  96. data/vendored/puppet/lib/puppet/pops/serialization.rb +2 -0
  97. data/vendored/puppet/lib/puppet/pops/serialization/from_data_converter.rb +2 -1
  98. data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +11 -3
  99. data/vendored/puppet/lib/puppet/pops/serialization/to_stringified_converter.rb +226 -0
  100. data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +3 -0
  101. data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +97 -47
  102. data/vendored/puppet/lib/puppet/pops/validation/validator_factory_4_0.rb +7 -8
  103. data/vendored/puppet/lib/puppet/property/keyvalue.rb +70 -8
  104. data/vendored/puppet/lib/puppet/provider/aix_object.rb +483 -0
  105. data/vendored/puppet/lib/puppet/provider/file/windows.rb +1 -1
  106. data/vendored/puppet/lib/puppet/provider/group/aix.rb +51 -112
  107. data/vendored/puppet/lib/puppet/provider/package/gem.rb +1 -1
  108. data/vendored/puppet/lib/puppet/provider/package/pip.rb +1 -1
  109. data/vendored/puppet/lib/puppet/provider/package/puppet_gem.rb +1 -1
  110. data/vendored/puppet/lib/puppet/provider/package/rpm.rb +1 -1
  111. data/vendored/puppet/lib/puppet/provider/package/windows/package.rb +1 -1
  112. data/vendored/puppet/lib/puppet/provider/package/zypper.rb +1 -1
  113. data/vendored/puppet/lib/puppet/provider/service/systemd.rb +1 -1
  114. data/vendored/puppet/lib/puppet/provider/service/windows.rb +37 -40
  115. data/vendored/puppet/lib/puppet/provider/user/aix.rb +142 -254
  116. data/vendored/puppet/lib/puppet/resource.rb +20 -3
  117. data/vendored/puppet/lib/puppet/resource/catalog.rb +2 -12
  118. data/vendored/puppet/lib/puppet/rest/routes.rb +97 -34
  119. data/vendored/puppet/lib/puppet/settings.rb +1 -1
  120. data/vendored/puppet/lib/puppet/settings/file_setting.rb +1 -1
  121. data/vendored/puppet/lib/puppet/ssl/base.rb +1 -9
  122. data/vendored/puppet/lib/puppet/ssl/certificate_request.rb +1 -13
  123. data/vendored/puppet/lib/puppet/ssl/certificate_request_attributes.rb +1 -1
  124. data/vendored/puppet/lib/puppet/ssl/host.rb +114 -232
  125. data/vendored/puppet/lib/puppet/ssl/key.rb +1 -5
  126. data/vendored/puppet/lib/puppet/ssl/oids.rb +1 -1
  127. data/vendored/puppet/lib/puppet/test/test_helper.rb +0 -4
  128. data/vendored/puppet/lib/puppet/transaction/event.rb +3 -7
  129. data/vendored/puppet/lib/puppet/transaction/persistence.rb +1 -1
  130. data/vendored/puppet/lib/puppet/type/exec.rb +18 -16
  131. data/vendored/puppet/lib/puppet/type/file.rb +3 -3
  132. data/vendored/puppet/lib/puppet/type/file/source.rb +20 -7
  133. data/vendored/puppet/lib/puppet/type/group.rb +3 -5
  134. data/vendored/puppet/lib/puppet/type/notify.rb +1 -1
  135. data/vendored/puppet/lib/puppet/type/package.rb +2 -5
  136. data/vendored/puppet/lib/puppet/type/schedule.rb +1 -1
  137. data/vendored/puppet/lib/puppet/type/service.rb +3 -6
  138. data/vendored/puppet/lib/puppet/type/tidy.rb +1 -1
  139. data/vendored/puppet/lib/puppet/type/user.rb +13 -20
  140. data/vendored/puppet/lib/puppet/util.rb +8 -9
  141. data/vendored/puppet/lib/puppet/util/execution.rb +3 -3
  142. data/vendored/puppet/lib/puppet/util/feature.rb +61 -39
  143. data/vendored/puppet/lib/puppet/util/log/destinations.rb +1 -1
  144. data/vendored/puppet/lib/puppet/util/rdoc.rb +1 -1
  145. data/vendored/puppet/lib/puppet/util/run_mode.rb +1 -1
  146. data/vendored/puppet/lib/puppet/util/storage.rb +1 -1
  147. data/vendored/puppet/lib/puppet/util/suidmanager.rb +7 -5
  148. data/vendored/puppet/lib/puppet/util/tag_set.rb +1 -1
  149. data/vendored/puppet/lib/puppet/util/tagging.rb +1 -1
  150. data/vendored/puppet/lib/puppet/util/windows.rb +18 -2
  151. data/vendored/puppet/lib/puppet/util/windows/adsi.rb +154 -205
  152. data/vendored/puppet/lib/puppet/util/windows/service.rb +770 -0
  153. data/vendored/puppet/lib/puppet/util/yaml.rb +41 -5
  154. data/vendored/puppet/lib/puppet/version.rb +1 -1
  155. data/vendored/puppet/lib/puppet_pal.rb +280 -24
  156. metadata +8 -38
  157. data/lib/bolt/catalog/compiler.rb +0 -48
  158. data/lib/bolt/catalog/loaders.rb +0 -19
  159. data/vendored/puppet/lib/puppet/application/ca.rb +0 -11
  160. data/vendored/puppet/lib/puppet/application/certificate.rb +0 -17
  161. data/vendored/puppet/lib/puppet/application/certificate_request.rb +0 -7
  162. data/vendored/puppet/lib/puppet/application/certificate_revocation_list.rb +0 -7
  163. data/vendored/puppet/lib/puppet/face/ca.rb +0 -266
  164. data/vendored/puppet/lib/puppet/face/certificate.rb +0 -167
  165. data/vendored/puppet/lib/puppet/face/certificate_request.rb +0 -56
  166. data/vendored/puppet/lib/puppet/face/certificate_revocation_list.rb +0 -56
  167. data/vendored/puppet/lib/puppet/graph/random_prioritizer.rb +0 -16
  168. data/vendored/puppet/lib/puppet/graph/title_hash_prioritizer.rb +0 -16
  169. data/vendored/puppet/lib/puppet/indirector/certificate/ca.rb +0 -9
  170. data/vendored/puppet/lib/puppet/indirector/certificate/disabled_ca.rb +0 -22
  171. data/vendored/puppet/lib/puppet/indirector/certificate_request/ca.rb +0 -22
  172. data/vendored/puppet/lib/puppet/indirector/certificate_request/disabled_ca.rb +0 -22
  173. data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/ca.rb +0 -8
  174. data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/disabled_ca.rb +0 -22
  175. data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/file.rb +0 -8
  176. data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/rest.rb +0 -11
  177. data/vendored/puppet/lib/puppet/indirector/certificate_status.rb +0 -4
  178. data/vendored/puppet/lib/puppet/indirector/certificate_status/file.rb +0 -91
  179. data/vendored/puppet/lib/puppet/indirector/certificate_status/rest.rb +0 -11
  180. data/vendored/puppet/lib/puppet/indirector/key/ca.rb +0 -16
  181. data/vendored/puppet/lib/puppet/indirector/key/disabled_ca.rb +0 -22
  182. data/vendored/puppet/lib/puppet/indirector/ldap.rb +0 -86
  183. data/vendored/puppet/lib/puppet/indirector/node/ldap.rb +0 -275
  184. data/vendored/puppet/lib/puppet/provider/aixobject.rb +0 -392
  185. data/vendored/puppet/lib/puppet/provider/cron/crontab.rb +0 -297
  186. data/vendored/puppet/lib/puppet/ssl/certificate_authority.rb +0 -475
  187. data/vendored/puppet/lib/puppet/ssl/certificate_authority/autosign_command.rb +0 -45
  188. data/vendored/puppet/lib/puppet/ssl/certificate_authority/interface.rb +0 -324
  189. data/vendored/puppet/lib/puppet/ssl/certificate_factory.rb +0 -219
  190. data/vendored/puppet/lib/puppet/ssl/certificate_revocation_list.rb +0 -111
  191. data/vendored/puppet/lib/puppet/ssl/inventory.rb +0 -55
  192. data/vendored/puppet/lib/puppet/type/cron.rb +0 -480
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This class exists to override evaluate_main and let us inject
4
- # AST instead of looking for the main manifest. A better option may be to set up the
5
- # node environment so our AST is in the '' hostclass instead of doing it here.
6
- module Puppet
7
- module Parser
8
- class BoltCompiler < Puppet::Parser::Compiler
9
- def internal_evaluator
10
- @internal_evaluator ||= Puppet::Pops::Parser::EvaluatingParser.new
11
- end
12
-
13
- def dump_ast(ast)
14
- Puppet::Pops::Serialization::ToDataConverter.convert(ast, rich_data: true, symbol_to_string: true)
15
- end
16
-
17
- def load_ast(ast_data)
18
- Puppet::Pops::Serialization::FromDataConverter.convert(ast_data)
19
- end
20
-
21
- def parse_string(string, file = '')
22
- internal_evaluator.parse_string(string, file)
23
- end
24
-
25
- def evaluate_main
26
- main = Puppet.lookup(:pal_main)
27
- ast = if main.is_a?(String)
28
- parse_string(main)
29
- else
30
- load_ast(main)
31
- end
32
-
33
- bridge = Puppet::Parser::AST::PopsBridge::Program.new(ast)
34
-
35
- # This is more or less copypaste from the super but we don't use the
36
- # original host_class.
37
- krt = environment.known_resource_types
38
- @main = krt.add(Puppet::Resource::Type.new(:hostclass, '', code: bridge))
39
- @topscope.source = @main
40
- @main_resource = Puppet::Parser::Resource.new('class', :main, scope: @topscope, source: @main)
41
- @topscope.resource = @main_resource
42
- add_resource(@topscope, @main_resource)
43
-
44
- @main_resource.evaluate
45
- end
46
- end
47
- end
48
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Bolt
4
- class Catalog
5
- class BoltLoaders < Puppet::Pops::Loaders
6
- def create_puppet_system_loader
7
- parent = super
8
-
9
- Puppet::Pops::Loader::ModuleLoaders::FileBased.new(
10
- parent,
11
- self,
12
- 'boltlib',
13
- File.join(__dir__, '../../../bolt-modules/boltlib'),
14
- 'boltlib_system'
15
- )
16
- end
17
- end
18
- end
19
- end
@@ -1,11 +0,0 @@
1
- require 'puppet/application/face_base'
2
- require 'puppet/ssl/oids'
3
-
4
- class Puppet::Application::Ca < Puppet::Application::FaceBase
5
- run_mode :master
6
-
7
- def setup
8
- Puppet::SSL::Oids.register_puppet_oids
9
- super
10
- end
11
- end
@@ -1,17 +0,0 @@
1
- require 'puppet/application/indirection_base'
2
- require 'puppet/ssl/oids'
3
-
4
- class Puppet::Application::Certificate < Puppet::Application::IndirectionBase
5
- def setup
6
- Puppet::SSL::Oids.register_puppet_oids
7
- location = Puppet::SSL::Host.ca_location
8
- if location == :local && !Puppet::SSL::CertificateAuthority.ca?
9
- # I'd prefer if this could be dealt with differently; ideally, run_mode should be set as
10
- # part of a class definition, and should not be modifiable beyond that. This is one of
11
- # the cases where that isn't currently possible.
12
- Puppet.settings.preferred_run_mode = "master"
13
- end
14
-
15
- super
16
- end
17
- end
@@ -1,7 +0,0 @@
1
- require 'puppet/application/indirection_base'
2
-
3
- # NOTE: this is using an "old" naming convention (underscores instead of camel-case), for backwards
4
- # compatibility with 2.7.x. When the old naming convention is officially and publicly deprecated,
5
- # this should be changed to camel-case.
6
- class Puppet::Application::Certificate_request < Puppet::Application::IndirectionBase
7
- end
@@ -1,7 +0,0 @@
1
- require 'puppet/application/indirection_base'
2
-
3
- # NOTE: this is using an "old" naming convention (underscores instead of camel-case), for backwards
4
- # compatibility with 2.7.x. When the old naming convention is officially and publicly deprecated,
5
- # this should be changed to camel-case.
6
- class Puppet::Application::Certificate_revocation_list < Puppet::Application::IndirectionBase
7
- end
@@ -1,266 +0,0 @@
1
- require 'puppet/face'
2
-
3
- Puppet::Face.define(:ca, '0.1.0') do
4
- copyright "Puppet Inc.", 2011
5
- license _("Apache 2 license; see COPYING")
6
-
7
- summary _("Local Puppet Certificate Authority management.")
8
-
9
- description <<-TEXT
10
- This provides local management of the Puppet Certificate Authority.
11
-
12
- You can use this subcommand to sign outstanding certificate requests, list
13
- and manage local certificates, and inspect the state of the CA.
14
- TEXT
15
-
16
- action :list do
17
- summary _("List certificates and/or certificate requests.")
18
-
19
- description <<-TEXT
20
- This will list the current certificates and certificate signing requests
21
- in the Puppet CA. You will also get the fingerprint, and any certificate
22
- verification failure reported.
23
- TEXT
24
-
25
- option "--[no-]all" do
26
- summary _("Include all certificates and requests.")
27
- end
28
-
29
- option "--[no-]pending" do
30
- summary _("Include pending certificate signing requests.")
31
- end
32
-
33
- option "--[no-]signed" do
34
- summary _("Include signed certificates.")
35
- end
36
-
37
- option "--digest " + _("ALGORITHM") do
38
- summary _("The hash algorithm to use when displaying the fingerprint")
39
- end
40
-
41
- option "--subject " + _("PATTERN") do
42
- summary _("Only list if the subject matches PATTERN.")
43
-
44
- description <<-TEXT
45
- Only include certificates or requests where subject matches PATTERN.
46
-
47
- PATTERN is interpreted as a regular expression, allowing complex
48
- filtering of the content.
49
- TEXT
50
- end
51
-
52
- when_invoked do |options|
53
- #TRANSLATORS "CA" stands for "certificate authority"
54
- raise _("Not a CA") unless Puppet::SSL::CertificateAuthority.ca?
55
- unless ca = Puppet::SSL::CertificateAuthority.instance
56
- #TRANSLATORS "CA" stands for "certificate authority"
57
- raise _("Unable to fetch the CA")
58
- end
59
- Puppet::SSL::Host.ca_location = :only
60
-
61
- pattern = options[:subject].nil? ? nil :
62
- Regexp.new(options[:subject], Regexp::IGNORECASE)
63
-
64
- pending = options[:pending].nil? ? options[:all] : options[:pending]
65
- signed = options[:signed].nil? ? options[:all] : options[:signed]
66
-
67
- # By default we list pending, so if nothing at all was requested...
68
- unless pending or signed then pending = true end
69
-
70
- hosts = []
71
-
72
- pending and hosts += ca.waiting?
73
- signed and hosts += ca.list
74
-
75
- pattern and hosts = hosts.select {|hostname| pattern.match hostname }
76
-
77
- hosts.sort.map {|host| Puppet::SSL::Host.new(host) }
78
- end
79
-
80
- when_rendering :console do |hosts, options|
81
- unless ca = Puppet::SSL::CertificateAuthority.instance
82
- raise _("Unable to fetch the CA")
83
- end
84
-
85
- length = hosts.map{|x| x.name.length }.max.to_i + 1
86
-
87
- hosts.map do |host|
88
- name = host.name.ljust(length)
89
- if host.certificate_request then
90
- " #{name} #{host.certificate_request.digest(options[:digest])}"
91
- else
92
- begin
93
- ca.verify(host.name)
94
- "+ #{name} #{host.certificate.digest(options[:digest])}"
95
- rescue Puppet::SSL::CertificateAuthority::CertificateVerificationError => e
96
- "- #{name} #{host.certificate.digest(options[:digest])} (#{e.to_s})"
97
- end
98
- end
99
- end.join("\n")
100
- end
101
- end
102
-
103
- action :destroy do
104
- summary _("Destroy named certificate or pending certificate request.")
105
- when_invoked do |host, options|
106
- raise _("Not a CA") unless Puppet::SSL::CertificateAuthority.ca?
107
- unless ca = Puppet::SSL::CertificateAuthority.instance
108
- raise _("Unable to fetch the CA")
109
- end
110
- Puppet::SSL::Host.ca_location = :local
111
-
112
- ca.destroy host
113
- end
114
- end
115
-
116
- action :revoke do
117
- summary _("Add certificate to certificate revocation list.")
118
- when_invoked do |host, options|
119
- raise _("Not a CA") unless Puppet::SSL::CertificateAuthority.ca?
120
- unless ca = Puppet::SSL::CertificateAuthority.instance
121
- raise _("Unable to fetch the CA")
122
- end
123
- Puppet::SSL::Host.ca_location = :only
124
-
125
- begin
126
- ca.revoke host
127
- rescue ArgumentError => e
128
- # This is a bit naff, but it makes the behaviour consistent with the
129
- # destroy action. The underlying tools could be nicer for that sort
130
- # of thing; they have fairly inconsistent reporting of failures.
131
- raise unless e.to_s =~ /Could not find a serial number for /
132
- _("Nothing was revoked")
133
- end
134
- end
135
- end
136
-
137
- action :generate do
138
- summary _("Generate a certificate for a named client.")
139
- option "--dns-alt-names " + _("NAMES") do
140
- summary _("Additional DNS names to add to the certificate request")
141
- description Puppet.settings.setting(:dns_alt_names).desc
142
- end
143
-
144
- when_invoked do |host, options|
145
- raise _("Not a CA") unless Puppet::SSL::CertificateAuthority.ca?
146
- unless ca = Puppet::SSL::CertificateAuthority.instance
147
- raise _("Unable to fetch the CA")
148
- end
149
- Puppet::SSL::Host.ca_location = :local
150
-
151
- begin
152
- ca.generate(host, :dns_alt_names => options[:dns_alt_names])
153
- rescue RuntimeError => e
154
- if e.to_s =~ /already has a requested certificate/
155
- _("%{host} already has a certificate request; use sign instead") % { host: host }
156
- else
157
- raise
158
- end
159
- rescue ArgumentError => e
160
- if e.to_s =~ /A Certificate already exists for /
161
- _("%{host} already has a certificate") % { host: host }
162
- else
163
- raise
164
- end
165
- end
166
- end
167
- end
168
-
169
- action :sign do
170
- summary _("Sign an outstanding certificate request.")
171
- option("--[no-]allow-dns-alt-names") do
172
- summary _("Whether or not to accept DNS alt names in the certificate request")
173
- end
174
-
175
- when_invoked do |host, options|
176
- raise _("Not a CA") unless Puppet::SSL::CertificateAuthority.ca?
177
- unless ca = Puppet::SSL::CertificateAuthority.instance
178
- raise _("Unable to fetch the CA")
179
- end
180
- Puppet::SSL::Host.ca_location = :only
181
-
182
- begin
183
- signing_options = options.select { |k,_|
184
- [:allow_dns_alt_names, :allow_authorization_extensions].include?(k)
185
- }
186
- ca.sign(host, signing_options)
187
- rescue ArgumentError => e
188
- if e.to_s =~ /Could not find certificate request/
189
- e.to_s
190
- else
191
- raise
192
- end
193
- end
194
- end
195
- end
196
-
197
- action :print do
198
- summary _("Print the full-text version of a host's certificate.")
199
- when_invoked do |host, options|
200
- raise _("Not a CA") unless Puppet::SSL::CertificateAuthority.ca?
201
- unless ca = Puppet::SSL::CertificateAuthority.instance
202
- raise _("Unable to fetch the CA")
203
- end
204
- Puppet::SSL::Host.ca_location = :only
205
-
206
- ca.print host
207
- end
208
- end
209
-
210
- action :fingerprint do
211
- #TRANSLATORS "DIGEST" refers to a hash algorithm
212
- summary _("Print the DIGEST (defaults to the signing algorithm) fingerprint of a host's certificate.")
213
- option "--digest " + _("ALGORITHM") do
214
- summary _("The hash algorithm to use when displaying the fingerprint")
215
- end
216
-
217
- when_invoked do |host, options|
218
- #TRANSLATORS "CA" stands for "certificate authority"
219
- raise _("Not a CA") unless Puppet::SSL::CertificateAuthority.ca?
220
- unless Puppet::SSL::CertificateAuthority.instance
221
- #TRANSLATORS "CA" stands for "certificate authority"
222
- raise _("Unable to fetch the CA")
223
- end
224
- Puppet::SSL::Host.ca_location = :only
225
-
226
- if cert = (Puppet::SSL::Certificate.indirection.find(host) || Puppet::SSL::CertificateRequest.indirection.find(host))
227
- cert.digest(options[:digest]).to_s
228
- else
229
- nil
230
- end
231
- end
232
- end
233
-
234
- action :verify do
235
- summary "Verify the named certificate against the local CA certificate."
236
- when_invoked do |host, options|
237
- #TRANSLATORS "CA" stands for "certificate authority"
238
- raise _("Not a CA") unless Puppet::SSL::CertificateAuthority.ca?
239
- unless ca = Puppet::SSL::CertificateAuthority.instance
240
- #TRANSLATORS "CA" stands for "certificate authority"
241
- raise _("Unable to fetch the CA")
242
- end
243
- Puppet::SSL::Host.ca_location = :only
244
-
245
- begin
246
- ca.verify host
247
- { :host => host, :valid => true }
248
- rescue ArgumentError => e
249
- raise unless e.to_s =~ /Could not find a certificate for/
250
- { :host => host, :valid => false, :error => e.to_s }
251
- rescue Puppet::SSL::CertificateAuthority::CertificateVerificationError => e
252
- { :host => host, :valid => false, :error => e.to_s }
253
- end
254
- end
255
-
256
- when_rendering :console do |value|
257
- if value[:valid]
258
- nil
259
- else
260
- _("Could not verify %{host}: %{error}") % { host: value[:host], error: value[:error] }
261
- end
262
- end
263
- end
264
-
265
- deprecate
266
- end
@@ -1,167 +0,0 @@
1
- require 'puppet/indirector/face'
2
- require 'puppet/ssl/host'
3
-
4
- Puppet::Indirector::Face.define(:certificate, '0.0.1') do
5
- copyright "Puppet Inc.", 2011
6
- license _("Apache 2 license; see COPYING")
7
-
8
- summary _("Provide access to the CA for certificate management.")
9
- description <<-EOT
10
- This subcommand interacts with a local or remote Puppet certificate
11
- authority. Currently, its behavior is not a full superset of `puppet
12
- cert`; specifically, it is unable to mimic puppet cert's "clean" option,
13
- and its "generate" action submits a CSR rather than creating a
14
- signed certificate.
15
- EOT
16
-
17
- option "--ca-location " + _("LOCATION") do
18
- required
19
- summary _("Which certificate authority to use (local or remote).")
20
- description <<-EOT
21
- Whether to act on the local certificate authority or one provided by a
22
- remote puppet master. Allowed values are 'local' and 'remote.'
23
-
24
- This option is required.
25
- EOT
26
-
27
- before_action do |action, args, options|
28
- unless [:remote, :local, :only].include? options[:ca_location].to_sym
29
- raise ArgumentError, _("Valid values for ca-location are 'remote', 'local', 'only'.")
30
- end
31
- Puppet::SSL::Host.ca_location = options[:ca_location].to_sym
32
- end
33
- end
34
-
35
- action :generate do
36
- summary _("Generate a new certificate signing request.")
37
- arguments _("<host>")
38
- returns "Nothing."
39
- description <<-EOT
40
- Generates and submits a certificate signing request (CSR) for the
41
- specified host. This CSR will then have to be signed by a user
42
- with the proper authorization on the certificate authority.
43
-
44
- Puppet agent usually handles CSR submission automatically. This action is
45
- primarily useful for requesting certificates for individual users and
46
- external applications.
47
- EOT
48
- examples <<-EOT
49
- Request a certificate for "somenode" from the site's CA:
50
-
51
- $ puppet certificate generate somenode.puppetlabs.lan --ca-location remote
52
- EOT
53
-
54
- # Duplicate the option here explicitly to distinguish if it was passed arg
55
- # us vs. set in the config file.
56
- option "--dns-alt-names "+ _("NAMES") do
57
- summary _("Additional DNS names to add to the certificate request")
58
- description Puppet.settings.setting(:dns_alt_names).desc
59
- end
60
-
61
- when_invoked do |name, options|
62
- host = Puppet::SSL::Host.new(name)
63
-
64
- # We have a weird case where we have --dns_alt_names from Puppet, but
65
- # this option is --dns-alt-names. Until we can get rid of --dns-alt-names
66
- # or do a global tr('-', '_'), we have to support both.
67
- # In supporting both, we'll use Puppet[:dns_alt_names] if specified on
68
- # command line. We'll use options[:dns_alt_names] if specified on
69
- # command line. If both specified, we'll fail.
70
- # jeffweiss 17 april 2012
71
-
72
- global_setting_from_cli = Puppet.settings.set_by_cli?(:dns_alt_names) == true
73
- raise ArgumentError, _("Can't specify both --dns_alt_names and --dns-alt-names") if options[:dns_alt_names] and global_setting_from_cli
74
- options[:dns_alt_names] = Puppet[:dns_alt_names] if global_setting_from_cli
75
-
76
- # If dns_alt_names are specified via the command line, we will always add
77
- # them. Otherwise, they will default to the config file setting iff this
78
- # cert is for the host we're running on.
79
-
80
- unless Puppet::FileSystem.exist?(Puppet[:hostcert])
81
- Puppet.push_context({:ssl_host => host})
82
- end
83
-
84
- host.generate_certificate_request(:dns_alt_names => options[:dns_alt_names])
85
- end
86
- end
87
-
88
- action :list do
89
- summary _("List all certificate signing requests.")
90
- returns <<-EOT
91
- An array of #inspect output from CSR objects. This output is
92
- currently messy, but does contain the names of nodes requesting
93
- certificates. This action returns #inspect strings even when used
94
- from the Ruby API.
95
- EOT
96
-
97
- when_invoked do |options|
98
- Puppet::SSL::Host.indirection.search("*", {
99
- :for => :certificate_request,
100
- }).map { |h| h.inspect }
101
- end
102
- end
103
-
104
- action :sign do
105
- summary _("Sign a certificate signing request for HOST.")
106
- arguments _("<host>")
107
- returns <<-EOT
108
- A string that appears to be (but isn't) an x509 certificate.
109
- EOT
110
- examples <<-EOT
111
- Sign somenode.puppetlabs.lan's certificate:
112
-
113
- $ puppet certificate sign somenode.puppetlabs.lan --ca-location remote
114
- EOT
115
-
116
- option("--[no-]allow-dns-alt-names") do
117
- summary _("Whether or not to accept DNS alt names in the certificate request")
118
- end
119
-
120
- when_invoked do |name, options|
121
- host = Puppet::SSL::Host.new(name)
122
- if Puppet::SSL::Host.ca_location == :remote
123
- if options[:allow_dns_alt_names]
124
- raise ArgumentError, _("--allow-dns-alt-names may not be specified with a remote CA")
125
- end
126
-
127
- host.desired_state = 'signed'
128
- Puppet::SSL::Host.indirection.save(host)
129
- else
130
- # We have to do this case manually because we need to specify
131
- # allow_dns_alt_names.
132
- unless ca = Puppet::SSL::CertificateAuthority.instance
133
- raise ArgumentError, _("This process is not configured as a certificate authority")
134
- end
135
-
136
- signing_options = {allow_dns_alt_names: options[:allow_dns_alt_names]}
137
-
138
- ca.sign(name, signing_options)
139
- end
140
- end
141
- end
142
-
143
- # Indirector action doc overrides
144
- find = get_action(:find)
145
- find.summary _("Retrieve a certificate.")
146
- find.arguments _("<host>")
147
- find.render_as = :s
148
- find.returns <<-EOT
149
- An x509 SSL certificate.
150
-
151
- Note that this action has a side effect of caching a copy of the
152
- certificate in Puppet's `ssldir`.
153
- EOT
154
-
155
- destroy = get_action(:destroy)
156
- destroy.summary _("Delete a certificate.")
157
- destroy.arguments _("<host>")
158
- destroy.returns "Nothing."
159
- destroy.description <<-EOT
160
- Deletes a certificate. This action currently only works on the local CA.
161
- EOT
162
-
163
- deactivate_action(:search)
164
- deactivate_action(:save)
165
-
166
- deprecate
167
- end