Module: Chef::DSL::Recipe
- Included in:
- Cheffish::BasicChefClient
- Defined in:
- lib/cheffish/recipe_dsl.rb
Instance Method Summary collapse
- #get_private_key(name) ⇒ Object
- #with_chef_data_bag(name) ⇒ Object
- #with_chef_data_bag_item_encryption(encryption_options, &block) ⇒ Object
- #with_chef_environment(name, &block) ⇒ Object
- #with_chef_local_server(options, &block) ⇒ Object
- #with_chef_server(server_url, options = {}, &block) ⇒ Object
Instance Method Details
#get_private_key(name) ⇒ Object
91 92 93 |
# File 'lib/cheffish/recipe_dsl.rb', line 91 def get_private_key(name) Cheffish.get_private_key(name, run_context.config) end |
#with_chef_data_bag(name) ⇒ Object
32 33 34 |
# File 'lib/cheffish/recipe_dsl.rb', line 32 def with_chef_data_bag(name) run_context.cheffish.with_data_bag(name, &block) end |
#with_chef_data_bag_item_encryption(encryption_options, &block) ⇒ Object
40 41 42 |
# File 'lib/cheffish/recipe_dsl.rb', line 40 def with_chef_data_bag_item_encryption(, &block) run_context.cheffish.with_data_bag_item_encryption(, &block) end |
#with_chef_environment(name, &block) ⇒ Object
36 37 38 |
# File 'lib/cheffish/recipe_dsl.rb', line 36 def with_chef_environment(name, &block) run_context.cheffish.with_environment(name, &block) end |
#with_chef_local_server(options, &block) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/cheffish/recipe_dsl.rb', line 48 def with_chef_local_server(, &block) [:host] ||= "127.0.0.1" [:log_level] ||= Chef::Log.level [:port] ||= ChefZero::VERSION.to_f >= 2.2 ? 8901.upto(9900) : 8901 # Create the data store chef-zero will use [:data_store] ||= begin unless [:chef_repo_path] raise "chef_repo_path must be specified to with_chef_local_server" end # Ensure all paths are given %w{acl client cookbook container data_bag environment group node role}.each do |type| # Set the options as symbol keys and then copy to string keys string_key = "#{type}_path" symbol_key = "#{type}_path".to_sym [symbol_key] ||= if [:chef_repo_path].is_a?(String) Chef::Util::PathHelper.join([:chef_repo_path], "#{type}s") else [:chef_repo_path].map { |path| Chef::Util::PathHelper.join(path, "#{type}s") } end # Copy over to string keys for things that use string keys (ChefFS)... # TODO: Fix ChefFS to take symbols or use something that is insensitive to the difference [string_key] = [symbol_key] end chef_fs = Chef::ChefFS::Config.new().local_fs chef_fs.write_pretty_json = true Chef::ChefFS::ChefFSDataStore.new(chef_fs) end # Start the chef-zero server Chef::Log.info("Starting chef-zero on port #{[:port]} with repository at #{[:data_store].chef_fs.fs_description}") chef_zero_server = ChefZero::Server.new() chef_zero_server.start_background run_context.cheffish.local_servers << chef_zero_server with_chef_server(chef_zero_server.url, &block) end |
#with_chef_server(server_url, options = {}, &block) ⇒ Object
44 45 46 |
# File 'lib/cheffish/recipe_dsl.rb', line 44 def with_chef_server(server_url, = {}, &block) run_context.cheffish.with_chef_server({ chef_server_url: server_url, options: }, &block) end |