chef-dk 3.13.1 → 4.0.60
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +33 -25
- data/Gemfile.lock +317 -293
- data/LICENSE +0 -0
- data/Rakefile +0 -0
- data/bin/chef +1 -1
- data/chef-dk.gemspec +3 -3
- data/lib/chef-dk.rb +0 -0
- data/lib/chef-dk/authenticated_http.rb +0 -0
- data/lib/chef-dk/builtin_commands.rb +1 -3
- data/lib/chef-dk/chef_runner.rb +0 -0
- data/lib/chef-dk/chef_server_api_multi.rb +0 -0
- data/lib/chef-dk/cli.rb +2 -3
- data/lib/chef-dk/command/base.rb +9 -1
- data/lib/chef-dk/command/clean_policy_cookbooks.rb +2 -3
- data/lib/chef-dk/command/clean_policy_revisions.rb +3 -4
- data/lib/chef-dk/command/delete_policy.rb +1 -1
- data/lib/chef-dk/command/delete_policy_group.rb +1 -2
- data/lib/chef-dk/command/describe_cookbook.rb +5 -4
- data/lib/chef-dk/command/diff.rb +7 -9
- data/lib/chef-dk/command/env.rb +0 -0
- data/lib/chef-dk/command/exec.rb +0 -0
- data/lib/chef-dk/command/export.rb +0 -1
- data/lib/chef-dk/command/gem.rb +0 -0
- data/lib/chef-dk/command/generate.rb +1 -6
- data/lib/chef-dk/command/generator_commands.rb +0 -0
- data/lib/chef-dk/command/generator_commands/attribute.rb +0 -0
- data/lib/chef-dk/command/generator_commands/base.rb +0 -0
- data/lib/chef-dk/command/generator_commands/build_cookbook.rb +7 -7
- data/lib/chef-dk/command/generator_commands/chef_exts/generator_desc_resource.rb +4 -49
- data/lib/chef-dk/command/generator_commands/chef_exts/quieter_doc_formatter.rb +0 -0
- data/lib/chef-dk/command/generator_commands/chef_exts/recipe_dsl_ext.rb +0 -0
- data/lib/chef-dk/command/generator_commands/cookbook.rb +22 -23
- data/lib/chef-dk/command/generator_commands/cookbook_code_file.rb +0 -0
- data/lib/chef-dk/command/generator_commands/cookbook_file.rb +0 -0
- data/lib/chef-dk/command/generator_commands/generator_generator.rb +0 -0
- data/lib/chef-dk/command/generator_commands/helpers.rb +0 -0
- data/lib/chef-dk/command/generator_commands/policyfile.rb +0 -0
- data/lib/chef-dk/command/generator_commands/recipe.rb +0 -0
- data/lib/chef-dk/command/generator_commands/repo.rb +25 -9
- data/lib/chef-dk/command/generator_commands/resource.rb +0 -0
- data/lib/chef-dk/command/generator_commands/template.rb +0 -0
- data/lib/chef-dk/command/install.rb +1 -2
- data/lib/chef-dk/command/provision.rb +2 -404
- data/lib/chef-dk/command/push.rb +1 -2
- data/lib/chef-dk/command/push_archive.rb +2 -2
- data/lib/chef-dk/command/shell_init.rb +9 -5
- data/lib/chef-dk/command/show_policy.rb +0 -1
- data/lib/chef-dk/command/undelete.rb +0 -1
- data/lib/chef-dk/command/update.rb +0 -1
- data/lib/chef-dk/command/verify.rb +13 -110
- data/lib/chef-dk/commands_map.rb +0 -0
- data/lib/chef-dk/completions/bash.sh.erb +0 -0
- data/lib/chef-dk/completions/chef.fish.erb +0 -0
- data/lib/chef-dk/completions/zsh.zsh.erb +0 -0
- data/lib/chef-dk/component_test.rb +4 -2
- data/lib/chef-dk/configurable.rb +0 -1
- data/lib/chef-dk/cookbook_metadata.rb +0 -0
- data/lib/chef-dk/cookbook_omnifetch.rb +0 -0
- data/lib/chef-dk/cookbook_profiler/git.rb +0 -0
- data/lib/chef-dk/cookbook_profiler/identifiers.rb +0 -0
- data/lib/chef-dk/cookbook_profiler/null_scm.rb +0 -0
- data/lib/chef-dk/exceptions.rb +1 -1
- data/lib/chef-dk/generator.rb +1 -1
- data/lib/chef-dk/helpers.rb +1 -2
- data/lib/chef-dk/pager.rb +0 -0
- data/lib/chef-dk/policyfile/artifactory_cookbook_source.rb +0 -0
- data/lib/chef-dk/policyfile/attribute_merge_checker.rb +0 -0
- data/lib/chef-dk/policyfile/chef_repo_cookbook_source.rb +0 -0
- data/lib/chef-dk/policyfile/chef_server_cookbook_source.rb +0 -0
- data/lib/chef-dk/policyfile/chef_server_lock_fetcher.rb +2 -2
- data/lib/chef-dk/policyfile/community_cookbook_source.rb +0 -0
- data/lib/chef-dk/policyfile/comparison_base.rb +0 -0
- data/lib/chef-dk/policyfile/cookbook_location_specification.rb +0 -0
- data/lib/chef-dk/policyfile/cookbook_locks.rb +1 -1
- data/lib/chef-dk/policyfile/cookbook_sources.rb +0 -0
- data/lib/chef-dk/policyfile/delivery_supermarket_source.rb +0 -0
- data/lib/chef-dk/policyfile/differ.rb +0 -0
- data/lib/chef-dk/policyfile/dsl.rb +1 -1
- data/lib/chef-dk/policyfile/git_lock_fetcher.rb +0 -0
- data/lib/chef-dk/policyfile/included_policies_cookbook_source.rb +0 -0
- data/lib/chef-dk/policyfile/lister.rb +0 -0
- data/lib/chef-dk/policyfile/local_lock_fetcher.rb +0 -0
- data/lib/chef-dk/policyfile/lock_applier.rb +0 -0
- data/lib/chef-dk/policyfile/lock_fetcher_mixin.rb +0 -0
- data/lib/chef-dk/policyfile/null_cookbook_source.rb +0 -0
- data/lib/chef-dk/policyfile/policyfile_location_specification.rb +0 -0
- data/lib/chef-dk/policyfile/read_cookbook_for_compat_mode_upload.rb +0 -0
- data/lib/chef-dk/policyfile/remote_lock_fetcher.rb +0 -0
- data/lib/chef-dk/policyfile/reports/install.rb +0 -0
- data/lib/chef-dk/policyfile/reports/table_printer.rb +0 -0
- data/lib/chef-dk/policyfile/reports/upload.rb +0 -0
- data/lib/chef-dk/policyfile/solution_dependencies.rb +1 -1
- data/lib/chef-dk/policyfile/source_uri.rb +0 -0
- data/lib/chef-dk/policyfile/storage_config.rb +0 -0
- data/lib/chef-dk/policyfile/undo_record.rb +0 -0
- data/lib/chef-dk/policyfile/undo_stack.rb +0 -0
- data/lib/chef-dk/policyfile/uploader.rb +0 -0
- data/lib/chef-dk/policyfile_compiler.rb +2 -4
- data/lib/chef-dk/policyfile_lock.rb +1 -3
- data/lib/chef-dk/policyfile_services/clean_policies.rb +0 -0
- data/lib/chef-dk/policyfile_services/clean_policy_cookbooks.rb +0 -0
- data/lib/chef-dk/policyfile_services/export_repo.rb +6 -6
- data/lib/chef-dk/policyfile_services/install.rb +0 -0
- data/lib/chef-dk/policyfile_services/push.rb +0 -0
- data/lib/chef-dk/policyfile_services/push_archive.rb +2 -2
- data/lib/chef-dk/policyfile_services/rm_policy.rb +0 -0
- data/lib/chef-dk/policyfile_services/rm_policy_group.rb +0 -0
- data/lib/chef-dk/policyfile_services/show_policy.rb +0 -0
- data/lib/chef-dk/policyfile_services/undelete.rb +0 -0
- data/lib/chef-dk/policyfile_services/update_attributes.rb +0 -0
- data/lib/chef-dk/service_exception_inspectors.rb +0 -0
- data/lib/chef-dk/service_exception_inspectors/base.rb +0 -0
- data/lib/chef-dk/service_exception_inspectors/http.rb +0 -0
- data/lib/chef-dk/service_exceptions.rb +0 -0
- data/lib/chef-dk/shell_out.rb +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/Berksfile +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/build_cookbook/README.md +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/build_cookbook/kitchen.yml +1 -1
- data/lib/chef-dk/skeletons/code_generator/files/default/build_cookbook/test-fixture-recipe.rb +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/chefignore +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/cookbook_readmes/README-policy.md +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/cookbook_readmes/README.md +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/delivery-config.json +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/delivery-project.toml +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/gitignore +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/README.md +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/README.md +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/metadata.rb +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/data_bags/README.md +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/data_bags/example/example_item.json +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/dot-chef-repo.txt +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/environments/README.md +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/environments/example.json +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/policyfiles/README.md +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/roles/README.md +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/roles/example.json +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/spec_helper.rb +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/spec_helper_policyfile.rb +0 -0
- data/lib/chef-dk/skeletons/code_generator/metadata.rb +0 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/attribute.rb +0 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/build_cookbook.rb +20 -20
- data/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb +24 -16
- data/lib/chef-dk/skeletons/code_generator/recipes/cookbook_file.rb +0 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/helpers.rb +0 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/policyfile.rb +0 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/recipe.rb +0 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/repo.rb +7 -3
- data/lib/chef-dk/skeletons/code_generator/recipes/resource.rb +0 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/template.rb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/CHANGELOG.md.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.all_rights.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.apachev2.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.gplv2.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.gplv3.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.mit.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/Policyfile.rb.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/README.md.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/attribute.rb.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/build_cookbook/Berksfile.erb +1 -1
- data/lib/chef-dk/skeletons/code_generator/templates/default/build_cookbook/metadata.rb.erb +1 -1
- data/lib/chef-dk/skeletons/code_generator/templates/default/build_cookbook/recipe.rb.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/cookbook_file.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/helpers.rb.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/inspec_default_test.rb.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/kitchen.yml.erb +1 -1
- data/lib/chef-dk/skeletons/code_generator/templates/default/kitchen_dokken.yml.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +1 -1
- data/lib/chef-dk/skeletons/code_generator/templates/default/metadata.rb.erb +1 -1
- data/lib/chef-dk/skeletons/code_generator/templates/default/recipe.rb.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/recipe_spec.rb.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/repo/gitignore.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/resource.rb.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/template.erb +0 -0
- data/lib/chef-dk/ui.rb +0 -0
- data/lib/chef-dk/version.rb +1 -1
- data/lib/kitchen/provisioner/policyfile_zero.rb +0 -0
- data/spec/shared/a_file_generator.rb +0 -0
- data/spec/shared/a_generated_file.rb +0 -0
- data/spec/shared/command_with_ui_object.rb +0 -0
- data/spec/shared/custom_generator_cookbook.rb +0 -0
- data/spec/shared/fixture_cookbook_checksums.rb +1 -1
- data/spec/shared/setup_git_committer_config.rb +0 -0
- data/spec/shared/setup_git_cookbooks.rb +0 -0
- data/spec/spec_helper.rb +0 -4
- data/spec/test_helpers.rb +0 -0
- data/spec/unit/chef_runner_spec.rb +0 -0
- data/spec/unit/chef_server_api_multi_spec.rb +0 -0
- data/spec/unit/cli_spec.rb +0 -0
- data/spec/unit/command/base_spec.rb +24 -1
- data/spec/unit/command/clean_policy_cookbooks_spec.rb +0 -0
- data/spec/unit/command/clean_policy_revisions_spec.rb +0 -0
- data/spec/unit/command/delete_policy_group_spec.rb +0 -0
- data/spec/unit/command/delete_policy_spec.rb +0 -0
- data/spec/unit/command/diff_spec.rb +0 -0
- data/spec/unit/command/env_spec.rb +1 -1
- data/spec/unit/command/exec_spec.rb +1 -1
- data/spec/unit/command/export_spec.rb +0 -0
- data/spec/unit/command/generate_spec.rb +0 -0
- data/spec/unit/command/generator_commands/attribute_spec.rb +0 -0
- data/spec/unit/command/generator_commands/base_spec.rb +0 -0
- data/spec/unit/command/generator_commands/build_cookbook_spec.rb +15 -15
- data/spec/unit/command/generator_commands/chef_exts/generator_desc_resource_spec.rb +6 -26
- data/spec/unit/command/generator_commands/chef_exts/recipe_dsl_ext_spec.rb +0 -0
- data/spec/unit/command/generator_commands/cookbook_file_spec.rb +0 -0
- data/spec/unit/command/generator_commands/cookbook_spec.rb +200 -203
- data/spec/unit/command/generator_commands/generator_generator_spec.rb +7 -7
- data/spec/unit/command/generator_commands/helpers_spec.rb +0 -0
- data/spec/unit/command/generator_commands/policyfile_spec.rb +0 -0
- data/spec/unit/command/generator_commands/recipe_spec.rb +1 -2
- data/spec/unit/command/generator_commands/repo_spec.rb +8 -8
- data/spec/unit/command/generator_commands/resource_spec.rb +0 -0
- data/spec/unit/command/generator_commands/template_spec.rb +0 -0
- data/spec/unit/command/install_spec.rb +0 -0
- data/spec/unit/command/push_archive_spec.rb +0 -0
- data/spec/unit/command/push_spec.rb +0 -0
- data/spec/unit/command/shell_init_spec.rb +0 -0
- data/spec/unit/command/show_policy_spec.rb +0 -0
- data/spec/unit/command/undelete_spec.rb +0 -0
- data/spec/unit/command/update_spec.rb +0 -0
- data/spec/unit/command/verify_spec.rb +2 -3
- data/spec/unit/commands_map_spec.rb +0 -0
- data/spec/unit/component_test_spec.rb +0 -0
- data/spec/unit/configurable_spec.rb +0 -0
- data/spec/unit/cookbook_metadata_spec.rb +0 -0
- data/spec/unit/cookbook_profiler/git_spec.rb +0 -0
- data/spec/unit/cookbook_profiler/identifiers_spec.rb +3 -3
- data/spec/unit/fixtures/chef-runner-cookbooks/test_cookbook/recipes/recipe_one.rb +0 -0
- data/spec/unit/fixtures/chef-runner-cookbooks/test_cookbook/recipes/recipe_two.rb +0 -0
- data/spec/unit/fixtures/command/cli_test_command.rb +0 -0
- data/spec/unit/fixtures/command/explicit_path_example.rb +0 -0
- data/spec/unit/fixtures/configurable/test_config_loader.rb +0 -0
- data/spec/unit/fixtures/configurable/test_configurable.rb +0 -0
- data/spec/unit/fixtures/cookbook_cache/baz-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/.kitchen.yml +0 -0
- data/spec/unit/fixtures/cookbook_cache/baz-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/Berksfile +0 -0
- data/spec/unit/fixtures/cookbook_cache/baz-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/README.md +0 -0
- data/spec/unit/fixtures/cookbook_cache/baz-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/chefignore +0 -0
- data/spec/unit/fixtures/cookbook_cache/baz-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/metadata.rb +0 -0
- data/spec/unit/fixtures/cookbook_cache/baz-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/recipes/default.rb +0 -0
- data/spec/unit/fixtures/cookbook_cache/dep_of_bar-1.2.3/.kitchen.yml +0 -0
- data/spec/unit/fixtures/cookbook_cache/dep_of_bar-1.2.3/Berksfile +0 -0
- data/spec/unit/fixtures/cookbook_cache/dep_of_bar-1.2.3/README.md +0 -0
- data/spec/unit/fixtures/cookbook_cache/dep_of_bar-1.2.3/chefignore +0 -0
- data/spec/unit/fixtures/cookbook_cache/dep_of_bar-1.2.3/metadata.rb +0 -0
- data/spec/unit/fixtures/cookbook_cache/dep_of_bar-1.2.3/recipes/default.rb +0 -0
- data/spec/unit/fixtures/cookbook_cache/foo-1.0.0/Berksfile +0 -0
- data/spec/unit/fixtures/cookbook_cache/foo-1.0.0/README.md +0 -0
- data/spec/unit/fixtures/cookbook_cache/foo-1.0.0/chefignore +0 -0
- data/spec/unit/fixtures/cookbook_cache/foo-1.0.0/{.kitchen.yml → kitchen.yml} +0 -0
- data/spec/unit/fixtures/cookbook_cache/foo-1.0.0/metadata.rb +0 -0
- data/spec/unit/fixtures/cookbook_cache/foo-1.0.0/recipes/default.rb +0 -0
- data/spec/unit/fixtures/cookbooks_api/chef_server_universe.json +0 -0
- data/spec/unit/fixtures/cookbooks_api/pruned_chef_server_universe.json +0 -0
- data/spec/unit/fixtures/cookbooks_api/pruned_small_universe.json +0 -0
- data/spec/unit/fixtures/cookbooks_api/small_universe.json +0 -0
- data/spec/unit/fixtures/cookbooks_api/universe.json +0 -0
- data/spec/unit/fixtures/cookbooks_api/update_fixtures.rb +0 -0
- data/spec/unit/fixtures/dev_cookbooks/README.md +0 -0
- data/spec/unit/fixtures/dev_cookbooks/bar-cookbook.gitbundle +0 -0
- data/spec/unit/fixtures/eg_omnibus_dir/missing_apps/bin/.keep +0 -0
- data/spec/unit/fixtures/eg_omnibus_dir/missing_apps/embedded/.keep +0 -0
- data/spec/unit/fixtures/eg_omnibus_dir/missing_apps/embedded/bin/.keep +0 -0
- data/spec/unit/fixtures/eg_omnibus_dir/missing_component/bin/.keep +0 -0
- data/spec/unit/fixtures/eg_omnibus_dir/missing_component/embedded/apps/berkshelf/.keep +0 -0
- data/spec/unit/fixtures/eg_omnibus_dir/missing_component/embedded/apps/test-kitchen/.keep +0 -0
- data/spec/unit/fixtures/eg_omnibus_dir/missing_component/embedded/bin/.keep +0 -0
- data/spec/unit/fixtures/eg_omnibus_dir/valid/bin/.keep +0 -0
- data/spec/unit/fixtures/eg_omnibus_dir/valid/embedded/apps/chef-dk/.keep +0 -0
- data/spec/unit/fixtures/eg_omnibus_dir/valid/embedded/bin/.keep +0 -0
- data/spec/unit/fixtures/example_app/Policyfile.rb +0 -0
- data/spec/unit/fixtures/example_cookbook/.gitignore +0 -0
- data/spec/unit/fixtures/example_cookbook/.kitchen.yml +0 -0
- data/spec/unit/fixtures/example_cookbook/Berksfile +0 -0
- data/spec/unit/fixtures/example_cookbook/README.md +0 -0
- data/spec/unit/fixtures/example_cookbook/chefignore +0 -0
- data/spec/unit/fixtures/example_cookbook/metadata.rb +0 -0
- data/spec/unit/fixtures/example_cookbook/recipes/default.rb +0 -0
- data/spec/unit/fixtures/example_cookbook_metadata_json_only/.gitignore +0 -0
- data/spec/unit/fixtures/example_cookbook_metadata_json_only/.kitchen.yml +0 -0
- data/spec/unit/fixtures/example_cookbook_metadata_json_only/Berksfile +0 -0
- data/spec/unit/fixtures/example_cookbook_metadata_json_only/README.md +0 -0
- data/spec/unit/fixtures/example_cookbook_metadata_json_only/chefignore +0 -0
- data/spec/unit/fixtures/example_cookbook_metadata_json_only/metadata.json +0 -0
- data/spec/unit/fixtures/example_cookbook_metadata_json_only/recipes/default.rb +0 -0
- data/spec/unit/fixtures/example_cookbook_no_metadata/.gitignore +0 -0
- data/spec/unit/fixtures/example_cookbook_no_metadata/.kitchen.yml +0 -0
- data/spec/unit/fixtures/example_cookbook_no_metadata/Berksfile +0 -0
- data/spec/unit/fixtures/example_cookbook_no_metadata/README.md +0 -0
- data/spec/unit/fixtures/example_cookbook_no_metadata/chefignore +0 -0
- data/spec/unit/fixtures/example_cookbook_no_metadata/recipes/default.rb +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/README.md +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/chefignore +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/metadata.rb +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/recipes/default.rb +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/cookbook-with-a-dep/Berksfile +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/cookbook-with-a-dep/README.md +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/cookbook-with-a-dep/chefignore +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/cookbook-with-a-dep/metadata.rb +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/cookbook-with-a-dep/recipes/default.rb +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/local-cookbook/.kitchen.yml +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/local-cookbook/Berksfile +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/local-cookbook/README.md +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/local-cookbook/chefignore +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/local-cookbook/extra/extra_file.txt +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/local-cookbook/metadata.rb +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/local-cookbook/recipes/default.rb +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/metadata-missing/README.md +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/.kitchen.yml +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/README.md +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/metadata.rb +0 -0
- data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/recipes/default.rb +0 -0
- data/spec/unit/generator_spec.rb +0 -0
- data/spec/unit/pager_spec.rb +0 -0
- data/spec/unit/policyfile/artifactory_cookbook_source_spec.rb +0 -0
- data/spec/unit/policyfile/attribute_merge_checker_spec.rb +0 -0
- data/spec/unit/policyfile/chef_repo_cookbook_source_spec.rb +0 -0
- data/spec/unit/policyfile/chef_server_cookbook_source_spec.rb +0 -0
- data/spec/unit/policyfile/chef_server_lock_fetcher_spec.rb +0 -0
- data/spec/unit/policyfile/community_cookbook_source_spec.rb +0 -0
- data/spec/unit/policyfile/comparison_base_spec.rb +0 -0
- data/spec/unit/policyfile/cookbook_location_specification_spec.rb +0 -0
- data/spec/unit/policyfile/cookbook_locks_spec.rb +0 -0
- data/spec/unit/policyfile/delivery_supermarket_source_spec.rb +0 -0
- data/spec/unit/policyfile/differ_spec.rb +0 -0
- data/spec/unit/policyfile/git_lock_fetcher_spec.rb +0 -0
- data/spec/unit/policyfile/included_policies_cookbook_source_spec.rb +0 -0
- data/spec/unit/policyfile/lister_spec.rb +0 -0
- data/spec/unit/policyfile/local_lock_fetcher_spec.rb +0 -0
- data/spec/unit/policyfile/lock_applier_spec.rb +0 -0
- data/spec/unit/policyfile/lock_fetcher_mixin_spec.rb +0 -0
- data/spec/unit/policyfile/null_cookbook_source_spec.rb +0 -0
- data/spec/unit/policyfile/read_cookbook_for_compat_mode_upload_spec.rb +0 -0
- data/spec/unit/policyfile/remote_lock_fetcher_spec.rb +0 -0
- data/spec/unit/policyfile/reports/install_spec.rb +0 -0
- data/spec/unit/policyfile/reports/upload_spec.rb +0 -0
- data/spec/unit/policyfile/solution_dependencies_spec.rb +0 -0
- data/spec/unit/policyfile/source_uri_spec.rb +0 -0
- data/spec/unit/policyfile/storage_config_spec.rb +0 -0
- data/spec/unit/policyfile/undo_record_spec.rb +0 -0
- data/spec/unit/policyfile/undo_stack_spec.rb +0 -0
- data/spec/unit/policyfile/uploader_spec.rb +0 -0
- data/spec/unit/policyfile_demands_spec.rb +0 -0
- data/spec/unit/policyfile_evaluation_spec.rb +0 -0
- data/spec/unit/policyfile_includes_dsl_spec.rb +0 -0
- data/spec/unit/policyfile_includes_spec.rb +0 -0
- data/spec/unit/policyfile_install_with_includes_spec.rb +0 -0
- data/spec/unit/policyfile_lock_build_spec.rb +2 -2
- data/spec/unit/policyfile_lock_install_spec.rb +0 -0
- data/spec/unit/policyfile_lock_serialization_spec.rb +0 -0
- data/spec/unit/policyfile_lock_validation_spec.rb +0 -0
- data/spec/unit/policyfile_services/clean_policies_spec.rb +0 -0
- data/spec/unit/policyfile_services/clean_policy_cookbooks_spec.rb +0 -0
- data/spec/unit/policyfile_services/export_repo_spec.rb +6 -6
- data/spec/unit/policyfile_services/install_spec.rb +0 -0
- data/spec/unit/policyfile_services/push_archive_spec.rb +2 -2
- data/spec/unit/policyfile_services/push_spec.rb +0 -0
- data/spec/unit/policyfile_services/rm_policy_group_spec.rb +0 -0
- data/spec/unit/policyfile_services/rm_policy_spec.rb +0 -0
- data/spec/unit/policyfile_services/show_policy_spec.rb +0 -0
- data/spec/unit/policyfile_services/undelete_spec.rb +0 -0
- data/spec/unit/policyfile_services/update_attributes_spec.rb +0 -0
- data/spec/unit/policyfile_services/update_spec.rb +0 -0
- data/spec/unit/service_exception_inspectors/base_spec.rb +0 -0
- data/spec/unit/service_exception_inspectors/http_spec.rb +1 -1
- data/spec/unit/shell_out_spec.rb +0 -0
- data/warning.txt +3 -2
- metadata +20 -19
- data/lib/chef-dk/command/generator_commands/app.rb +0 -106
- data/lib/chef-dk/skeletons/code_generator/recipes/app.rb +0 -87
- data/spec/unit/command/generator_commands/app_spec.rb +0 -166
- data/spec/unit/command/provision_spec.rb +0 -589
File without changes
|
File without changes
|
@@ -38,28 +38,28 @@ module ChefDK
|
|
38
38
|
option :berks,
|
39
39
|
short: "-b",
|
40
40
|
long: "--berks",
|
41
|
-
description: "Generate cookbooks
|
41
|
+
description: "Generate cookbooks using Berkshelf dependency resolution.",
|
42
42
|
boolean: true,
|
43
43
|
default: nil
|
44
44
|
|
45
45
|
option :kitchen,
|
46
46
|
long: "--kitchen CONFIGURATION",
|
47
|
-
description: "Generate cookbooks with a specific
|
47
|
+
description: "Generate cookbooks with a specific Test Kitchen configuration (dokken|vagrant) - defaults to vagrant",
|
48
48
|
default: "vagrant"
|
49
49
|
|
50
50
|
option :policy,
|
51
51
|
short: "-P",
|
52
52
|
long: "--policy",
|
53
|
-
description: "
|
53
|
+
description: "Generate a cookbook using Policyfile dependency resolution (default).",
|
54
54
|
boolean: true,
|
55
55
|
default: nil
|
56
56
|
|
57
|
-
option :
|
58
|
-
short: "-
|
59
|
-
long: "--
|
60
|
-
description: "
|
57
|
+
option :workflow,
|
58
|
+
short: "-w",
|
59
|
+
long: "--workflow",
|
60
|
+
description: "Generate a cookbook with a full Chef Workflow (Delivery) build cookbook.",
|
61
61
|
boolean: true,
|
62
|
-
default:
|
62
|
+
default: false
|
63
63
|
|
64
64
|
option :verbose,
|
65
65
|
short: "-V",
|
@@ -69,17 +69,16 @@ module ChefDK
|
|
69
69
|
default: false
|
70
70
|
|
71
71
|
option :pipeline,
|
72
|
-
long:
|
73
|
-
description:
|
74
|
-
default:
|
72
|
+
long: "--pipeline PIPELINE",
|
73
|
+
description: "Use PIPELINE to set target branch to something other than master for the Workflow build_cookbook",
|
74
|
+
default: "master"
|
75
75
|
|
76
76
|
options.merge!(SharedGeneratorOptions.options)
|
77
77
|
|
78
78
|
def initialize(params)
|
79
79
|
@params_valid = true
|
80
80
|
@cookbook_name = nil
|
81
|
-
@
|
82
|
-
@enable_delivery = true
|
81
|
+
@policy_mode = true
|
83
82
|
@verbose = false
|
84
83
|
super
|
85
84
|
end
|
@@ -127,14 +126,14 @@ module ChefDK
|
|
127
126
|
Generator.add_attr_to_context(:policy_run_list, policy_run_list)
|
128
127
|
Generator.add_attr_to_context(:policy_local_cookbook, ".")
|
129
128
|
|
130
|
-
Generator.add_attr_to_context(:
|
131
|
-
Generator.add_attr_to_context(:
|
129
|
+
Generator.add_attr_to_context(:enable_workflow, enable_workflow?)
|
130
|
+
Generator.add_attr_to_context(:workflow_project_dir, cookbook_full_path)
|
132
131
|
Generator.add_attr_to_context(:build_cookbook_parent_is_cookbook, true)
|
133
|
-
Generator.add_attr_to_context(:
|
132
|
+
Generator.add_attr_to_context(:workflow_project_git_initialized, have_git? && !cookbook_path_in_git_repo?)
|
134
133
|
|
135
134
|
Generator.add_attr_to_context(:verbose, verbose?)
|
136
135
|
|
137
|
-
Generator.add_attr_to_context(:
|
136
|
+
Generator.add_attr_to_context(:use_policyfile, policy_mode?)
|
138
137
|
Generator.add_attr_to_context(:pipeline, pipeline)
|
139
138
|
Generator.add_attr_to_context(:kitchen, kitchen)
|
140
139
|
end
|
@@ -175,12 +174,12 @@ module ChefDK
|
|
175
174
|
File.expand_path(cookbook_name_or_path, Dir.pwd)
|
176
175
|
end
|
177
176
|
|
178
|
-
def
|
179
|
-
@
|
177
|
+
def policy_mode?
|
178
|
+
@policy_mode
|
180
179
|
end
|
181
180
|
|
182
|
-
def
|
183
|
-
|
181
|
+
def enable_workflow?
|
182
|
+
config[:workflow]
|
184
183
|
end
|
185
184
|
|
186
185
|
def verbose?
|
@@ -224,8 +223,8 @@ module ChefDK
|
|
224
223
|
@params_valid = false
|
225
224
|
end
|
226
225
|
|
227
|
-
if config[:
|
228
|
-
@
|
226
|
+
if config[:berks]
|
227
|
+
@policy_mode = false
|
229
228
|
end
|
230
229
|
|
231
230
|
if config[:verbose]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -35,28 +35,36 @@ module ChefDK
|
|
35
35
|
option :policy_only,
|
36
36
|
short: "-p",
|
37
37
|
long: "--policy-only",
|
38
|
-
description: "Create a repository
|
38
|
+
description: "Create a repository to store Policyfiles only, not cookbooks.",
|
39
39
|
default: false
|
40
40
|
|
41
41
|
option :roles,
|
42
42
|
short: "-r",
|
43
43
|
long: "--roles",
|
44
|
-
description: "Create roles and environments directories instead of using
|
44
|
+
description: "Create roles and environments directories instead of using Policyfiles.",
|
45
45
|
default: nil
|
46
46
|
|
47
47
|
option :policy,
|
48
48
|
short: "-P",
|
49
49
|
long: "--policy",
|
50
|
-
description: "Use
|
50
|
+
description: "Use Policyfiles instead of roles and environments.",
|
51
51
|
boolean: true,
|
52
52
|
default: nil
|
53
53
|
|
54
|
+
option :verbose,
|
55
|
+
short: "-V",
|
56
|
+
long: "--verbose",
|
57
|
+
description: "Show detailed output from the generator",
|
58
|
+
boolean: true,
|
59
|
+
default: false
|
60
|
+
|
54
61
|
options.merge!(SharedGeneratorOptions.options)
|
55
62
|
|
56
63
|
def initialize(params)
|
57
64
|
@params_valid = true
|
58
65
|
@repo_name = nil
|
59
|
-
@
|
66
|
+
@use_policy = true
|
67
|
+
@verbose = false
|
60
68
|
super
|
61
69
|
end
|
62
70
|
|
@@ -64,7 +72,10 @@ module ChefDK
|
|
64
72
|
read_and_validate_params
|
65
73
|
if params_valid?
|
66
74
|
setup_context
|
75
|
+
msg("Generating Chef Infra repo #{repo_name}")
|
67
76
|
chef_runner.converge
|
77
|
+
msg("")
|
78
|
+
msg("Your new Chef Infra repo is ready! Type `cd #{repo_name}` to enter it.")
|
68
79
|
0
|
69
80
|
else
|
70
81
|
err(opt_parser)
|
@@ -74,9 +85,10 @@ module ChefDK
|
|
74
85
|
|
75
86
|
def setup_context
|
76
87
|
super
|
88
|
+
Generator.add_attr_to_context(:verbose, verbose?)
|
77
89
|
Generator.add_attr_to_context(:repo_root, repo_root)
|
78
90
|
Generator.add_attr_to_context(:repo_name, repo_name)
|
79
|
-
Generator.add_attr_to_context(:
|
91
|
+
Generator.add_attr_to_context(:use_policy, use_policy?)
|
80
92
|
end
|
81
93
|
|
82
94
|
def recipe
|
@@ -95,8 +107,12 @@ module ChefDK
|
|
95
107
|
File.expand_path(repo_name_or_path, Dir.pwd)
|
96
108
|
end
|
97
109
|
|
98
|
-
def
|
99
|
-
@
|
110
|
+
def use_policy?
|
111
|
+
@use_policy
|
112
|
+
end
|
113
|
+
|
114
|
+
def verbose?
|
115
|
+
@verbose
|
100
116
|
end
|
101
117
|
|
102
118
|
def read_and_validate_params
|
@@ -109,8 +125,8 @@ module ChefDK
|
|
109
125
|
err("Roles and Policyfiles are exclusive. Please only select one.")
|
110
126
|
@params_valid = false
|
111
127
|
end
|
112
|
-
if config[:
|
113
|
-
@
|
128
|
+
if config[:roles]
|
129
|
+
@use_policy = false
|
114
130
|
end
|
115
131
|
end
|
116
132
|
|
File without changes
|
File without changes
|
@@ -34,7 +34,7 @@ module ChefDK
|
|
34
34
|
cookbooks for the policy's run_list and caches them locally. It emits a
|
35
35
|
Policyfile.lock.json describing the locked cookbook set. You can use the
|
36
36
|
lockfile to install the locked cookbooks on another machine. You can also push
|
37
|
-
the lockfile to a "policy group" on a Chef Server and apply that exact set of
|
37
|
+
the lockfile to a "policy group" on a Chef Infra Server and apply that exact set of
|
38
38
|
cookbooks to nodes in your infrastructure.
|
39
39
|
|
40
40
|
See our detailed README for more information:
|
@@ -70,7 +70,6 @@ module ChefDK
|
|
70
70
|
|
71
71
|
def run(params = [])
|
72
72
|
return 1 unless apply_params!(params)
|
73
|
-
|
74
73
|
# Force config file to be loaded. We don't use the configuration
|
75
74
|
# directly, but the user may have SSL configuration options that they
|
76
75
|
# need to talk to a private supermarket (e.g., trusted_certs or
|
@@ -18,420 +18,18 @@
|
|
18
18
|
require "ostruct"
|
19
19
|
|
20
20
|
require "chef-dk/command/base"
|
21
|
-
require "chef-dk/configurable"
|
22
21
|
require "chef-dk/chef_runner"
|
23
|
-
require "chef-dk/policyfile_services/push"
|
24
|
-
|
25
|
-
require "chef/provisioning"
|
26
22
|
|
27
23
|
module ChefDK
|
28
24
|
|
29
|
-
module ProvisioningData
|
30
|
-
|
31
|
-
def self.reset
|
32
|
-
@context = nil
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.context
|
36
|
-
@context ||= Context.new
|
37
|
-
end
|
38
|
-
|
39
|
-
class Context
|
40
|
-
|
41
|
-
attr_accessor :action
|
42
|
-
|
43
|
-
attr_accessor :node_name
|
44
|
-
|
45
|
-
attr_accessor :target
|
46
|
-
|
47
|
-
attr_accessor :enable_policyfile
|
48
|
-
|
49
|
-
attr_accessor :policy_group
|
50
|
-
|
51
|
-
attr_accessor :policy_name
|
52
|
-
|
53
|
-
attr_accessor :extra_chef_config
|
54
|
-
|
55
|
-
attr_accessor :opts
|
56
|
-
|
57
|
-
def initialize
|
58
|
-
@extra_chef_config = ""
|
59
|
-
@opts = nil
|
60
|
-
end
|
61
|
-
|
62
|
-
def set_user_opts(hash)
|
63
|
-
@opts = OpenStruct.new(hash)
|
64
|
-
end
|
65
|
-
|
66
|
-
def convergence_options
|
67
|
-
{
|
68
|
-
chef_server: Chef::Config.chef_server_url,
|
69
|
-
chef_config: chef_config,
|
70
|
-
}
|
71
|
-
end
|
72
|
-
|
73
|
-
def chef_config
|
74
|
-
config = <<~CONFIG
|
75
|
-
# SSL Settings:
|
76
|
-
ssl_verify_mode #{Chef::Config.ssl_verify_mode.inspect}
|
77
|
-
|
78
|
-
CONFIG
|
79
|
-
if enable_policyfile
|
80
|
-
policyfile_config = <<~CONFIG
|
81
|
-
# Policyfile Settings:
|
82
|
-
use_policyfile true
|
83
|
-
policy_document_native_api true
|
84
|
-
|
85
|
-
policy_group "#{policy_group}"
|
86
|
-
policy_name "#{policy_name}"
|
87
|
-
|
88
|
-
CONFIG
|
89
|
-
config << policyfile_config
|
90
|
-
end
|
91
|
-
|
92
|
-
config << extra_chef_config.to_s
|
93
|
-
config
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
25
|
module Command
|
100
26
|
|
101
27
|
class Provision < Base
|
102
28
|
|
103
|
-
banner(
|
104
|
-
DEPRECATED: This command is deprecated and will be removed in ChefDK 4.
|
105
|
-
|
106
|
-
Usage: chef provision POLICY_GROUP --policy-name POLICY_NAME [options]
|
107
|
-
chef provision POLICY_GROUP --sync [POLICYFILE_PATH] [options]
|
108
|
-
chef provision --no-policy [options]
|
109
|
-
|
110
|
-
`chef provision` invokes an embedded chef-client run to provision machines
|
111
|
-
using Chef Provisioning. If not otherwise specified, `chef provision` will
|
112
|
-
expect to find a cookbook named 'provision' in the current working directory.
|
113
|
-
It runs a recipe in this cookbook which should use Chef Provisioning to create
|
114
|
-
one or more machines (or other infrastructure).
|
115
|
-
|
116
|
-
`chef provision` provides three forms of operation:
|
117
|
-
|
118
|
-
### chef provision POLICY_GROUP --policy-name POLICY_NAME
|
119
|
-
|
120
|
-
In the first form of the command, `chef provision` creates machines that will
|
121
|
-
operate in policyfile mode. The chef configuration passed to the cookbook will
|
122
|
-
set the policy group and policy name as given.
|
123
|
-
|
124
|
-
### chef provision POLICY_GROUP --sync [POLICYFILE_PATH] [options]
|
125
|
-
|
126
|
-
In the second form of the command, `chef provision` create machines that will
|
127
|
-
operate in policyfile mode and syncronizes a local policyfile to the server
|
128
|
-
before converging the machine(s) defined in the provision cookbook.
|
129
|
-
|
130
|
-
### chef provision --no-policy [options]
|
131
|
-
|
132
|
-
In the third form of the command, `chef provision` expects to create machines
|
133
|
-
that will not operate in policyfile mode.
|
134
|
-
|
135
|
-
Chef Provisioning is documented at https://docs.chef.io/provisioning.html
|
136
|
-
|
137
|
-
Options:
|
138
|
-
|
139
|
-
E
|
140
|
-
include Configurable
|
141
|
-
|
142
|
-
option :config_file,
|
143
|
-
short: "-c CONFIG_FILE",
|
144
|
-
long: "--config CONFIG_FILE",
|
145
|
-
description: "Path to configuration file"
|
146
|
-
|
147
|
-
option :policy_name,
|
148
|
-
short: "-p POLICY_NAME",
|
149
|
-
long: "--policy-name POLICY_NAME",
|
150
|
-
description: "Set the default policy name for provisioned machines"
|
151
|
-
|
152
|
-
option :sync,
|
153
|
-
short: "-s [POLICYFILE_PATH]",
|
154
|
-
long: "--sync [POLICYFILE_PATH]",
|
155
|
-
description: "Push policyfile to the server before converging node(s)"
|
156
|
-
|
157
|
-
option :enable_policyfile,
|
158
|
-
long: "--[no-]policy",
|
159
|
-
description: "Enable/disable policyfile integration (defaults to enabled, use --no-policy to disable)",
|
160
|
-
default: true
|
161
|
-
|
162
|
-
option :destroy,
|
163
|
-
short: "-d",
|
164
|
-
long: "--destroy",
|
165
|
-
description: "Set default machine action to :destroy",
|
166
|
-
default: false,
|
167
|
-
boolean: true
|
168
|
-
|
169
|
-
option :machine_recipe,
|
170
|
-
short: "-r RECIPE",
|
171
|
-
long: "--recipe RECIPE",
|
172
|
-
description: "Machine recipe to use",
|
173
|
-
default: "default"
|
174
|
-
|
175
|
-
option :cookbook,
|
176
|
-
long: "--cookbook COOKBOOK_PATH",
|
177
|
-
description: "Path to your provisioning cookbook",
|
178
|
-
default: "./provision"
|
179
|
-
|
180
|
-
option :node_name,
|
181
|
-
short: "-n NODE_NAME",
|
182
|
-
long: "--node-name NODE_NAME",
|
183
|
-
description: "Set default node name (may be overriden by provisioning cookbook)"
|
184
|
-
|
185
|
-
option :target,
|
186
|
-
short: "-t REMOTE_HOST",
|
187
|
-
long: "--target REMOTE_HOST",
|
188
|
-
description: "Set hostname or IP of the host to converge (may be overriden by provisioning cookbook)"
|
189
|
-
|
190
|
-
OPT_SEPARATOR = /[=\s]+/
|
191
|
-
|
192
|
-
def self.split_opt(key_value)
|
193
|
-
key, _separator, value = key_value.partition(OPT_SEPARATOR)
|
194
|
-
[key, value]
|
195
|
-
end
|
196
|
-
|
197
|
-
opts = {}
|
198
|
-
|
199
|
-
option :opts,
|
200
|
-
short: "-o OPT=VALUE",
|
201
|
-
long: "--opt OPT=VALUE",
|
202
|
-
description: "Set arbitrary option OPT on the provisioning context",
|
203
|
-
proc: lambda { |arg| key, value = split_opt(arg); opts[key] = value; opts },
|
204
|
-
default: {}
|
205
|
-
|
206
|
-
option :debug,
|
207
|
-
short: "-D",
|
208
|
-
long: "--debug",
|
209
|
-
description: "Enable stacktraces and other debug output",
|
210
|
-
default: false
|
211
|
-
|
212
|
-
attr_reader :params
|
213
|
-
attr_reader :policyfile_relative_path
|
214
|
-
attr_reader :policy_group
|
215
|
-
|
216
|
-
attr_accessor :ui
|
217
|
-
|
218
|
-
def initialize(*args)
|
219
|
-
super
|
220
|
-
|
221
|
-
@ui = UI.new
|
222
|
-
|
223
|
-
@policyfile_relative_path = nil
|
224
|
-
@policy_group = nil
|
225
|
-
|
226
|
-
@provisioning_cookbook_path = nil
|
227
|
-
@provisioning_cookbook_name = nil
|
228
|
-
end
|
29
|
+
banner("DEPRECATED: Chef provisioning has been removed from ChefDK / Workstation. If you require Chef Provisioning you will need to install an earlier version of these products!")
|
229
30
|
|
230
31
|
def run(params = [])
|
231
|
-
|
232
|
-
return 1 unless apply_params!(params)
|
233
|
-
chef_config # force chef config to load
|
234
|
-
return 1 unless check_cookbook_and_recipe_path
|
235
|
-
|
236
|
-
push.run if sync_policy?
|
237
|
-
|
238
|
-
setup_context
|
239
|
-
|
240
|
-
chef_runner.converge
|
241
|
-
0
|
242
|
-
rescue ChefRunnerError, PolicyfileServiceError => e
|
243
|
-
handle_error(e)
|
244
|
-
1
|
245
|
-
# Chef Provisioning doesn't fail gracefully when a driver is missing:
|
246
|
-
# https://github.com/chef/chef-provisioning/issues/338
|
247
|
-
rescue StandardError, LoadError => error
|
248
|
-
ui.err("Error: #{error.message}")
|
249
|
-
1
|
250
|
-
end
|
251
|
-
|
252
|
-
# An instance of ChefRunner. Calling ChefRunner#converge will trigger
|
253
|
-
# convergence and generate the desired code.
|
254
|
-
def chef_runner
|
255
|
-
@chef_runner ||= ChefRunner.new(provisioning_cookbook_path, ["recipe[#{provisioning_cookbook_name}::#{recipe}]"])
|
256
|
-
end
|
257
|
-
|
258
|
-
def push
|
259
|
-
@push ||= PolicyfileServices::Push.new(policyfile: policyfile_relative_path,
|
260
|
-
ui: ui,
|
261
|
-
policy_group: policy_group,
|
262
|
-
config: chef_config,
|
263
|
-
root_dir: Dir.pwd)
|
264
|
-
end
|
265
|
-
|
266
|
-
def setup_context
|
267
|
-
ProvisioningData.context.tap do |c|
|
268
|
-
|
269
|
-
c.action = default_action
|
270
|
-
c.node_name = node_name
|
271
|
-
c.target = target
|
272
|
-
|
273
|
-
c.set_user_opts(user_opts)
|
274
|
-
|
275
|
-
c.enable_policyfile = enable_policyfile?
|
276
|
-
|
277
|
-
if enable_policyfile?
|
278
|
-
c.policy_group = policy_group
|
279
|
-
c.policy_name = policy_name
|
280
|
-
end
|
281
|
-
|
282
|
-
end
|
283
|
-
end
|
284
|
-
|
285
|
-
def policy_name
|
286
|
-
if sync_policy?
|
287
|
-
push.policy_data["name"]
|
288
|
-
else
|
289
|
-
config[:policy_name]
|
290
|
-
end
|
291
|
-
end
|
292
|
-
|
293
|
-
def default_action
|
294
|
-
if config[:destroy]
|
295
|
-
:destroy
|
296
|
-
else
|
297
|
-
:converge
|
298
|
-
end
|
299
|
-
end
|
300
|
-
|
301
|
-
def node_name
|
302
|
-
config[:node_name]
|
303
|
-
end
|
304
|
-
|
305
|
-
def target
|
306
|
-
config[:target]
|
307
|
-
end
|
308
|
-
|
309
|
-
def user_opts
|
310
|
-
config[:opts]
|
311
|
-
end
|
312
|
-
|
313
|
-
def recipe
|
314
|
-
config[:machine_recipe]
|
315
|
-
end
|
316
|
-
|
317
|
-
# Gives the `cookbook_path` in the chef-client sense, which is the
|
318
|
-
# directory that contains the provisioning cookbook.
|
319
|
-
def provisioning_cookbook_path
|
320
|
-
detect_provisioning_cookbook_name_and_path! unless @provisioning_cookbook_path
|
321
|
-
@provisioning_cookbook_path
|
322
|
-
end
|
323
|
-
|
324
|
-
# The name of the provisioning cookbook
|
325
|
-
def provisioning_cookbook_name
|
326
|
-
detect_provisioning_cookbook_name_and_path! unless @provisioning_cookbook_name
|
327
|
-
@provisioning_cookbook_name
|
328
|
-
end
|
329
|
-
|
330
|
-
def cookbook_path
|
331
|
-
config[:cookbook]
|
332
|
-
end
|
333
|
-
|
334
|
-
def enable_policyfile?
|
335
|
-
config[:enable_policyfile]
|
336
|
-
end
|
337
|
-
|
338
|
-
def apply_params!(params)
|
339
|
-
remaining_args = parse_options(params)
|
340
|
-
if enable_policyfile?
|
341
|
-
handle_policy_argv(remaining_args)
|
342
|
-
else
|
343
|
-
handle_no_policy_argv(remaining_args)
|
344
|
-
end
|
345
|
-
end
|
346
|
-
|
347
|
-
def debug?
|
348
|
-
!!config[:debug]
|
349
|
-
end
|
350
|
-
|
351
|
-
def sync_policy?
|
352
|
-
config.key?(:sync)
|
353
|
-
end
|
354
|
-
|
355
|
-
private
|
356
|
-
|
357
|
-
def detect_provisioning_cookbook_name_and_path!
|
358
|
-
given_path = File.expand_path(cookbook_path, Dir.pwd)
|
359
|
-
@provisioning_cookbook_name = File.basename(given_path)
|
360
|
-
@provisioning_cookbook_path = File.dirname(given_path)
|
361
|
-
end
|
362
|
-
|
363
|
-
def check_cookbook_and_recipe_path
|
364
|
-
if !File.exist?(cookbook_expanded_path)
|
365
|
-
ui.err("ERROR: Provisioning cookbook not found at path #{cookbook_expanded_path}")
|
366
|
-
false
|
367
|
-
elsif !File.exist?(provisioning_recipe_path)
|
368
|
-
ui.err("ERROR: Provisioning recipe not found at path #{provisioning_recipe_path}")
|
369
|
-
false
|
370
|
-
else
|
371
|
-
true
|
372
|
-
end
|
373
|
-
end
|
374
|
-
|
375
|
-
def provisioning_recipe_path
|
376
|
-
File.join(cookbook_expanded_path, "recipes", "#{recipe}.rb")
|
377
|
-
end
|
378
|
-
|
379
|
-
def cookbook_expanded_path
|
380
|
-
File.join(chef_runner.cookbook_path, provisioning_cookbook_name)
|
381
|
-
end
|
382
|
-
|
383
|
-
def handle_no_policy_argv(remaining_args)
|
384
|
-
if remaining_args.empty?
|
385
|
-
true
|
386
|
-
else
|
387
|
-
ui.err("The --no-policy flag cannot be combined with policyfile arguments")
|
388
|
-
ui.err("")
|
389
|
-
ui.err(opt_parser)
|
390
|
-
false
|
391
|
-
end
|
392
|
-
end
|
393
|
-
|
394
|
-
def handle_policy_argv(remaining_args)
|
395
|
-
if remaining_args.size > 1
|
396
|
-
ui.err("Too many arguments")
|
397
|
-
ui.err("")
|
398
|
-
ui.err(opt_parser)
|
399
|
-
false
|
400
|
-
elsif remaining_args.size < 1
|
401
|
-
ui.err("You must specify a POLICY_GROUP or disable policyfiles with --no-policy")
|
402
|
-
ui.err("")
|
403
|
-
ui.err(opt_parser)
|
404
|
-
false
|
405
|
-
elsif !sync_policy? && config[:policy_name].nil?
|
406
|
-
ui.err("You must pass either --sync or --policy-name to provision machines in policyfile mode")
|
407
|
-
ui.err("")
|
408
|
-
ui.err(opt_parser)
|
409
|
-
false
|
410
|
-
elsif sync_policy? && config[:policy_name]
|
411
|
-
ui.err("The --policy-name and --sync arguments cannot be combined")
|
412
|
-
ui.err("")
|
413
|
-
ui.err(opt_parser)
|
414
|
-
false
|
415
|
-
elsif sync_policy?
|
416
|
-
@policy_group = remaining_args[0]
|
417
|
-
@policyfile_relative_path = config[:sync]
|
418
|
-
true
|
419
|
-
elsif config[:policy_name]
|
420
|
-
@policy_group = remaining_args[0]
|
421
|
-
true
|
422
|
-
else
|
423
|
-
raise BUG, "Cannot properly parse input argv '#{ARGV.inspect}'"
|
424
|
-
end
|
425
|
-
end
|
426
|
-
|
427
|
-
def handle_error(error)
|
428
|
-
ui.err("Error: #{error.message}")
|
429
|
-
if error.respond_to?(:reason)
|
430
|
-
ui.err("Reason: #{error.reason}")
|
431
|
-
ui.err("")
|
432
|
-
ui.err(error.extended_error_info) if debug?
|
433
|
-
ui.err(error.cause.backtrace.join("\n")) if debug?
|
434
|
-
end
|
32
|
+
raise "Chef provisioning has been removed from ChefDK / Workstation. If you require Chef Provisioning you will need to install an earlier version of these products!"
|
435
33
|
end
|
436
34
|
|
437
35
|
end
|