diff options
author | Tim Smith <tsmith@chef.io> | 2019-06-03 10:28:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-03 10:28:02 -0700 |
commit | 11dbd02b8494d4346cb0dbf0c58f06652ffa1e06 (patch) | |
tree | 0f42d2682eb574a324912df920d91aded1123047 | |
parent | c75acb8512b290e8531b33787b76789afdfaa435 (diff) | |
parent | 1f5d5da12d51444a33b87e3bddc3080edbbe9f86 (diff) | |
download | chef-11dbd02b8494d4346cb0dbf0c58f06652ffa1e06.tar.gz |
Merge pull request #8628 from chef/btm/knife-cloud-bootstrap
Add hooks for plugins in knife bootstrap
-rw-r--r-- | lib/chef/knife/bootstrap.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb index 475cb43199..0826a0f38c 100644 --- a/lib/chef/knife/bootstrap.rb +++ b/lib/chef/knife/bootstrap.rb @@ -539,15 +539,18 @@ class Chef check_license verify_deprecated_flags! + plugin_setup! validate_name_args! validate_protocol! validate_first_boot_attributes! validate_winrm_transport_opts! validate_policy_options! + plugin_validate_options! winrm_warn_no_ssl_verification warn_on_short_session_timeout + plugin_create_instance! $stdout.sync = true connect! register_client @@ -555,6 +558,7 @@ class Chef content = render_template bootstrap_path = upload_bootstrap(content) perform_bootstrap(bootstrap_path) + plugin_finalize ensure connection.del_file!(bootstrap_path) if connection && bootstrap_path end @@ -772,6 +776,40 @@ class Chef true end + # Validate any additional options + # + # Plugins that subclass bootstrap, e.g. knife-ec2, can use this method to validate any additonal options before any other actions are executed + # + # @return [TrueClass] If options are valid or exits + def plugin_validate_options! + true + end + + # Create the server that we will bootstrap, if necessary + # + # Plugins that subclass bootstrap, e.g. knife-ec2, can use this method to call out to an API to build an instance of the server we wish to bootstrap + # + # @return [TrueClass] If instance successfully created, or exits + def plugin_create_instance! + true + end + + # Perform any setup necessary by the plugin + # + # Plugins that subclass bootstrap, e.g. knife-ec2, can use this method to create connection objects + # + # @return [TrueClass] If instance successfully created, or exits + def plugin_setup! + end + + # Perform any teardown or cleanup necessary by the plugin + # + # Plugins that subclass bootstrap, e.g. knife-ec2, can use this method to display a message or perform any cleanup + # + # @return [void] + def plugin_finalize + end + # If session_timeout is too short, it is likely # a holdover from "--winrm-session-timeout" which used # minutes as its unit, instead of seconds. |