Class: Orats::Commands::Inventory

Inherits:
Common
  • Object
show all
Includes:
Project::Rails
Defined in:
lib/orats/commands/inventory.rb

Constant Summary

Constants inherited from Common

Common::RELATIVE_PATHS

Instance Attribute Summary

Attributes inherited from Common

#local_paths, #remote_gem_version, #remote_paths

Instance Method Summary collapse

Methods included from Project::Rails

#bundle_binstubs, #bundle_install, #check_exit_conditions, #create_and_migrate_database, #custom_rails_template, #generate_favicons, #generate_home_page, #gsub_postgres_info, #gsub_project_path, #gsub_readme, #gsub_redis_info, #migrate_and_seed_database, #rails_template, #run_rake, #spring_binstub, #template_exist?

Methods inherited from Common

#base_path, copy_from_local_gem, #exit_if_path_exists, #exit_if_process, #file_to_string, #repo_path, #url_to_string

Methods included from Diff::Parse

#galaxyfile, #gem_version, #hosts, #inventory, #playbook

Methods included from UI

#git_commit, #log_error, #log_local_info, #log_remote_info, #log_results, #log_status_bottom, #log_status_top, #log_task, #run_from

Constructor Details

#initialize(target_path = '', options = {}) ⇒ Inventory

Returns a new instance of Inventory.



10
11
12
# File 'lib/orats/commands/inventory.rb', line 10

def initialize(target_path = '', options = {})
  super
end

Instance Method Details

#initObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/orats/commands/inventory.rb', line 14

def init
  exit_if_path_exists('inventory')

  create_inventory

  secrets_path = "#{@target_path}/secrets"
  create_secrets secrets_path

  log_task 'Update secrets path in group_vars/all.yml'
  gsub_file "#{@target_path}/#{fix_path_for_user(Common::RELATIVE_PATHS[:inventory])}",
            '/home/yourname/dev/testproj/secrets', File.expand_path(secrets_path)

  log_task 'Update place holder app name in group_vars/all.yml'
  gsub_file "#{@target_path}/#{fix_path_for_user(Common::RELATIVE_PATHS[:inventory])}",
            'testproj', File.basename(@target_path)

  log_task 'Add ssh keypair'
  run "ssh-keygen -t rsa -P '' -f #{secrets_path}/id_rsa"

  log_task 'Add self signed ssl certificates'
  run create_rsa_certificate(secrets_path, 'sslkey.key', 'sslcert.crt')

  log_task 'Add monit pem file'
  run "#{create_rsa_certificate(secrets_path,
                                'monit.pem', 'monit.pem')} && openssl gendh 512 >> #{secrets_path}/monit.pem"

  install_role_dependencies unless @options[:skip_galaxy]

  log_success
end