Class: Fhcap::Tasks::Chef::Provisioning::ChefProvisioningTaskBase
- Inherits:
-
ChefServerTask
- Object
- TaskBase
- ChefTaskBase
- ChefServerTask
- Fhcap::Tasks::Chef::Provisioning::ChefProvisioningTaskBase
- Defined in:
- lib/fhcap/tasks/chef/provisioning/chef_provisioning_task_base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cluster_config ⇒ Object
readonly
Returns the value of attribute cluster_config.
-
#cluster_filepath ⇒ Object
readonly
Returns the value of attribute cluster_filepath.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#run_options ⇒ Object
readonly
Returns the value of attribute run_options.
Attributes inherited from ChefServerTask
#chef_repo, #chef_server, #repos
Attributes inherited from TaskBase
#config, #options, #thor, #verbose
Instance Method Summary collapse
- #default_run_options ⇒ Object
- #do_chef_run(run_list, dry_run = ) ⇒ Object
- #get_run_options(opts) ⇒ Object
-
#initialize(options) ⇒ ChefProvisioningTaskBase
constructor
A new instance of ChefProvisioningTaskBase.
- #seed_cookbooks ⇒ Object
Methods inherited from ChefServerTask
#delete_chef_object, #knife_data_bag_delete, #knife_download, #knife_environment_delete, #knife_upload, #local_chef_server?, #with_chef_server, #with_local_chef_server
Methods inherited from ChefTaskBase
#knife_config_dir, #knife_config_file_for, #run_chef_client_cmd, #run_knife_cmd, #run_knife_ssh_cmd
Methods inherited from TaskBase
#ask_config, #color_pad, #exit_with_error, #set_color, #suppress_stdout, #table_header, #table_row, #with_progress
Methods included from KnifeHelper
#chef_server_config_for, #chef_server_config_hash_for, #chef_server_names, #knife_config, #knife_config_dir, #knife_config_file_for
Methods included from ProvidersHelper
#provider_availability_zones, #provider_config, #provider_credentials, #provider_for, #provider_names, #provider_names_for, #provider_regions, #provider_type, #providers_config
Methods included from ReposHelper
#find_cluster, #find_cluster_pwds, #find_cluster_pwds_with_repo, #find_cluster_with_repo, #find_data_bag, #find_data_bag_item, #find_environment, #find_repo_item, #find_role, #get_cookbook_deps, #get_cookbook_meta, #get_cookbook_versions, #get_cookbooks, #get_entry_dependencies, #get_modified_cookbooks, #is_dirty?, #modified?, #repo_cfg, #repo_clusters_dir, #repo_cookbook_paths, #repo_dir, #repo_names, #repo_paths, #repos_config, #repos_dir, #run_inside_repo_dir
Methods included from FhcapHelper
Constructor Details
#initialize(options) ⇒ ChefProvisioningTaskBase
Returns a new instance of ChefProvisioningTaskBase.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fhcap/tasks/chef/provisioning/chef_provisioning_task_base.rb', line 14 def initialize() super @name = [:name] @cluster_filepath = find_cluster(name) if @cluster_filepath @cluster_config = JSON.parse(IO.read(@cluster_filepath), {:symbolize_names => true}) @cluster_config.merge!({ local_repo_path: repo_dir(@chef_repo), local_repo_clusters_dir: repo_clusters_dir(@chef_repo), chef_server_config: chef_server_config_hash_for(@chef_server), provider_credentials: provider_credentials(@cluster_config[:provider_id]), max_simultaneous: [:series] ? 1 : nil }) else exit_with_error("Unknown cluster #{@name}") end @run_options = [:'run-options'] end |
Instance Attribute Details
#cluster_config ⇒ Object (readonly)
Returns the value of attribute cluster_config.
12 13 14 |
# File 'lib/fhcap/tasks/chef/provisioning/chef_provisioning_task_base.rb', line 12 def cluster_config @cluster_config end |
#cluster_filepath ⇒ Object (readonly)
Returns the value of attribute cluster_filepath.
12 13 14 |
# File 'lib/fhcap/tasks/chef/provisioning/chef_provisioning_task_base.rb', line 12 def cluster_filepath @cluster_filepath end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/fhcap/tasks/chef/provisioning/chef_provisioning_task_base.rb', line 12 def name @name end |
#run_options ⇒ Object (readonly)
Returns the value of attribute run_options.
12 13 14 |
# File 'lib/fhcap/tasks/chef/provisioning/chef_provisioning_task_base.rb', line 12 def @run_options end |
Instance Method Details
#default_run_options ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/fhcap/tasks/chef/provisioning/chef_provisioning_task_base.rb', line 40 def { max_simultaneous: [:series] ? 1 : nil, "env-regexp" => '.', "node-regexp" => '.' } end |
#do_chef_run(run_list, dry_run = ) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/fhcap/tasks/chef/provisioning/chef_provisioning_task_base.rb', line 52 def do_chef_run(run_list, dry_run=[:'dry-run']) cookbook_path = File.join(Fhcap.source_root, 'lib', 'cookbooks') private_key_paths = [File.join(cluster_config[:local_repo_path], cluster_config[:local_repo_clusters_dir], 'key_pairs')] node_attrs = cluster_config.deep_merge(()) Fhcap::ChefRunner.new(cookbook_path, run_list, dry_run, node_attrs, private_key_paths).converge end |
#get_run_options(opts) ⇒ Object
48 49 50 |
# File 'lib/fhcap/tasks/chef/provisioning/chef_provisioning_task_base.rb', line 48 def (opts) .deep_merge!(opts) end |
#seed_cookbooks ⇒ Object
33 34 35 36 37 38 |
# File 'lib/fhcap/tasks/chef/provisioning/chef_provisioning_task_base.rb', line 33 def seed_cookbooks archive_task = Chef::Cookbook::Archive.new(@options.dup.merge({:'skip-repo-checkout' => true})) archive_task.run @cluster_config[:local_cookbook_archive] = archive_task.archive do_chef_run("provision::seed_cookbooks") end |