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,341 +1,76 @@
1
1
  require 'puppet/application'
2
- require 'puppet/ssl/certificate_authority/interface'
3
2
 
4
3
  class Puppet::Application::Cert < Puppet::Application
5
4
 
6
- run_mode :master
7
-
8
- attr_accessor :all, :ca, :digest, :signed
9
-
10
- def subcommand
11
- @subcommand
12
- end
13
-
14
- def subcommand=(name)
15
- # Handle the nasty, legacy mapping of "clean" to "destroy".
16
- sub = name.to_sym
17
- @subcommand = (sub == :clean ? :destroy : sub)
18
- end
19
-
20
- option("--clean", "-c") do |arg|
21
- self.subcommand = "destroy"
22
- end
23
-
24
- option("--all", "-a") do |arg|
25
- @all = true
26
- end
27
-
28
- option("--digest DIGEST") do |arg|
29
- @digest = arg
30
- end
31
-
32
- option("--signed", "-s") do |arg|
33
- @signed = true
34
- end
35
-
36
- option("--debug", "-d") do |arg|
37
- options[:debug] = true
38
- set_log_level
39
- end
40
-
41
- option("--list", "-l") do |arg|
42
- self.subcommand = :list
43
- end
44
-
45
- option("--revoke", "-r") do |arg|
46
- self.subcommand = :revoke
47
- end
48
-
49
- option("--generate", "-g") do |arg|
50
- self.subcommand = :generate
51
- end
52
-
53
- option("--sign", "-s") do |arg|
54
- self.subcommand = :sign
55
- end
56
-
57
- option("--print", "-p") do |arg|
58
- self.subcommand = :print
59
- end
60
-
61
- option("--verify", "-v") do |arg|
62
- self.subcommand = :verify
63
- end
64
-
65
- option("--fingerprint", "-f") do |arg|
66
- self.subcommand = :fingerprint
67
- end
68
-
69
- option("--reinventory") do |arg|
70
- self.subcommand = :reinventory
71
- end
72
-
73
- option("--[no-]allow-dns-alt-names") do |value|
74
- options[:allow_dns_alt_names] = value
75
- end
76
-
77
- option("--[no-]allow-authorization-extensions") do |value|
78
- options[:allow_authorization_extensions] = value
79
- end
80
-
81
- option("--verbose", "-v") do |arg|
82
- options[:verbose] = true
83
- set_log_level
84
- end
85
-
86
- option("--human-readable", "-H") do |arg|
87
- options[:format] = :human
88
- end
89
-
90
- option("--machine-readable", "-m") do |arg|
91
- options[:format] = :machine
92
- end
93
-
94
- option("--interactive", "-i") do |arg|
95
- options[:interactive] = true
96
- end
97
-
98
- option("--assume-yes", "-y") do |arg|
99
- options[:yes] = true
100
- end
101
-
102
5
  def summary
103
- _("Manage certificates and requests (Deprecated)")
6
+ _("Manage certificates and requests (Disabled)")
104
7
  end
105
8
 
106
9
  def help
107
- <<-HELP
10
+ <<-HELP
11
+ This command is no longer functional, please use `puppetserver ca` instead.
108
12
 
109
13
  puppet-cert(8) -- #{summary}
110
14
  ========
111
15
 
112
- SYNOPSIS
113
- --------
114
- Standalone certificate authority. Capable of generating certificates,
115
- but mostly used for signing certificate requests from puppet clients.
116
-
117
-
118
- USAGE
119
- -----
120
- puppet cert <action> [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose]
121
- [--digest <digest>] [<host>]
122
-
123
-
124
- DESCRIPTION
125
- -----------
126
- Because the puppet master service defaults to not signing client
127
- certificate requests, this script is available for signing outstanding
128
- requests. It can be used to list outstanding requests and then either
129
- sign them individually or sign all of them.
130
-
131
16
  ACTIONS
132
17
  -------
133
-
134
18
  Every action except 'list' and 'generate' requires a hostname to act on,
135
19
  unless the '--all' option is set.
136
20
 
137
- The most important actions for day-to-day use are 'list' and 'sign'.
138
-
139
21
  * clean:
140
- Revoke a host's certificate (if applicable) and remove all files
141
- related to that host from puppet cert's storage. This is useful when
142
- rebuilding hosts, since new certificate signing requests will only be
143
- honored if puppet cert does not have a copy of a signed certificate
144
- for that host. If '--all' is specified then all host certificates,
145
- both signed and unsigned, will be removed.
22
+ Use `puppetserver ca clean --certname NAME[,NAME...]`
146
23
 
147
24
  * fingerprint:
