Sha256: 4919614acd868a34629459df974aa788550d82ee0474f22af04154011487d7a2

Contents?: true

Size: 1.81 KB

Versions: 1

Compression:

Stored size: 1.81 KB

Contents

class AwsStackBuilderGenerator < Rails::Generators::Base
  source_root File.expand_path('../templates', __FILE__)
  argument :app_name, :type => :string
  argument :roles, :type => :array

  def create_aws_folder
    @app_name = app_name
    @roles = roles
    puts "Gerando na pasta aws todos os arquivos necessários"
    puts "para criarmos o stack na AWS para o app #{app_name}"
    puts "com os roles #{roles.join(', ')}."
    puts "Consute o arquivo aws/doc/README.md para instruções."

    copy_standard_files
    create_custom_files

    # transformo os arquivos em executáveis
    File.chmod(0755,"aws/geradores/build_templates.sh")
    File.chmod(0755,"aws/scripts/app_deploy.sh")
    File.chmod(0755,"aws/scripts/app_pack.sh")
    File.chmod(0755,"aws/scripts/app_stop_instances.sh")
    File.chmod(0755,"aws/scripts/app_update.sh")
    File.chmod(0755,"aws/scripts/run_delayed_job.sh")
    puts "Arquivos gerados."

  end

  private

  def copy_standard_files
    directory "aws/doc", "aws/doc"
    copy_file "aws/scripts/app_pack.sh"
    copy_file "aws/scripts/run_delayed_job.sh"
  end

  def create_custom_files
    # aqui geramos os arquivos com os roles baseados nos workers informados
    template "aws/geradores/ami-userdata.sh.template", "aws/geradores/ami-userdata.sh"
    template "aws/geradores/build_templates.sh.template", "aws/geradores/build_templates.sh"
    template "aws/scripts/app_deploy.sh.template", "aws/scripts/app_deploy.sh"
    template "aws/scripts/app_stop_instances_by_role.sh.template", "aws/scripts/app_stop_instances.sh"
    template "aws/scripts/app_update.sh.template", "aws/scripts/app_update.sh"
    template "aws/geradores/cf-stack-generator.py.template", "aws/geradores/cf-stack-generator.py"
    template "aws/geradores/cf-base-instance.py.template", "aws/geradores/cf-base-instance.py"
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aws_stack_builder-0.1.0 lib/generators/aws_stack_builder/aws_stack_builder_generator.rb