Module: Inception::CliHelpers::PrepareDeploySettings
- Included in:
- Inception::Cli
- Defined in:
- lib/inception/cli_helpers/prepare_deploy_settings.rb
Instance Method Summary collapse
- #default_key_pair_name ⇒ Object
- #default_server_name ⇒ Object
- #private_key_path_for_inception ⇒ Object
-
#provision_or_reuse_public_ip_address_for_inception ⇒ Object
Attempt to provision a new public IP; if none available, then look for a pre-provisioned public IP that’s not assigned to a server; else error.
- #recreate_key_pair_for_inception ⇒ Object
-
#recreate_private_key_file_for_inception ⇒ Object
The keys for the inception server originate from the provider and are cached in the manifest.
- #update_git_config ⇒ Object
-
#validate_deploy_settings ⇒ Object
Required settings: * git.name * git.email.
Instance Method Details
#default_key_pair_name ⇒ Object
33 34 35 |
# File 'lib/inception/cli_helpers/prepare_deploy_settings.rb', line 33 def default_key_pair_name default_server_name end |
#default_server_name ⇒ Object
29 30 31 |
# File 'lib/inception/cli_helpers/prepare_deploy_settings.rb', line 29 def default_server_name "inception" end |
#private_key_path_for_inception ⇒ Object
46 47 48 |
# File 'lib/inception/cli_helpers/prepare_deploy_settings.rb', line 46 def private_key_path_for_inception @private_key_path_for_inception ||= File.join(settings_dir, "ssh", settings.inception.key_pair.name) end |
#provision_or_reuse_public_ip_address_for_inception ⇒ Object
Attempt to provision a new public IP; if none available, then look for a pre-provisioned public IP that’s not assigned to a server; else error. The user needs to go get more public IP addresses in this region.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/inception/cli_helpers/prepare_deploy_settings.rb', line 17 def provision_or_reuse_public_ip_address_for_inception say "Acquiring a public IP address... " if public_ip = provider_client.provision_or_reuse_public_ip_address say public_ip, :green settings.set("inception.provisioned.ip_address", public_ip) save_settings! else say "none available.", :red error "Please rustle up at least one public IP address and try again." end end |
#recreate_key_pair_for_inception ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/inception/cli_helpers/prepare_deploy_settings.rb', line 37 def recreate_key_pair_for_inception key_pair_name = settings.set_default("inception.key_pair.name", default_key_pair_name) provider_client.delete_key_pair_if_exists(key_pair_name) key_pair = provider_client.create_key_pair(key_pair_name) settings.set("inception.key_pair.private_key", key_pair.private_key) settings.set("inception.key_pair.fingerprint", key_pair.fingerprint) save_settings! end |
#recreate_private_key_file_for_inception ⇒ Object
The keys for the inception server originate from the provider and are cached in the manifest. The private key is stored locally; the public key is placed on the inception server.
53 54 55 56 57 58 |
# File 'lib/inception/cli_helpers/prepare_deploy_settings.rb', line 53 def recreate_private_key_file_for_inception mkdir_p(File.dirname(private_key_path_for_inception)) File.chmod(0700, File.dirname(private_key_path_for_inception)) File.open(private_key_path_for_inception, "w") { |file| file << settings.inception.key_pair.private_key } File.chmod(0600, private_key_path_for_inception) end |
#update_git_config ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/inception/cli_helpers/prepare_deploy_settings.rb', line 3 def update_git_config gitconfig = File.("~/.gitconfig") if File.exists?(gitconfig) say "Using your git user.name (#{`git config -f #{gitconfig} user.name`.strip})" settings.set("git.name", `git config -f #{gitconfig} user.name`.strip) settings.set("git.email", `git config -f #{gitconfig} user.email`.strip) save_settings! end end |
#validate_deploy_settings ⇒ Object
Required settings:
-
git.name
-
git.email
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/inception/cli_helpers/prepare_deploy_settings.rb', line 64 def validate_deploy_settings begin settings.git.name settings.git.email rescue Settingslogic::MissingSetting => e error "Please setup local git user.name & user.email config; or specify git.name & git.email in settings.yml" end begin settings.provider.name settings.provider.region settings.provider.credentials rescue Settingslogic::MissingSetting => e error "Wooh there, we need provider.name, provider.region, provider.credentials in settings.yml to proceed." end begin settings.inception.provisioned.ip_address settings.inception.key_pair.name settings.inception.key_pair.private_key rescue Settingslogic::MissingSetting => e error "Wooh there, we need inception.provisioned.ip_address, inception.key_pair.name, & inception.key_pair.private_key in settings.yml to proceed." end end |