Class: Fhcap::Tasks::Cluster::ClusterTaskBase
- Defined in:
- lib/fhcap/tasks/cluster/cluster_task_base.rb
Direct Known Subclasses
BootstrapServer, ChefProvisioningTask, Create, CreateDNSRecords, CreateEnvironment, Destroy, DestroyEnvironment, Generate, Info, PromoteCookbooks, Provision, Status, Test, UpdateEnvironmentAttributes
Instance Attribute Summary collapse
-
#cluster_config ⇒ Object
readonly
Returns the value of attribute cluster_config.
-
#cluster_file ⇒ Object
readonly
Returns the value of attribute cluster_file.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from TaskBase
#config, #options, #thor, #verbose
Instance Method Summary collapse
- #checkout_repos ⇒ Object
- #chef_task_options ⇒ Object
-
#initialize(options, exit_on_error = true) ⇒ ClusterTaskBase
constructor
A new instance of ClusterTaskBase.
- #template_as_object(template_file, config) ⇒ Object
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, #delete_chef_object, #knife_config, #knife_config_dir, #knife_config_file_for, #knife_data_bag_delete, #knife_download, #knife_environment_delete, #knife_upload, #local_chef_server?, #with_chef_server, #with_local_chef_server
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_dirty_cookbooks, #get_entry_dependencies, #get_modified_cookbooks, #git_diff, #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, exit_on_error = true) ⇒ ClusterTaskBase
Returns a new instance of ClusterTaskBase.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fhcap/tasks/cluster/cluster_task_base.rb', line 11 def initialize(, exit_on_error=true) super() @name = [:name] @cluster_config = [:'cluster-config'] unless @cluster_config @cluster_file = find_cluster(@name) if @cluster_file @cluster_config = JSON.parse(IO.read(@cluster_file), {:symbolize_names => true}) else exit_with_error("Unknown cluster #{@name}") if exit_on_error @cluster_config = {} end end end |
Instance Attribute Details
#cluster_config ⇒ Object (readonly)
Returns the value of attribute cluster_config.
9 10 11 |
# File 'lib/fhcap/tasks/cluster/cluster_task_base.rb', line 9 def cluster_config @cluster_config end |
#cluster_file ⇒ Object (readonly)
Returns the value of attribute cluster_file.
9 10 11 |
# File 'lib/fhcap/tasks/cluster/cluster_task_base.rb', line 9 def cluster_file @cluster_file end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/fhcap/tasks/cluster/cluster_task_base.rb', line 9 def name @name end |
Instance Method Details
#checkout_repos ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fhcap/tasks/cluster/cluster_task_base.rb', line 42 def checkout_repos repos = ['fhcap', cluster_config[:repo]].compact.uniq repos.each do |name| name = name.to_s if @options[:'git-ref'] fallback_git_ref = name == 'fhcap' ? nil : 'master' else fallback_git_ref = nil end Repo::Checkout.new(@options.dup.merge({:repo => name, :'fallback-git-ref' => fallback_git_ref})).run end if repos end |
#chef_task_options ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/fhcap/tasks/cluster/cluster_task_base.rb', line 27 def { :'chef-server' => cluster_config[:chef_server], :'chef-repo' => cluster_config[:repo], :repos => ['fhcap', cluster_config[:repo]].uniq } end |
#template_as_object(template_file, config) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/fhcap/tasks/cluster/cluster_task_base.rb', line 35 def template_as_object(template_file, config) template = File.read(template_file) eruby = Erubis::Eruby.new(template) result = eruby.result({config: config}) JSON.parse(result, {:symbolize_names => true}) end |