Class: Fhcap::Tasks::Cluster::Provision
- Inherits:
-
ClusterTaskBase
- Object
- TaskBase
- ClusterTaskBase
- Fhcap::Tasks::Cluster::Provision
- Defined in:
- lib/fhcap/tasks/cluster/provision.rb
Instance Attribute Summary collapse
-
#gitref ⇒ Object
readonly
Returns the value of attribute gitref.
-
#node_names ⇒ Object
readonly
Returns the value of attribute node_names.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
-
#strategy ⇒ Object
readonly
Returns the value of attribute strategy.
Attributes inherited from ClusterTaskBase
#cluster_config, #cluster_file, #name
Attributes inherited from TaskBase
#config, #options, #thor, #verbose
Instance Method Summary collapse
-
#initialize(options) ⇒ Provision
constructor
A new instance of Provision.
- #run ⇒ Object
Methods inherited from ClusterTaskBase
#checkout_repos, #chef_task_options, #template_as_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, #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) ⇒ Provision
Returns a new instance of Provision.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fhcap/tasks/cluster/provision.rb', line 15 def initialize() super @gitref = [:"git-ref"] @node_names = [:nodes] @roles = [:roles] @skip_repo_checkout = [:'skip-repo-checkout'] @skip_cookbook_promote = [:'skip-cookbook-promote'] @skip_server_bootstrap = [:'skip-server-bootstrap'] @skip_provision = [:'skip-provision'] @strategy = ('knife' unless provider_names.include?(@cluster_config[:provider_id])) || [:strategy] end |
Instance Attribute Details
#gitref ⇒ Object (readonly)
Returns the value of attribute gitref.
13 14 15 |
# File 'lib/fhcap/tasks/cluster/provision.rb', line 13 def gitref @gitref end |
#node_names ⇒ Object (readonly)
Returns the value of attribute node_names.
13 14 15 |
# File 'lib/fhcap/tasks/cluster/provision.rb', line 13 def node_names @node_names end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
13 14 15 |
# File 'lib/fhcap/tasks/cluster/provision.rb', line 13 def roles @roles end |
#strategy ⇒ Object (readonly)
Returns the value of attribute strategy.
13 14 15 |
# File 'lib/fhcap/tasks/cluster/provision.rb', line 13 def strategy @strategy end |
Instance Method Details
#run ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fhcap/tasks/cluster/provision.rb', line 27 def run thor.say "Cluster::Provision: name = #{name}, strategy = #{strategy}", :yellow checkout_repos unless @skip_repo_checkout Chef::Environments::PromoteCookbooks.new(@options.dup.merge({:environments => cluster_environments})).run unless @skip_cookbook_promote Chef::Server::Bootstrap.new(@options.dup.merge({:environments => cluster_environments}.merge())).run unless @skip_server_bootstrap unless @skip_provision if strategy == 'chef' Chef::Provisioning::Provision.new(@options.dup.merge()).run elsif strategy == 'knife' Chef::Server::Provision.new(@options.dup.merge({:environments => cluster_environments}.merge())).run else thor.say_status :error, "Unsupported provision strategy #{strategy}" end end end |