Module: Chef::DSL::Recipe
- Included in:
- Cheffish::BasicChefClient
- Defined in:
- lib/cheffish/recipe_dsl.rb
Instance Method Summary collapse
- #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
#with_chef_data_bag(name) ⇒ Object
13 14 15 |
# File 'lib/cheffish/recipe_dsl.rb', line 13 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
21 22 23 |
# File 'lib/cheffish/recipe_dsl.rb', line 21 def with_chef_data_bag_item_encryption(, &block) run_context.cheffish.with_data_bag_item_encryption(, &block) end |
#with_chef_environment(name, &block) ⇒ Object
17 18 19 |
# File 'lib/cheffish/recipe_dsl.rb', line 17 def with_chef_environment(name, &block) run_context.cheffish.with_environment(name, &block) end |
#with_chef_local_server(options, &block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/cheffish/recipe_dsl.rb', line 29 def with_chef_local_server(, &block) [:host] ||= '127.0.0.1' [:log_level] ||= Chef::Log.level [:port] ||= 8900 # Create the data store chef-zero will use [:data_store] ||= begin if ![: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| ["#{type}_path".to_sym] ||= begin if [:chef_repo_path].kind_of?(String) Chef::Config.path_join([:chef_repo_path], "#{type}s") else [:chef_repo_path].map { |path| Chef::Config.path_join(path, "#{type}s")} end end # Work around issue in earlier versions of ChefFS where it expects strings for these # instead of symbols ["#{type}_path"] = ["#{type}_path".to_sym] 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 #{options[:port]} with repository at #{options[: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
25 26 27 |
# File 'lib/cheffish/recipe_dsl.rb', line 25 def with_chef_server(server_url, = {}, &block) run_context.cheffish.with_chef_server({ :chef_server_url => server_url, :options => }, &block) end |