Module: Promote::ChefServer
- Included in:
- NodeFinder, PasswordVault, Promoter, Uploader
- Defined in:
- lib/promote/chef_server.rb
Instance Method Summary collapse
-
#with_chef_server(config, &block) ⇒ Object
Accepts a code block to run in the context of a chef server and user and reverts the environment back to the previous settings when done.
Instance Method Details
#with_chef_server(config, &block) ⇒ Object
Accepts a code block to run in the context of a chef server and user and reverts the environment back to the previous settings when done
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/promote/chef_server.rb', line 6 def with_chef_server(config, &block) current_server_url = Chef::Config[:chef_server_url] current_client_key = Chef::Config[:client_key] current_node_name = Chef::Config[:node_name] current_repo_root = Chef::Config[:chef_repo_path] current_verify_mode = Chef::Config[:ssl_verify_mode] Chef::Config.reset Chef::Config[:chef_server_url] = config.chef_server_url Chef::Config[:client_key] = config.client_key Chef::Config[:node_name] = config.node_name Chef::Config[:chef_repo_path] = config.repo_root Chef::Config[:ssl_verify_mode] = :verify_none yield ensure Chef::Config.reset Chef::Config[:chef_server_url] = current_server_url Chef::Config[:client_key] = current_client_key Chef::Config[:node_name] = current_node_name Chef::Config[:chef_repo_path] = current_repo_root Chef::Config[:ssl_verify_mode] = current_verify_mode end |