Module: Enscalator
- Defined in:
- lib/enscalator.rb,
lib/enscalator/vpc.rb,
lib/enscalator/core.rb,
lib/enscalator/enapp.rb,
lib/enscalator/helpers.rb,
lib/enscalator/plugins.rb,
lib/enscalator/version.rb,
lib/enscalator/templates.rb,
lib/enscalator/helpers/dns.rb,
lib/enscalator/plugins/elb.rb,
lib/enscalator/plugins/rds.rb,
lib/enscalator/helpers/stack.rb,
lib/enscalator/plugins/redis.rb,
lib/enscalator/plugins/debian.rb,
lib/enscalator/plugins/ubuntu.rb,
lib/enscalator/plugins/core_os.rb,
lib/enscalator/plugins/route53.rb,
lib/enscalator/helpers/wrappers.rb,
lib/enscalator/core/cf_resources.rb,
lib/enscalator/plugins/couchbase.rb,
lib/enscalator/rich_template_dsl.rb,
lib/enscalator/core/cf_parameters.rb,
lib/enscalator/core/instance_type.rb,
lib/enscalator/plugins/auto_scale.rb,
lib/enscalator/plugins/rethink_db.rb,
lib/enscalator/core/network_config.rb,
lib/enscalator/helpers/sub_process.rb,
lib/enscalator/plugins/elasticache.rb,
lib/enscalator/plugins/nat_gateway.rb,
lib/enscalator/plugins/amazon_linux.rb,
lib/enscalator/vpc_with_nat_gateway.rb,
lib/enscalator/templates/vpc_peering.rb,
lib/enscalator/vpc_with_nat_instance.rb,
lib/enscalator/plugins/elastic_beanstalk.rb,
lib/enscalator/plugins/elasticsearch_amazon.rb,
lib/enscalator/plugins/elasticsearch_bitnami.rb,
lib/enscalator/plugins/elasticsearch_opsworks.rb,
lib/enscalator/plugins/vpc_peering_connection.rb
Overview
Enscalator
Defined Under Namespace
Modules: Core, Helpers, Plugins, Templates Classes: EnAppTemplateDSL, RichTemplateDSL
Constant Summary collapse
- ASSETS_DIR =
Default directory to save generated assets like ssh keys, configs and etc.
File.join(ENV['HOME'], ".#{name.split('::').first.downcase}")
- VERSION =
Current version
'0.4.4'.freeze
Class Method Summary collapse
-
.run!(argv) ⇒ Object
Main method to actually run Enscalator.
Class Method Details
.run!(argv) ⇒ Object
Main method to actually run Enscalator
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/enscalator.rb', line 25 def self.run!(argv) argv_dup = argv.dup display_name = name.downcase parser = Trollop::Parser.new do "Usage: #{display_name} [arguments]" opt :list_templates, 'List all available templates', default: false, short: 'l' opt :template, 'Template name', type: String, short: 't' opt :template_file, 'Template filename', type: String, short: 'f' opt :region, 'AWS Region', type: String, default: 'us-east-1', short: 'r' opt :parameters, "Parameters 'Key1=Value1;Key2=Value2'", type: String, short: 'p' opt :stack_name, 'Stack name', type: String, short: 's' opt :private_hosted_zone, "Private hosted zone (e.x. 'default-vpc.internal')", type: String, short: 'z' opt :public_hosted_zone, 'Public hosted zone', type: String, short: 'g' opt :create_stack, 'Create the stack', default: false, short: 'c' opt :update_stack, 'Update already deployed stack', default: false, short: 'u' opt :pre_run, 'Use pre-run hooks', default: true, short: 'e' opt :post_run, 'Use post-run hooks', default: true, short: 'o' opt :expand, 'Print generated JSON template', default: false, short: 'x' opt :capabilities, 'AWS capabilities', default: 'CAPABILITY_IAM', short: 'a' opt :vpc_stack_name, 'VPC stack name', default: 'default-vpc', short: 'n' opt :availability_zone, 'Deploy to specific availability zone', default: 'all', short: 'd' opt :profile, 'Use a specific profile from your credential file', type: String, default: nil conflicts :list_templates, :create_stack, :update_stack, :expand end opts = Trollop.with_standard_exception_handling(parser) do fail Trollop::HelpNeeded if argv.empty? parser.parse argv end if opts[:availability_zone_given] valid_values = ('a'..'e').to_a << 'all' unless opts[:availability_zone].split(',').all?{|x| valid_values.include?(x)} STDERR.puts %(Availability zone can be only one off "#{valid_values.join(',')}") exit end end # fallback to create_stack action when no action was given if !opts[:create_stack] && !opts[:update_stack] opts[:create_stack] = true end # load template from given file and update template list if opts[:template_file] unless File.exist?(opts[:template_file]) abort(format('Unable to find file "%s"', opts[:template_file])) end load(opts[:template_file]) unless Enscalator::Templates.all_valid? STDERR.puts 'Some templates missing required tpl method:' Enscalator::Templates.all.select { |a| !a.instance_methods.include?(:tpl) }.each do |tpl| STDERR.puts tpl.name.demodulize end exit end end templates = Enscalator::Templates.constants.map(&:to_s) if opts[:list_templates] STDERR.puts 'Available templates:' STDERR.puts templates.sort exit end if opts[:template] && templates.include?(opts[:template]) # for stack_name use template name as a base and convert it from camelcase to underscore case opts[:stack_name] ||= opts[:template].underscore.gsub(/[_]/, '-') Object.const_get("Enscalator::Templates::#{opts[:template]}").new(opts.merge(ARGV: argv_dup)).exec! elsif opts[:template_given] && !opts[:template].empty? STDERR.puts %(Template "#{opts[:template]}" doesn't exist) else STDERR.puts 'Template name cannot be an empty string' end end |