Class: Fhcap::Tasks::Cluster::Destroy

Inherits:
ClusterTaskBase show all
Defined in:
lib/fhcap/tasks/cluster/destroy.rb

Instance Attribute Summary

Attributes inherited from ClusterTaskBase

#cluster_config, #cluster_file, #name

Attributes inherited from TaskBase

#config, #options, #thor, #verbose

Instance Method Summary collapse

Methods inherited from ClusterTaskBase

#checkout_repos, #template_as_object

Methods inherited from TaskBase

#ask_config, #color_pad, #exit_with_error, #set_color, #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

#cluster_template_names

Constructor Details

#initialize(options) ⇒ Destroy

Returns a new instance of Destroy.



10
11
12
13
# File 'lib/fhcap/tasks/cluster/destroy.rb', line 10

def initialize(options)
  super(options, false)
  @skip_destroy = options[:'skip-destroy']
end

Instance Method Details

#run ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fhcap/tasks/cluster/destroy.rb', line 15

def run
  thor.say "Cluster::Destroy: name = #{@name}", :yellow
  Chef::Provisioning::Destroy.new(options).run unless @skip_destroy

  if thor.yes? "Delete all local repo files?"
    cluster_environments.each do |env_name, cfg|
      Chef::Environments::Destroy.new(@options.dup.merge({:name => env_name, :chef_server => @cluster_config[:chef_server], :repo => @cluster_config[:repo]})).run
    end
    thor.remove_file find_cluster(@name)
  end
end