Class: Catfish::CLI::Provision

Inherits:
Object
  • Object
show all
Defined in:
lib/catfish/cli/provision.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Provision

Returns a new instance of Provision.



5
6
7
# File 'lib/catfish/cli/provision.rb', line 5

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/catfish/cli/provision.rb', line 3

def options
  @options
end

Instance Method Details

#runObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/catfish/cli/provision.rb', line 9

def run
  puts 'Provisioning to servers using Catfishfile.lock'
  vagrant_version
  begin
    # Connect to the servers. The --provider=managed is the key here.
    system("vagrant up /managed/ --provider=#{options[:provider]}")

    # Confirm the connectivity
    status = `vagrant status /managed/ --machine-readable`
    if status.include? 'not reachable'
      abort 'ERROR DEPLOYING: One or more servers could not be connected to'
    end

    provision status

  ensure

    # Disconnect from all of the servers
    system 'vagrant destroy -f /managed/'

  end
end