148
- Print the DIGEST (defaults to the signing algorithm) fingerprint of a
149
- host's certificate.
25
+ Use openssl directly:
26
+ `openssl x509 -noout -fingerprint -<digest> -inform pem -in certificate.crt`
150
27
 
151
28
  * generate:
152
- Generate a certificate for a named client. A certificate/keypair will
153
- be generated for each client named on the command line.
29
+ Use `puppetserver ca generate --certname NAME[,NAME...]`
154
30
 
155
31
  * list:
156
- List outstanding certificate requests. If '--all' is specified, signed
157
- certificates are also listed, prefixed by '+', and revoked or invalid
158
- certificates are prefixed by '-' (the verification outcome is printed
159
- in parenthesis). If '--human-readable' or '-H' is specified,
160
- certificates are formatted in a way to improve human scan-ability. If
161
- '--machine-readable' or '-m' is specified, output is formatted concisely
162
- for consumption by a script.
32
+ Use `puppetserver ca list [--all]`
163
33
 
164
34
  * print:
165
- Print the full-text version of a host's certificate.
35
+ Use openssl directly:
36
+ `openssl x509 -noout -text -in certificate.pem`
166
37
 
167
38
  * revoke:
168
- Revoke the certificate of a client. The certificate can be specified either
169
- by its serial number (given as a hexadecimal number prefixed by '0x') or by its
170
- hostname. The certificate is revoked by adding it to the Certificate Revocation
171
- List given by the 'cacrl' configuration option. Note that the puppet master
172
- needs to be restarted after revoking certificates.
39
+ Use `puppetserver ca revoke --cerntname NAME[,NAME...]`
173
40
 
174
41
  * sign:
175
- Sign an outstanding certificate request. If '--interactive' or '-i' is
176
- supplied the user will be prompted to confirm that they are signing the
177
- correct certificate (recommended). If '--assume-yes' or '-y' is supplied
178
- the interactive prompt will assume the answer of 'yes'.
42
+ Use `puppetserver ca sign --cerntname NAME[,NAME...]`
179
43
 
180
44
  * verify:
181
- Verify the named certificate against the local CA certificate.
45
+ Use `puppet ssl verify [--certname NAME]`
182
46
 
183
47
  * reinventory:
184
- Build an inventory of the issued certificates. This will destroy the current
185
- inventory file specified by 'cert_inventory' and recreate it from the
186
- certificates found in the 'certdir'. Ensure the puppet master is stopped
187
- before running this action.
48
+ Removed.
188
49
 
189
50
  OPTIONS
190
51
  -------
191
- Note that any setting that's valid in the configuration
192
- file is also a valid long argument. For example, 'ssldir' is a valid
193
- setting, so you can specify '--ssldir <directory>' as an
194
- argument.
195
-
196
- See the configuration file documentation at
197
- https://puppet.com/docs/puppet/latest/configuration.html for the
198
- full list of acceptable parameters. A commented list of all
199
- configuration options can also be generated by running puppet cert with
200
- '--genconfig'.
201
-
202
- * --all:
203
- Operate on all items. Currently only makes sense with the 'sign',
204
- 'list', and 'fingerprint' actions.
52
+ There are a couple important notes about previously-supported options.
205
53
 
206
54
  * --allow-dns-alt-names:
207
- Sign a certificate request even if it contains one or more alternate DNS
208
- names. If this option isn't specified, 'puppet cert sign' will ignore any
209
- requests that contain alternate names.
210
-
211
- In general, ONLY certs intended for a Puppet master server should include
212
- alternate DNS names, since Puppet agent relies on those names for identifying
213
- its rightful server.
214
-
215
- You can make Puppet agent request a certificate with alternate names by
216
- setting 'dns_alt_names' in puppet.conf or specifying '--dns_alt_names' on the
217
- command line. The output of 'puppet cert list' shows any requested alt names
218
- for pending certificate requests.
55
+ In order to sign certificates with subject alternative names using
56
+ `puppetserver ca sign`, the `allow-subject-alt-names` setting must be
57
+ set to true in the `certificate-authority` section of Puppet Server's
58
+ config.
219
59
 
220
60
  * --allow-authorization-extensions:
