Class: Fhcap::Tasks::Cluster::CreateEnvironment
- Inherits:
-
ClusterTaskBase
- Object
- TaskBase
- ClusterTaskBase
- Fhcap::Tasks::Cluster::CreateEnvironment
- Defined in:
- lib/fhcap/tasks/cluster/create_environment.rb
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#environment_config ⇒ Object
readonly
Returns the value of attribute environment_config.
-
#environment_name ⇒ Object
readonly
Returns the value of attribute environment_name.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Attributes inherited from ClusterTaskBase
#cluster_config, #cluster_file, #name
Attributes inherited from TaskBase
#config, #options, #thor, #verbose
Instance Method Summary collapse
-
#initialize(options) ⇒ CreateEnvironment
constructor
A new instance of CreateEnvironment.
- #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, #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) ⇒ CreateEnvironment
Returns a new instance of CreateEnvironment.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fhcap/tasks/cluster/create_environment.rb', line 13 def initialize() super() @skip_create_cluster_file = [:'skip-create-cluster-file'] @template = [:template] @environment_name = [:'environment-name'] @domain = [:domain] @cluster_config[:environments] = @cluster_config[:environments] || {} @environment_config = @cluster_config[:environments][@environment_name.to_sym] || {} template_filepath = File.join(Fhcap.source_root, 'templates', 'cluster', @cluster_config[:driver], "#{template}.json.erb") env_template_config = template_as_object(template_filepath, @cluster_config.merge({ domain: @domain, environment_name: @environment_name })) @environment_config.merge!(env_template_config) @availability_zones = provider_availability_zones(@cluster_config[:provider_id], @cluster_config[:provider_config][:region]) @cidr = @cluster_config[:provider_config][:cidr] @subnets = {} @allocated_ips = {} @next_subnet = 0 end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
11 12 13 |
# File 'lib/fhcap/tasks/cluster/create_environment.rb', line 11 def domain @domain end |
#environment_config ⇒ Object (readonly)
Returns the value of attribute environment_config.
11 12 13 |
# File 'lib/fhcap/tasks/cluster/create_environment.rb', line 11 def environment_config @environment_config end |
#environment_name ⇒ Object (readonly)
Returns the value of attribute environment_name.
11 12 13 |
# File 'lib/fhcap/tasks/cluster/create_environment.rb', line 11 def environment_name @environment_name end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
11 12 13 |
# File 'lib/fhcap/tasks/cluster/create_environment.rb', line 11 def template @template end |
Instance Method Details
#run ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fhcap/tasks/cluster/create_environment.rb', line 37 def run thor.say "Cluster::CreateEnvironment: cluster = #{name}, environment = #{environment_name}, domain = #{domain}", :yellow env_cfg = { name: "#{name}-#{environment_name}", domain: domain, type: get_env_type(environment_name), repo: cluster_config[:repo], efs_enabled: cluster_config[:provider_config][:efs_enabled] } generate_environment_config create_chef_environment(env_cfg) thor.create_file(cluster_file, JSON.pretty_generate(cluster_config)) unless @skip_create_cluster_file end |