Class: Legworker::Legs

Inherits:
Object
  • Object
show all
Defined in:
lib/legworker.rb

Instance Method Summary collapse

Instance Method Details

#setup_app(options) ⇒ Object


Setup Application & Databases




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
# File 'lib/legworker.rb', line 34

def setup_app(options)
	app_options = {}
	vagrant_file = 'config/puppet/manifests/vagrant.pp'

	file = File.open(vagrant_file)
	contents = file.read

		contents.gsub!('_APPLICATION_NAME_',options[:application_name])
		contents.gsub!('_DEV_USER_',options[:dev_user])
		contents.gsub!('_DEV_PASS_',options[:dev_pass])
		contents.gsub!('_PROD_USER_',options[:prod_user])
		contents.gsub!('_PROD_PASS_',options[:prod_pass])

		File.open(vagrant_file, "w") { |f| f.puts contents }

		database_yml = "config/puppet/templates/database.yml.erb"
		
		db = File.open(database_yml)
		db_contents = db.read

		db_contents.gsub!("_DEV_DATABASE_",options[:dev_database])
		db_contents.gsub!("_PROD_DATABASE_",options[:prod_database])
		db_contents.gsub!('_DEV_USER_',options[:dev_user])
		db_contents.gsub!('_DEV_PASS_',options[:dev_pass])
		db_contents.gsub!('_PROD_USER_',options[:prod_user])
		db_contents.gsub!('_PROD_PASS_',options[:prod_pass])

		File.open(database_yml, "w") { |f| f.puts db_contents }


end

#vagrant(options) ⇒ Object


Download Vagrant & Puppet




12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/legworker.rb', line 12

def vagrant(options)

	# download useful things
	system('curl -sS https://s3.amazonaws.com/legworker/Vagrantfile > Vagrantfile')

	# download puppet.zip
		system('curl -sS https://s3.amazonaws.com/legworker/puppet.zip > puppet.zip')
		system('unzip puppet.zip -d config')
		system('rm puppet.zip')
		system('rm -rf config/__MACOSX || exit')
		system('rm -rf Gemfile')
		system('curl -sS https://s3.amazonaws.com/legworker/Gemfile > Gemfile')

		self.setup_app(options)

end