221
- Enable the signing of a request with authorization extensions. Such requests
222
- are sensitive because they can be used to write access rules in Puppet Server.
223
- Currently, this is the only means by which such requests can be signed.
224
-
225
- * --digest:
226
- Set the digest for fingerprinting (defaults to the digest used when
227
- signing the cert). Valid values depends on your openssl and openssl ruby
228
- extension version.
229
-
230
- * --debug:
231
- Enable full debugging.
232
-
233
- * --help:
234
- Print this help message
235
-
236
- * --verbose:
237
- Enable verbosity.
238
-
239
- * --version:
240
- Print the puppet version number and exit.
241
-
242
-
243
- EXAMPLE
244
- -------
245
- $ puppet cert list
246
- culain.madstop.com
247
- $ puppet cert sign culain.madstop.com
248
-
249
-
250
- AUTHOR
251
- ------
252
- Luke Kanies
253
-
254
-
255
- COPYRIGHT
256
- ---------
257
- Copyright (c) 2011 Puppet Inc., LLC Licensed under the Apache 2.0 License
258
-
259
- HELP
260
- end
261
-
262
- def main
263
- if @all
264
- hosts = :all
265
- elsif @signed
266
- hosts = :signed
267
- else
268
- hosts = command_line.args.collect { |h| h.downcase }
269
- end
270
- begin
271
- if subcommand == :destroy
272
- raise _("Refusing to destroy all certs, provide an explicit list of certs to destroy") if hosts == :all
273
-
274
- signed_hosts = hosts - @ca.waiting?
275
- apply(@ca, :revoke, options.merge(:to => signed_hosts)) unless signed_hosts.empty?
276
- end
277
- apply(@ca, subcommand, options.merge(:to => hosts, :digest => @digest))
278
- rescue => detail
279
- Puppet.log_exception(detail)
280
- exit(24)
281
- end
61
+ In order to sign certificates with authorization extensions using
62
+ `puppetserver ca sign`, the `allow-authorization-extensions` setting must be
63
+ set to true in the `certificate-authority` section of Puppet Server's
64
+ config.
65
+ HELP
282
66
  end
283
67
 
284
68
  def setup
285
69
  deprecate
286
-
287
- require 'puppet/ssl/certificate_authority'
288
- exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs?
289
-
290
- Puppet::SSL::Oids.register_puppet_oids
291
- Puppet::SSL::Oids.load_custom_oid_file(Puppet[:trusted_oid_mapping_file])
292
-
293
- Puppet::Util::Log.newdestination :console
294
-
295
- if [:generate, :destroy].include? subcommand
296
- Puppet::SSL::Host.ca_location = :local
297
- else
298
- Puppet::SSL::Host.ca_location = :only
299
- end
300
-
301
- # If we are generating, and the option came from the CLI, it gets added to
302
- # the data. This will do the right thing for non-local certificates, in
303
- # that the command line but *NOT* the config file option will apply.
304
- if subcommand == :generate
305
- if Puppet.settings.set_by_cli?(:dns_alt_names)
306
- options[:dns_alt_names] = Puppet[:dns_alt_names]
307
- end
308
- end
309
-
310
- begin
311
- @ca = Puppet::SSL::CertificateAuthority.new
312
- rescue => detail
313
- Puppet.log_exception(detail)
314
- exit(23)
315
- end
316
70
  end
317
71
 
318
72
  def parse_options
319
- # handle the bareword subcommand pattern.
320
- result = super
321
- unless self.subcommand then
322
- if sub = self.command_line.args.shift then
323
- self.subcommand = sub
324
- else
325
- puts help
326
- exit
327
- end
328
- end
329
-
330
- result
73
+ puts help
74
+ exit 1
331
75
  end
332
-
333
- # Create and run an applicator. I wanted to build an interface where you could do
334
- # something like 'ca.apply(:generate).to(:all) but I don't think it's really possible.
335
- def apply(ca, method, options)
336
- raise ArgumentError, _("You must specify the hosts to apply to; valid values are an array or the symbol :all") unless options[:to]
337
- applier = Puppet::SSL::CertificateAuthority::Interface.new(method, options)
338
- applier.apply(ca)
339
- end
340
-
341
76
  end
@@ -376,11 +376,6 @@ Licensed under the Apache 2.0 License
376
376
 
377
377
  Puppet.settings.use :main, :agent, :device, :ssl
378
378
 
379
- # We need to specify a ca location for all of the SSL-related
380
- # indirected classes to work; in fingerprint mode we just need
381
- # access to the local files and we don't need a ca.
382
- Puppet::SSL::Host.ca_location = :remote
383
-
384
379
  Puppet::Transaction::Report.indirection.terminus_class = :rest
385
380
 
386
381
  if Puppet[:catalog_cache_terminus]
@@ -353,7 +353,7 @@ Copyright (c) 2015 Puppet Inc., LLC Licensed under the Apache 2.0 License
353
353
  if fact_file.end_with?("json")
354
354
  given_facts = Puppet::Util::Json.load(Puppet::FileSystem.read(fact_file, :encoding => 'utf-8'))
355
355
  else
356
- given_facts = YAML.load(Puppet::FileSystem.read(fact_file, :encoding => 'utf-8'))
356
+ given_facts = Puppet::Util::Yaml.safe_load_file(fact_file)
357
357
  end
