Class: Subspace::Commands::Init
- Defined in:
- lib/subspace/commands/init.rb
Instance Method Summary collapse
-
#initialize(args, options) ⇒ Init
constructor
A new instance of Init.
- #run ⇒ Object
Methods inherited from Base
#confirm_overwrite, #copy, #dest_dir, #gem_path, #inventory, #pass_through_params, #playbook_dir, #project_name, #project_path, #require_configuration, #set_subspace_version, #template, #template!, #template_dir
Methods included from Ansible
#ansible_command, #ansible_playbook
Constructor Details
#initialize(args, options) ⇒ Init
Returns a new instance of Init.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/subspace/commands/init.rb', line 5 def initialize(args, ) .default env: "dev" @env = .env @template = .template if .ansibe.nil? && .terraform.nil? # They didn't pass in any options (subspace init) so just do both .ansible = true .terraform = true end if @template.nil? && .terraform == true answer = ask "What template/server configuration would you like to use? e.g. 'workhorse' or 'oxenwagen'" @template = answer end @init_ansible = .ansible @init_terraform = .terraform run end |
Instance Method Details
#run ⇒ Object
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 |
# File 'lib/subspace/commands/init.rb', line 27 def run if File.exists? dest_dir answer = ask "Subspace appears to be initialized. Reply 'yes' to continue anyway: [no] " abort unless answer.chomp == "yes" else FileUtils.mkdir_p dest_dir end init_pemfile init_ansible if @init_ansible init_terraform if @init_terraform puts """ 1. Inspect key config files: - config/subspace/terraform/#{@env}/main.tf # Main terraform file - config/subspace/#{@env}.yml # Main ansible playbook - config/subspace/group_vars # Ansible configuration options - config/subspace/inventory.yml # Server Inventory - config/subspace/templates/authorized_keys # SSH Authorized Keys - config/subspace/templates/application.yml # Application Environment variables 2. create cloud infrastructure with terraform: subspace tf #{@env} 3. Bootstrap the new server subspace boostrap #{@env}1 4. Inspect new environment - ensure the correct roles are present in #{@env}.yml - Check ansible configuration variables in group_vars/#{@env} 4. Provision the new servers with ansible: subspace provision #{@env} !!MAKE SURE YOU PUT config/subspace/subspace.pem SOMEWHERE!! """ end |