Class: Subspace::Cli

Inherits:
Object
  • Object
show all
Includes:
Commander::Methods
Defined in:
lib/subspace/cli.rb

Instance Method Summary collapse

Instance Method Details

#runObject

include whatever modules you need



22
23
24
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/subspace/cli.rb', line 22

def run
  program :name, 'subspace'
  program :version, Subspace::VERSION
  program :description, 'Ansible-backed server provisioning tool for rails'

  command :init do |c|
    c.syntax = 'subspace init [vars]'
    c.summary = 'Run without options to initialize subspace.'
    c.description = 'Some initialization routines can be run indiviaully, useful for upgrading'
    c.example 'init a new project', 'subspace init'
    c.example 'create the new style application.yml vars template', 'subspace init vars'
    c.when_called Subspace::Commands::Init
  end

  command :bootstrap do |c|
    c.syntax = 'subspace boostrap [host]'
    c.summary = 'Install ansible requirements (python) and authorized_keys file'
    c.description = 'Ansible has very few dependencies, but python is one that is not installed by
    default on many linux images.  The bootstrap command will install python on a host as well as
    copy the authorized_keys file.  You will possibly need to type a password here.'
    c.option '--password', "Ask for a password instead of using ssh keys"
    c.option '--yum', "Use yum instead of apt to install python"
    c.option "-i", "--private-key PRIVATE-KEY", "Alias for private-key"
    Subspace::Commands::Bootstrap::PASS_THROUGH_PARAMS.each do |param_name|
      c.option "--#{param_name} #{param_name.upcase}", "Passed directly through to ansible-playbook command"
    end
    c.when_called Subspace::Commands::Bootstrap
  end

  command :provision do |c|
    c.syntax = 'subspace provision [options]'
    c.summary = ''
    c.description = ''
    c.option "-i", "--private-key PRIVATE-KEY", "Alias for private-key"
    Subspace::Commands::Provision::PASS_THROUGH_PARAMS.each do |param_name|
      c.option "--#{param_name} #{param_name.upcase}", "Passed directly through to ansible-playbook command"
    end
    c.when_called Subspace::Commands::Provision
  end

  command :ssh do |c|
    c.syntax = 'subspace ssh [options]'
    c.summary = 'ssh to the remote server as the administrative user'
    c.description = ''
    c.option '--user USER', "Use a different user (eg deploy).  Default is the ansible_ssh_user"
    Subspace::Commands::Ssh::PASS_THROUGH_PARAMS.each do |param_name|
      c.option "-#{param_name} #{param_name.upcase}", "Passed directly through to ssh command"
    end
    c.when_called Subspace::Commands::Ssh
  end

  command :configure do |c, args|
    c.syntax = 'subspace configure'
    c.summary = "Regenerate all of the ansible configuration files. You don't normally need to run this."
    c.description = ''
    c.when_called Subspace::Commands::Configure
  end

  command :override do |c, args|
    c.syntax = 'subspace override [role]'
    c.summary = 'Override a role configuration by copying the configuration locally'
    c.description = 'Copies the default role configuration to config/provision/<role> where it can be modified.'
    c.when_called Subspace::Commands::Override
  end

  command :vars do |c, args|
    c.syntax = 'subspace vars [environment]'
    c.summary = 'View or edit the encrypted variables for an environment'
    c.description = """By default, this will simply show the variables for a specific environemnt.
                       You can also edit variables, and we expect the functionality here to grow in the future.
                       Running `subspace vars development --create` is usually a great way to bootstrap a new development environment."""
    c.option '--edit', "Edit the variables instead of view"
    c.option '--create', "Create config/application.yml with the variables from the specified environment"
    c.when_called Subspace::Commands::Vars
  end

  command :maintain do |c, args|
    c.syntax = 'subspace maintain [options]'
    c.summary = 'Runs provision with --tags=maintenance'
    c.description = ''
    c.option "-i", "--private-key PRIVATE-KEY", "Alias for private-key"
    Subspace::Commands::Maintain::PASS_THROUGH_PARAMS.each do |param_name|
      c.option "--#{param_name} #{param_name.upcase}", "Passed directly through to ansible-playbook command"
    end
    c.when_called Subspace::Commands::Maintain
  end

  command :maintenance_mode do |c, args|
    c.syntax = 'subspace maintenance_mode [options]'
    c.summary = 'Turns on or off maintenance mode'
    c.description = ''
    c.option "-i", "--private-key PRIVATE-KEY", "Alias for private-key"
    c.option "--on", "Turns on maintenance mode"
    c.option "--off", "Turns off maintenance mode"
    Subspace::Commands::MaintenanceMode::PASS_THROUGH_PARAMS.each do |param_name|
      c.option "--#{param_name} #{param_name.upcase}", "Passed directly through to ansible-playbook command"
    end
    c.when_called Subspace::Commands::MaintenanceMode
  end

  run!
end