358
358
 
359
359
  unless given_facts.instance_of?(Hash)
@@ -0,0 +1,133 @@
1
+ require 'puppet/application'
2
+ require 'puppet/ssl/oids'
3
+
4
+ class Puppet::Application::Ssl < Puppet::Application
5
+ def summary
6
+ _("Manage SSL keys and certificates for puppet SSL clients")
7
+ end
8
+
9
+ def help
10
+ <<-HELP
11
+ puppet-ssl(8) -- #{summary}
12
+ ========
13
+
14
+ SYNOPSIS
15
+ --------
16
+ Manage SSL keys and certificates for an SSL clients needed
17
+ to communicate with a puppet infrastructure.
18
+
19
+ USAGE
20
+ -----
21
+ puppet ssl <action> [--certname <NAME>]
22
+
23
+ ACTIONS
24
+ -------
25
+
26
+ * submit_request:
27
+ Generate a certificate signing request (CSR) and submit it to the CA. If a private and
28
+ public key pair already exist, they will be used to generate the CSR. Otherwise a new
29
+ key pair will be generated. If a CSR has already been submitted with the given `certname`,
30
+ then the operation will fail.
31
+
32
+ * download_cert:
33
+ Download a certificate for this host. If the current private key matches the downloaded
34
+ certificate, then the certificate will be saved and used for subsequent requests. If
35
+ there is already an existing certificate, it will be overwritten.
36
+
37
+ * verify:
38
+ Verify the private key and certificate are present and match, verify the certificate is
39
+ issued by a trusted CA, and check revocation status.
40
+ HELP
41
+ end
42
+
43
+ option('--certname NAME') do |arg|
44
+ options[:certname] = arg
45
+ end
46
+
47
+ def main
48
+ if command_line.args.empty?
49
+ puts help
50
+ exit(1)
51
+ end
52
+
53
+ Puppet.settings.use(:main, :agent)
54
+ host = Puppet::SSL::Host.new(options[:certname])
55
+
56
+ action = command_line.args.first
57
+ case action
58
+ when 'submit_request'
59
+ submit_request(host)
60
+ download_cert(host)
61
+ when 'download_cert'
62
+ download_cert(host)
63
+ when 'verify'
64
+ verify(host)
65
+ else
66
+ puts "Unknown action '#{action}'"
67
+ exit(1)
68
+ end
69
+
70
+ exit(0)
71
+ end
72
+
73
+ def submit_request(host)
74
+ host.ensure_ca_certificate
75
+
76
+ host.submit_request
77
+ puts "Submitted certificate request for '#{host.name}' to https://#{Puppet[:ca_server]}:#{Puppet[:ca_port]}"
78
+ rescue => e
79
+ puts "Failed to submit certificate request: #{e.message}"
80
+ exit(1)
81
+ end
82
+
83
+ def download_cert(host)
84
+ host.ensure_ca_certificate
85
+
86
+ puts "Downloading certificate '#{host.name}' from https://#{Puppet[:ca_server]}:#{Puppet[:ca_port]}"
87
+ if cert = host.download_host_certificate
88
+ puts "Downloaded certificate '#{host.name}' with fingerprint #{cert.fingerprint}"
89
+ else
90
+ puts "No certificate for '#{host.name}' on CA"
91
+ end
92
+ rescue => e
93
+ puts "Failed to download certificate: #{e.message}"
94
+ exit(1)
95
+ end
96
+
97
+ def verify(host)
98
+ host.ensure_ca_certificate
99
+
100
+ key = host.key
101
+ unless key
102
+ puts "The host's private key is missing"
103
+ exit(1)
104
+ end
105
+
106
+ cert = host.check_for_certificate_on_disk(host.name)
107
+ unless cert
108
+ puts "The host's certificate is missing"
109
+ exit(1)
110
+ end
111
+
112
+ if cert.content.public_key.to_pem != key.content.public_key.to_pem
113
+ puts "The host's key does not match the certificate"
114
+ exit(1)
115
+ end
116
+
117
+ store = host.ssl_store
118
+ unless store.verify(cert.content)
119
+ puts "Failed to verify certificate '#{host.name}': #{store.error_string} (#{store.error})"
120
+ exit(1)
121
+ end
122
+
123
+ puts "Verified certificate '#{host.name}'"
124
+ # store.chain.reverse.each_with_index do |issuer, i|
125
+ # indent = " " * (i+1)
126
+ # puts "#{indent}#{issuer.subject.to_s}"
127
+ # end
128
+ exit(0)
129
+ rescue => e
130
+ puts "Verify failed: #{e.message}"
131
+ exit(1)
132
+ end
133
+ end