bolt 3.17.0 → 3.21.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.
- checksums.yaml +4 -4
- data/Puppetfile +14 -14
- data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +1 -4
- data/bolt-modules/boltlib/lib/puppet/functions/upload_file.rb +1 -4
- data/bolt-modules/file/lib/puppet/functions/file/exists.rb +1 -4
- data/bolt-modules/file/lib/puppet/functions/file/read.rb +1 -4
- data/bolt-modules/file/lib/puppet/functions/file/readable.rb +1 -4
- data/lib/bolt/analytics.rb +2 -2
- data/lib/bolt/application.rb +177 -12
- data/lib/bolt/applicator.rb +7 -6
- data/lib/bolt/apply_inventory.rb +3 -3
- data/lib/bolt/apply_result.rb +2 -2
- data/lib/bolt/bolt_option_parser.rb +87 -22
- data/lib/bolt/catalog.rb +10 -11
- data/lib/bolt/cli.rb +66 -24
- data/lib/bolt/config/modulepath.rb +1 -1
- data/lib/bolt/config/options.rb +42 -13
- data/lib/bolt/config/transport/base.rb +4 -4
- data/lib/bolt/config/transport/docker.rb +2 -2
- data/lib/bolt/config/transport/local.rb +2 -2
- data/lib/bolt/config/transport/lxd.rb +2 -2
- data/lib/bolt/config/transport/options.rb +3 -2
- data/lib/bolt/config/transport/orch.rb +2 -2
- data/lib/bolt/config/transport/podman.rb +2 -2
- data/lib/bolt/config/transport/remote.rb +2 -2
- data/lib/bolt/config/transport/ssh.rb +2 -2
- data/lib/bolt/config/transport/winrm.rb +2 -2
- data/lib/bolt/config.rb +9 -5
- data/lib/bolt/container_result.rb +2 -2
- data/lib/bolt/error.rb +1 -1
- data/lib/bolt/executor.rb +17 -14
- data/lib/bolt/fiber_executor.rb +2 -2
- data/lib/bolt/inventory/group.rb +4 -4
- data/lib/bolt/inventory/inventory.rb +3 -9
- data/lib/bolt/inventory/options.rb +1 -1
- data/lib/bolt/inventory/target.rb +1 -1
- data/lib/bolt/inventory.rb +8 -8
- data/lib/bolt/module_installer/installer.rb +2 -2
- data/lib/bolt/module_installer/puppetfile/forge_module.rb +1 -1
- data/lib/bolt/module_installer/puppetfile/git_module.rb +1 -1
- data/lib/bolt/module_installer/puppetfile/module.rb +1 -1
- data/lib/bolt/module_installer/puppetfile.rb +3 -3
- data/lib/bolt/module_installer/resolver.rb +3 -3
- data/lib/bolt/module_installer/specs/forge_spec.rb +1 -1
- data/lib/bolt/module_installer/specs/git_spec.rb +1 -1
- data/lib/bolt/module_installer/specs.rb +3 -3
- data/lib/bolt/module_installer.rb +6 -6
- data/lib/bolt/node/errors.rb +1 -1
- data/lib/bolt/node/output.rb +1 -1
- data/lib/bolt/outputter/human.rb +45 -2
- data/lib/bolt/outputter/json.rb +8 -0
- data/lib/bolt/outputter/logger.rb +1 -1
- data/lib/bolt/outputter/rainbow.rb +1 -1
- data/lib/bolt/outputter.rb +4 -4
- data/lib/bolt/pal/logging.rb +1 -1
- data/lib/bolt/pal/yaml_plan/evaluator.rb +1 -1
- data/lib/bolt/pal/yaml_plan/loader.rb +2 -2
- data/lib/bolt/pal/yaml_plan/step.rb +11 -11
- data/lib/bolt/pal/yaml_plan/transpiler.rb +3 -3
- data/lib/bolt/pal/yaml_plan.rb +2 -2
- data/lib/bolt/pal.rb +25 -11
- data/lib/bolt/plan_creator.rb +4 -4
- data/lib/bolt/plan_result.rb +2 -2
- data/lib/bolt/plugin/cache.rb +2 -2
- data/lib/bolt/plugin/module.rb +1 -1
- data/lib/bolt/plugin.rb +7 -7
- data/lib/bolt/project.rb +7 -5
- data/lib/bolt/project_manager/config_migrator.rb +1 -1
- data/lib/bolt/project_manager/inventory_migrator.rb +1 -1
- data/lib/bolt/project_manager/migrator.rb +1 -1
- data/lib/bolt/project_manager/module_migrator.rb +5 -5
- data/lib/bolt/project_manager.rb +23 -4
- data/lib/bolt/puppetdb/config.rb +1 -1
- data/lib/bolt/puppetdb.rb +3 -3
- data/lib/bolt/result.rb +1 -1
- data/lib/bolt/shell/bash.rb +14 -8
- data/lib/bolt/shell/powershell.rb +23 -4
- data/lib/bolt/shell.rb +2 -2
- data/lib/bolt/target.rb +2 -2
- data/lib/bolt/transport/base.rb +1 -1
- data/lib/bolt/transport/docker/connection.rb +1 -1
- data/lib/bolt/transport/docker.rb +2 -2
- data/lib/bolt/transport/local/connection.rb +2 -2
- data/lib/bolt/transport/local.rb +3 -3
- data/lib/bolt/transport/lxd/connection.rb +1 -1
- data/lib/bolt/transport/lxd.rb +4 -4
- data/lib/bolt/transport/orch.rb +2 -2
- data/lib/bolt/transport/podman/connection.rb +1 -1
- data/lib/bolt/transport/podman.rb +2 -2
- data/lib/bolt/transport/remote.rb +2 -2
- data/lib/bolt/transport/simple.rb +3 -3
- data/lib/bolt/transport/ssh/connection.rb +3 -3
- data/lib/bolt/transport/ssh.rb +5 -5
- data/lib/bolt/transport/winrm/connection.rb +2 -2
- data/lib/bolt/transport/winrm.rb +3 -3
- data/lib/bolt/util.rb +11 -31
- data/lib/bolt/validator.rb +1 -1
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt.rb +1 -1
- data/lib/bolt_server/transport_app.rb +26 -5
- data/lib/bolt_spec/bolt_context.rb +6 -4
- data/lib/bolt_spec/plans/mock_executor.rb +3 -3
- data/libexec/bolt_catalog +1 -1
- metadata +6 -6
@@ -114,6 +114,21 @@ module Bolt
|
|
114
114
|
{ flags: OPTIONS[:global],
|
115
115
|
banner: PLUGIN_HELP }
|
116
116
|
end
|
117
|
+
when 'policy'
|
118
|
+
case action
|
119
|
+
when 'apply'
|
120
|
+
{ flags: ACTION_OPTS + %w[compile-concurrency hiera-config noop],
|
121
|
+
banner: POLICY_APPLY_HELP }
|
122
|
+
when 'new'
|
123
|
+
{ flags: OPTIONS[:global] + PROJECT_PATHS,
|
124
|
+
banner: POLICY_NEW_HELP }
|
125
|
+
when 'show'
|
126
|
+
{ flags: OPTIONS[:global] + PROJECT_PATHS,
|
127
|
+
banner: POLICY_SHOW_HELP }
|
128
|
+
else
|
129
|
+
{ flags: OPTIONS[:global],
|
130
|
+
banner: POLICY_HELP }
|
131
|
+
end
|
117
132
|
when 'project'
|
118
133
|
case action
|
119
134
|
when 'init'
|
@@ -202,6 +217,7 @@ module Bolt
|
|
202
217
|
lookup Look up a value with Hiera
|
203
218
|
plan Convert, create, show, and run Bolt plans
|
204
219
|
plugin Show available plugins
|
220
|
+
policy Apply, create, and show policies
|
205
221
|
project Create and migrate Bolt projects
|
206
222
|
script Upload a local script and run it remotely
|
207
223
|
secret Create encryption keys and encrypt and decrypt values
|
@@ -250,7 +266,7 @@ module Bolt
|
|
250
266
|
|
251
267
|
COMMAND_RUN_HELP = <<~HELP
|
252
268
|
#{colorize(:cyan, 'Name')}
|
253
|
-
run
|
269
|
+
command run
|
254
270
|
|
255
271
|
#{colorize(:cyan, 'Usage')}
|
256
272
|
bolt command run <command> {--targets TARGETS | --query QUERY | --rerun FILTER}
|
@@ -286,7 +302,7 @@ module Bolt
|
|
286
302
|
|
287
303
|
FILE_DOWNLOAD_HELP = <<~HELP
|
288
304
|
#{colorize(:cyan, 'Name')}
|
289
|
-
download
|
305
|
+
file download
|
290
306
|
|
291
307
|
#{colorize(:cyan, 'Usage')}
|
292
308
|
bolt file download <source> <destination> {--targets TARGETS | --query QUERY | --rerun FILTER}
|
@@ -309,7 +325,7 @@ module Bolt
|
|
309
325
|
|
310
326
|
FILE_UPLOAD_HELP = <<~HELP
|
311
327
|
#{colorize(:cyan, 'Name')}
|
312
|
-
upload
|
328
|
+
file upload
|
313
329
|
|
314
330
|
#{colorize(:cyan, 'Usage')}
|
315
331
|
bolt file upload <source> <destination> {--targets TARGETS | --query QUERY | --rerun FILTER}
|
@@ -344,7 +360,7 @@ module Bolt
|
|
344
360
|
|
345
361
|
GROUP_SHOW_HELP = <<~HELP
|
346
362
|
#{colorize(:cyan, 'Name')}
|
347
|
-
show
|
363
|
+
group show
|
348
364
|
|
349
365
|
#{colorize(:cyan, 'Usage')}
|
350
366
|
bolt group show [options]
|
@@ -395,7 +411,7 @@ module Bolt
|
|
395
411
|
|
396
412
|
INVENTORY_SHOW_HELP = <<~HELP
|
397
413
|
#{colorize(:cyan, 'Name')}
|
398
|
-
show
|
414
|
+
inventory show
|
399
415
|
|
400
416
|
#{colorize(:cyan, 'Usage')}
|
401
417
|
bolt inventory show [options]
|
@@ -453,7 +469,7 @@ module Bolt
|
|
453
469
|
|
454
470
|
MODULE_ADD_HELP = <<~HELP
|
455
471
|
#{colorize(:cyan, 'Name')}
|
456
|
-
add
|
472
|
+
module add
|
457
473
|
|
458
474
|
#{colorize(:cyan, 'Usage')}
|
459
475
|
bolt module add <module> [options]
|
@@ -471,7 +487,7 @@ module Bolt
|
|
471
487
|
|
472
488
|
MODULE_GENERATETYPES_HELP = <<~HELP
|
473
489
|
#{colorize(:cyan, 'Name')}
|
474
|
-
generate-types
|
490
|
+
module generate-types
|
475
491
|
|
476
492
|
#{colorize(:cyan, 'Usage')}
|
477
493
|
bolt module generate-types [options]
|
@@ -486,7 +502,7 @@ module Bolt
|
|
486
502
|
|
487
503
|
MODULE_INSTALL_HELP = <<~HELP
|
488
504
|
#{colorize(:cyan, 'Name')}
|
489
|
-
install
|
505
|
+
module install
|
490
506
|
|
491
507
|
#{colorize(:cyan, 'Usage')}
|
492
508
|
bolt module install [options]
|
@@ -504,7 +520,7 @@ module Bolt
|
|
504
520
|
|
505
521
|
MODULE_SHOW_HELP = <<~HELP
|
506
522
|
#{colorize(:cyan, 'Name')}
|
507
|
-
show
|
523
|
+
module show
|
508
524
|
|
509
525
|
#{colorize(:cyan, 'Usage')}
|
510
526
|
bolt module show [module name] [options]
|
@@ -541,7 +557,7 @@ module Bolt
|
|
541
557
|
|
542
558
|
PLAN_CONVERT_HELP = <<~HELP
|
543
559
|
#{colorize(:cyan, 'Name')}
|
544
|
-
convert
|
560
|
+
plan convert
|
545
561
|
|
546
562
|
#{colorize(:cyan, 'Usage')}
|
547
563
|
bolt plan convert <plan name> [options]
|
@@ -564,7 +580,7 @@ module Bolt
|
|
564
580
|
|
565
581
|
PLAN_NEW_HELP = <<~HELP
|
566
582
|
#{colorize(:cyan, 'Name')}
|
567
|
-
new
|
583
|
+
plan new
|
568
584
|
|
569
585
|
#{colorize(:cyan, 'Usage')}
|
570
586
|
bolt plan new <plan name> [options]
|
@@ -581,7 +597,7 @@ module Bolt
|
|
581
597
|
|
582
598
|
PLAN_RUN_HELP = <<~HELP
|
583
599
|
#{colorize(:cyan, 'Name')}
|
584
|
-
run
|
600
|
+
plan run
|
585
601
|
|
586
602
|
#{colorize(:cyan, 'Usage')}
|
587
603
|
bolt plan run <plan name> [parameters] [options]
|
@@ -598,7 +614,7 @@ module Bolt
|
|
598
614
|
|
599
615
|
PLAN_SHOW_HELP = <<~HELP
|
600
616
|
#{colorize(:cyan, 'Name')}
|
601
|
-
show
|
617
|
+
plan show
|
602
618
|
|
603
619
|
#{colorize(:cyan, 'Usage')}
|
604
620
|
bolt plan show [plan name] [options]
|
@@ -641,7 +657,7 @@ module Bolt
|
|
641
657
|
|
642
658
|
PLUGIN_SHOW_HELP = <<~HELP
|
643
659
|
#{colorize(:cyan, 'Name')}
|
644
|
-
show
|
660
|
+
plugin show
|
645
661
|
|
646
662
|
#{colorize(:cyan, 'Usage')}
|
647
663
|
bolt plugin show [options]
|
@@ -653,6 +669,55 @@ module Bolt
|
|
653
669
|
Learn more about Bolt plugins at https://pup.pt/bolt-plugins.
|
654
670
|
HELP
|
655
671
|
|
672
|
+
POLICY_HELP = <<~HELP
|
673
|
+
#{colorize(:cyan, 'Name')}
|
674
|
+
policy
|
675
|
+
|
676
|
+
#{colorize(:cyan, 'Usage')}
|
677
|
+
bolt policy <action> [options]
|
678
|
+
|
679
|
+
#{colorize(:cyan, 'Description')}
|
680
|
+
Apply, create, and show policies.
|
681
|
+
|
682
|
+
#{colorize(:cyan, 'Actions')}
|
683
|
+
apply Apply a policy to the specified targets
|
684
|
+
new Create a new policy in the current project
|
685
|
+
show Show available policy
|
686
|
+
HELP
|
687
|
+
|
688
|
+
POLICY_APPLY_HELP = <<~HELP
|
689
|
+
#{colorize(:cyan, 'Name')}
|
690
|
+
policy apply
|
691
|
+
|
692
|
+
#{colorize(:cyan, 'Usage')}
|
693
|
+
bolt policy apply <policy> [options]
|
694
|
+
|
695
|
+
#{colorize(:cyan, 'Description')}
|
696
|
+
Apply a policy to the specified targets.
|
697
|
+
HELP
|
698
|
+
|
699
|
+
POLICY_NEW_HELP = <<~HELP
|
700
|
+
#{colorize(:cyan, 'Name')}
|
701
|
+
policy new
|
702
|
+
|
703
|
+
#{colorize(:cyan, 'Usage')}
|
704
|
+
bolt policy new <policy> [options]
|
705
|
+
|
706
|
+
#{colorize(:cyan, 'Description')}
|
707
|
+
Create a new policy in the current project.
|
708
|
+
HELP
|
709
|
+
|
710
|
+
POLICY_SHOW_HELP = <<~HELP
|
711
|
+
#{colorize(:cyan, 'Name')}
|
712
|
+
policy show
|
713
|
+
|
714
|
+
#{colorize(:cyan, 'Usage')}
|
715
|
+
bolt policy show [options]
|
716
|
+
|
717
|
+
#{colorize(:cyan, 'Description')}
|
718
|
+
Show available policies.
|
719
|
+
HELP
|
720
|
+
|
656
721
|
PROJECT_HELP = <<~HELP
|
657
722
|
#{colorize(:cyan, 'Name')}
|
658
723
|
project
|
@@ -673,7 +738,7 @@ module Bolt
|
|
673
738
|
|
674
739
|
PROJECT_INIT_HELP = <<~HELP
|
675
740
|
#{colorize(:cyan, 'Name')}
|
676
|
-
init
|
741
|
+
project init
|
677
742
|
|
678
743
|
#{colorize(:cyan, 'Usage')}
|
679
744
|
bolt project init [name] [options]
|
@@ -697,7 +762,7 @@ module Bolt
|
|
697
762
|
|
698
763
|
PROJECT_MIGRATE_HELP = <<~HELP
|
699
764
|
#{colorize(:cyan, 'Name')}
|
700
|
-
migrate
|
765
|
+
project migrate
|
701
766
|
|
702
767
|
#{colorize(:cyan, 'Usage')}
|
703
768
|
bolt project migrate [options]
|
@@ -729,7 +794,7 @@ module Bolt
|
|
729
794
|
|
730
795
|
SCRIPT_RUN_HELP = <<~HELP
|
731
796
|
#{colorize(:cyan, 'Name')}
|
732
|
-
run
|
797
|
+
script run
|
733
798
|
|
734
799
|
#{colorize(:cyan, 'Usage')}
|
735
800
|
bolt script run <script> [arguments] {--targets TARGETS | --query QUERY | --rerun FILTER}
|
@@ -770,7 +835,7 @@ module Bolt
|
|
770
835
|
|
771
836
|
SECRET_CREATEKEYS_HELP = <<~HELP
|
772
837
|
#{colorize(:cyan, 'Name')}
|
773
|
-
createkeys
|
838
|
+
secret createkeys
|
774
839
|
|
775
840
|
#{colorize(:cyan, 'Usage')}
|
776
841
|
bolt secret createkeys [options]
|
@@ -784,7 +849,7 @@ module Bolt
|
|
784
849
|
|
785
850
|
SECRET_DECRYPT_HELP = <<~HELP
|
786
851
|
#{colorize(:cyan, 'Name')}
|
787
|
-
decrypt
|
852
|
+
secret decrypt
|
788
853
|
|
789
854
|
#{colorize(:cyan, 'Usage')}
|
790
855
|
bolt secret decrypt <ciphertext> [options]
|
@@ -798,7 +863,7 @@ module Bolt
|
|
798
863
|
|
799
864
|
SECRET_ENCRYPT_HELP = <<~HELP
|
800
865
|
#{colorize(:cyan, 'Name')}
|
801
|
-
encrypt
|
866
|
+
secret encrypt
|
802
867
|
|
803
868
|
#{colorize(:cyan, 'Usage')}
|
804
869
|
bolt secret encrypt <plaintext> [options]
|
@@ -830,7 +895,7 @@ module Bolt
|
|
830
895
|
|
831
896
|
TASK_RUN_HELP = <<~HELP
|
832
897
|
#{colorize(:cyan, 'Name')}
|
833
|
-
run
|
898
|
+
task run
|
834
899
|
|
835
900
|
#{colorize(:cyan, 'Usage')}
|
836
901
|
bolt task run <task name> [parameters] {--targets TARGETS | --query QUERY | --rerun FILTER}
|
@@ -850,7 +915,7 @@ module Bolt
|
|
850
915
|
|
851
916
|
TASK_SHOW_HELP = <<~HELP
|
852
917
|
#{colorize(:cyan, 'Name')}
|
853
|
-
show
|
918
|
+
task show
|
854
919
|
|
855
920
|
#{colorize(:cyan, 'Usage')}
|
856
921
|
bolt task show [task name] [options]
|
data/lib/bolt/catalog.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
require_relative '../bolt/apply_inventory'
|
4
|
+
require_relative '../bolt/apply_target'
|
5
|
+
require_relative '../bolt/config'
|
6
|
+
require_relative '../bolt/error'
|
7
|
+
require_relative '../bolt/inventory'
|
8
|
+
require_relative '../bolt/pal'
|
9
|
+
require_relative '../bolt/puppetdb'
|
10
|
+
require_relative '../bolt/util'
|
11
11
|
|
12
12
|
Bolt::PAL.load_puppet
|
13
13
|
|
14
|
-
|
14
|
+
require_relative 'catalog/logging'
|
15
15
|
|
16
16
|
module Bolt
|
17
17
|
class Catalog
|
@@ -65,8 +65,7 @@ module Bolt
|
|
65
65
|
puppet_overrides = {
|
66
66
|
bolt_pdb_client: pdb_client,
|
67
67
|
bolt_inventory: inv,
|
68
|
-
bolt_project: bolt_project
|
69
|
-
future: request['future']
|
68
|
+
bolt_project: bolt_project
|
70
69
|
}
|
71
70
|
|
72
71
|
# Facts will be set by the catalog compiler, so we need to ensure
|
data/lib/bolt/cli.rb
CHANGED
@@ -9,23 +9,23 @@ require 'json'
|
|
9
9
|
require 'io/console'
|
10
10
|
require 'logging'
|
11
11
|
require 'optparse'
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
12
|
+
require_relative '../bolt/analytics'
|
13
|
+
require_relative '../bolt/application'
|
14
|
+
require_relative '../bolt/bolt_option_parser'
|
15
|
+
require_relative '../bolt/config'
|
16
|
+
require_relative '../bolt/error'
|
17
|
+
require_relative '../bolt/executor'
|
18
|
+
require_relative '../bolt/inventory'
|
19
|
+
require_relative '../bolt/logger'
|
20
|
+
require_relative '../bolt/module_installer'
|
21
|
+
require_relative '../bolt/outputter'
|
22
|
+
require_relative '../bolt/pal'
|
23
|
+
require_relative '../bolt/plugin'
|
24
|
+
require_relative '../bolt/project_manager'
|
25
|
+
require_relative '../bolt/puppetdb'
|
26
|
+
require_relative '../bolt/rerun'
|
27
|
+
require_relative '../bolt/target'
|
28
|
+
require_relative '../bolt/version'
|
29
29
|
|
30
30
|
module Bolt
|
31
31
|
class CLIExit < StandardError; end
|
@@ -44,6 +44,7 @@ module Bolt
|
|
44
44
|
'module' => %w[add generate-types install show],
|
45
45
|
'plan' => %w[show run convert new],
|
46
46
|
'plugin' => %w[show],
|
47
|
+
'policy' => %w[apply new show],
|
47
48
|
'project' => %w[init migrate],
|
48
49
|
'script' => %w[run],
|
49
50
|
'secret' => %w[encrypt decrypt createkeys],
|
@@ -53,8 +54,7 @@ module Bolt
|
|
53
54
|
TARGETING_OPTIONS = %i[query rerun targets].freeze
|
54
55
|
|
55
56
|
SUCCESS = 0
|
56
|
-
|
57
|
-
FAILURE = 2
|
57
|
+
FAILURE = 1
|
58
58
|
|
59
59
|
def initialize(argv)
|
60
60
|
Bolt::Logger.initialize_logging
|
@@ -288,6 +288,26 @@ module Bolt
|
|
288
288
|
raise Bolt::CLIError, "Must specify a plan."
|
289
289
|
end
|
290
290
|
|
291
|
+
if options[:subcommand] == 'policy'
|
292
|
+
if options[:action] == 'apply' && !options[:object]
|
293
|
+
raise Bolt::CLIError, "Must specify one or more policies to apply."
|
294
|
+
end
|
295
|
+
|
296
|
+
if options[:action] == 'apply' && options[:leftovers].any?
|
297
|
+
raise Bolt::CLIError, "Unknown argument(s) #{options[:leftovers].join(', ')}. "\
|
298
|
+
"To apply multiple policies, provide a comma-separated list of "\
|
299
|
+
"policy names."
|
300
|
+
end
|
301
|
+
|
302
|
+
if options[:action] == 'new' && !options[:object]
|
303
|
+
raise Bolt::CLIError, "Must specify a name for the new policy."
|
304
|
+
end
|
305
|
+
|
306
|
+
if options[:action] == 'show' && options[:object]
|
307
|
+
raise Bolt::CLIError, "Unknown argument #{options[:object]}."
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
291
311
|
if options[:subcommand] == 'module' && options[:action] == 'install' && options[:object]
|
292
312
|
command = Bolt::Util.powershell? ? 'Add-BoltModule -Module' : 'bolt module add'
|
293
313
|
raise Bolt::CLIError, "Invalid argument '#{options[:object]}'. To add a new module to "\
|
@@ -325,7 +345,9 @@ module Bolt
|
|
325
345
|
end
|
326
346
|
|
327
347
|
if options[:noop] &&
|
328
|
-
!(options[:subcommand] == 'task' && options[:action] == 'run') &&
|
348
|
+
!(options[:subcommand] == 'task' && options[:action] == 'run') &&
|
349
|
+
options[:subcommand] != 'apply' &&
|
350
|
+
options[:action] != 'apply'
|
329
351
|
raise Bolt::CLIError,
|
330
352
|
"Option '--noop' can only be specified when running a task or applying manifest code"
|
331
353
|
end
|
@@ -447,7 +469,7 @@ module Bolt
|
|
447
469
|
check_gem_install
|
448
470
|
warn_inventory_overrides_cli(config, options)
|
449
471
|
submit_screen_view(analytics, config, inventory, options)
|
450
|
-
options[:targets] = process_target_list(plugins
|
472
|
+
options[:targets] = process_target_list(plugins, @rerun, options)
|
451
473
|
|
452
474
|
# TODO: Fix casing issue in Windows.
|
453
475
|
config.check_path_case('modulepath', config.modulepath)
|
@@ -632,6 +654,26 @@ module Bolt
|
|
632
654
|
outputter.print_plugin_list(**app.list_plugins)
|
633
655
|
SUCCESS
|
634
656
|
|
657
|
+
when 'policy'
|
658
|
+
Bolt::Logger.warn('policy_command', 'This command is experimental and is subject to change.')
|
659
|
+
case action
|
660
|
+
when 'apply'
|
661
|
+
results = outputter.spin do
|
662
|
+
app.apply_policies(options[:object], options[:targets], **options.slice(:noop))
|
663
|
+
end
|
664
|
+
rerun.update(results)
|
665
|
+
app.shutdown
|
666
|
+
outputter.print_apply_result(results)
|
667
|
+
results.ok? ? SUCCESS : FAILURE
|
668
|
+
when 'new'
|
669
|
+
result = app.new_policy(options[:object])
|
670
|
+
outputter.print_new_policy(**result)
|
671
|
+
SUCCESS
|
672
|
+
when 'show'
|
673
|
+
outputter.print_policy_list(**app.list_policies)
|
674
|
+
SUCCESS
|
675
|
+
end
|
676
|
+
|
635
677
|
when 'project'
|
636
678
|
case action
|
637
679
|
when 'init'
|
@@ -690,14 +732,14 @@ module Bolt
|
|
690
732
|
# Process the target list by turning a PuppetDB query or rerun mode into a
|
691
733
|
# list of target names.
|
692
734
|
#
|
693
|
-
# @param
|
735
|
+
# @param plugins [Bolt::Plugin] The Plugin instance.
|
694
736
|
# @param rerun [Bolt::Rerun] The Rerun instance.
|
695
737
|
# @param options [Hash] The CLI options.
|
696
738
|
# @return [Hash] The target list.
|
697
739
|
#
|
698
|
-
private def process_target_list(
|
740
|
+
private def process_target_list(plugins, rerun, options)
|
699
741
|
if options[:query]
|
700
|
-
|
742
|
+
plugins.puppetdb_client.query_certnames(options[:query])
|
701
743
|
elsif options[:rerun]
|
702
744
|
rerun.get_targets(options[:rerun])
|
703
745
|
elsif options[:targets]
|
data/lib/bolt/config/options.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
require_relative '../../bolt/config/transport/docker'
|
4
|
+
require_relative '../../bolt/config/transport/local'
|
5
|
+
require_relative '../../bolt/config/transport/lxd'
|
6
|
+
require_relative '../../bolt/config/transport/orch'
|
7
|
+
require_relative '../../bolt/config/transport/podman'
|
8
|
+
require_relative '../../bolt/config/transport/remote'
|
9
|
+
require_relative '../../bolt/config/transport/ssh'
|
10
|
+
require_relative '../../bolt/config/transport/winrm'
|
11
11
|
|
12
12
|
module Bolt
|
13
13
|
class Config
|
@@ -147,14 +147,23 @@ module Bolt
|
|
147
147
|
type: Hash,
|
148
148
|
properties: {
|
149
149
|
"file_paths" => {
|
150
|
-
description: "Load scripts from the `scripts/` directory of a module",
|
150
|
+
description: "Load scripts from the `scripts/` directory of a module.",
|
151
|
+
type: [TrueClass, FalseClass],
|
152
|
+
_example: true,
|
153
|
+
_default: false,
|
154
|
+
_deprecation: "Bolt no longer honors this option and enables loading scripts from the scripts "\
|
155
|
+
"directory by default."
|
156
|
+
},
|
157
|
+
"script_interpreter" => {
|
158
|
+
description: "Use a target's [`interpreters` configuration](bolt_transports_reference.md#interpreters) "\
|
159
|
+
"when running a script.",
|
151
160
|
type: [TrueClass, FalseClass],
|
152
161
|
_example: true,
|
153
162
|
_default: false
|
154
163
|
}
|
155
164
|
},
|
156
165
|
_plugin: false,
|
157
|
-
_example: { '
|
166
|
+
_example: { 'script_interpreter' => true }
|
158
167
|
},
|
159
168
|
"hiera-config" => {
|
160
169
|
description: "The path to the Hiera configuration file.",
|
@@ -248,10 +257,16 @@ module Bolt
|
|
248
257
|
type: Hash,
|
249
258
|
properties: {
|
250
259
|
"forge" => {
|
251
|
-
description: "A subsection
|
252
|
-
"operations only, and a `baseurl` setting to specify a different Forge host.",
|
260
|
+
description: "A subsection for configuring connections to a Forge host.",
|
253
261
|
type: Hash,
|
254
262
|
properties: {
|
263
|
+
"authorization_token" => {
|
264
|
+
description: "The token used to authorize requests to the Forge host. Must also specify "\
|
265
|
+
"`baseurl` when using this option.",
|
266
|
+
type: String,
|
267
|
+
_example: "Bearer eyJhbGciOiJIUzI1NiIsInR5c...",
|
268
|
+
_plugin: true
|
269
|
+
},
|
255
270
|
"baseurl" => {
|
256
271
|
description: "The URL to the Forge host.",
|
257
272
|
type: String,
|
@@ -265,7 +280,11 @@ module Bolt
|
|
265
280
|
_example: "https://my-forge-proxy.com:8080"
|
266
281
|
}
|
267
282
|
},
|
268
|
-
_example: {
|
283
|
+
_example: {
|
284
|
+
"authorization_token" => "Bearer eyJhbGciOiJIUzI1NiIsInR5c...",
|
285
|
+
"baseurl" => "https://forge.example.com",
|
286
|
+
"proxy" => "https://my-forge-proxy.com:8080"
|
287
|
+
}
|
269
288
|
},
|
270
289
|
"proxy" => {
|
271
290
|
description: "The HTTP proxy to use for Git and Forge operations.",
|
@@ -377,6 +396,15 @@ module Bolt
|
|
377
396
|
_plugin: false,
|
378
397
|
_example: { "pkcs7" => { "keysize" => 1024 } }
|
379
398
|
},
|
399
|
+
"policies" => {
|
400
|
+
description: "A list of policy names and glob patterns to filter the project's policies by. This option "\
|
401
|
+
"is used to specify which policies are available to a project and can be applied to targets. "\
|
402
|
+
"When this option is not configured, policies are not available to the project and cannot "\
|
403
|
+
"be applied to targets.",
|
404
|
+
type: Array,
|
405
|
+
_plugin: false,
|
406
|
+
_example: ["myproject::apache", "myproject::postgres"]
|
407
|
+
},
|
380
408
|
"puppetdb" => {
|
381
409
|
description: "A map containing options for [configuring the Bolt PuppetDB "\
|
382
410
|
"client](bolt_connect_puppetdb.md).",
|
@@ -600,6 +628,7 @@ module Bolt
|
|
600
628
|
plugin-cache
|
601
629
|
plugin-hooks
|
602
630
|
plugins
|
631
|
+
policies
|
603
632
|
puppetdb
|
604
633
|
save-rerun
|
605
634
|
spinner
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
require_relative '../../../bolt/error'
|
4
|
+
require_relative '../../../bolt/util'
|
5
|
+
require_relative '../../../bolt/validator'
|
6
|
+
require_relative '../../../bolt/config/transport/options'
|
7
7
|
|
8
8
|
module Bolt
|
9
9
|
class Config
|
@@ -155,14 +155,15 @@ module Bolt
|
|
155
155
|
"`task.py`) and the extension is case sensitive. When a target's name is `localhost`, "\
|
156
156
|
"Ruby tasks run with the Bolt Ruby interpreter by default.",
|
157
157
|
additionalProperties: {
|
158
|
-
type: String,
|
158
|
+
type: [String, Array],
|
159
159
|
_plugin: false
|
160
160
|
},
|
161
161
|
propertyNames: {
|
162
162
|
pattern: "^.?[a-zA-Z0-9]+$"
|
163
163
|
},
|
164
164
|
_plugin: true,
|
165
|
-
_example: { "rb" => "/usr/bin/ruby"
|
165
|
+
_example: { "rb" => ["/usr/bin/ruby", "-r", "puppet"],
|
166
|
+
".py" => "/usr/bin/python3" }
|
166
167
|
},
|
167
168
|
"job-poll-interval" => {
|
168
169
|
type: Integer,
|