Class: Fhcap::Tasks::Chef::Environments::Destroy
- Inherits:
-
ChefTaskBase
- Object
- TaskBase
- ChefTaskBase
- Fhcap::Tasks::Chef::Environments::Destroy
- Defined in:
- lib/fhcap/tasks/chef/environments/destroy.rb
Instance Attribute Summary collapse
-
#chef_server ⇒ Object
readonly
Returns the value of attribute chef_server.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from TaskBase
#config, #options, #thor, #verbose
Instance Method Summary collapse
-
#initialize(options) ⇒ Destroy
constructor
A new instance of Destroy.
- #run ⇒ Object
Methods inherited from ChefTaskBase
#chef_server_environments, #chef_servers_for_environment, #knife_config_dir, #knife_config_file_for, #run_chef_client_cmd, #run_knife_cmd, #run_knife_ssh_cmd, #select_chef_server
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
Constructor Details
#initialize(options) ⇒ Destroy
Returns a new instance of Destroy.
11 12 13 14 15 16 |
# File 'lib/fhcap/tasks/chef/environments/destroy.rb', line 11 def initialize() super @name = [:name] @repo = [:repo] @chef_server = [:chef_server] end |
Instance Attribute Details
#chef_server ⇒ Object (readonly)
Returns the value of attribute chef_server.
9 10 11 |
# File 'lib/fhcap/tasks/chef/environments/destroy.rb', line 9 def chef_server @chef_server end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/fhcap/tasks/chef/environments/destroy.rb', line 9 def name @name end |
Instance Method Details
#run ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fhcap/tasks/chef/environments/destroy.rb', line 18 def run thor.say "Chef::Environments::Destroy #{@name}", :yellow if @chef_server if thor.yes? "Remove all environments and config from the chef server (#{@chef_server})?" run_knife_cmd("environment delete #{@name} -y", @chef_server) run_knife_cmd("data bag delete environments #{@name} -y", @chef_server) end end thor.remove_file find_data_bag_item('environments', @name) thor.remove_file find_environment(@name) thor.remove_file find_repo_item(repo_clusters_dir(@repo), "#{@name}_passwords.json").first end |