vito 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +11 -0
  3. data/README.md +32 -19
  4. data/Rakefile +5 -20
  5. data/bin/vito +1 -1
  6. data/lib/vito.rb +5 -1
  7. data/lib/vito/command_line/command.rb +21 -0
  8. data/lib/vito/command_line/document_flags.rb +30 -0
  9. data/lib/vito/command_line/options.rb +41 -0
  10. data/lib/vito/command_line/string.rb +35 -0
  11. data/lib/vito/commands/help.rb +62 -0
  12. data/lib/vito/commands/install.rb +17 -0
  13. data/lib/vito/core_ext/string.rb +33 -0
  14. data/lib/vito/dsl/installation.rb +5 -2
  15. data/lib/vito/dsl/server.rb +3 -3
  16. data/lib/vito/dsl_file.rb +11 -5
  17. data/lib/vito/operating_systems/ubuntu_10.rb +4 -0
  18. data/lib/vito/output.rb +3 -1
  19. data/lib/vito/recipe.rb +29 -4
  20. data/lib/vito/recipes/apache/install.rb +155 -0
  21. data/lib/vito/recipes/apache/service.rb +20 -0
  22. data/lib/vito/recipes/git/install.rb +39 -0
  23. data/lib/vito/recipes/passenger/install.rb +83 -0
  24. data/lib/vito/recipes/passenger/paths.rb +27 -0
  25. data/lib/vito/recipes/postgres/install.rb +106 -0
  26. data/lib/vito/recipes/rbenv/install.rb +54 -0
  27. data/lib/vito/recipes/ruby/install.rb +57 -0
  28. data/lib/vito/recipes/ruby/paths.rb +19 -0
  29. data/lib/vito/tasks/vagrant_bootstrap.rb +49 -0
  30. data/lib/vito/tests/vagrant_test_box.rb +44 -0
  31. data/lib/vito/utils/program_version.rb +2 -2
  32. data/lib/vito/version.rb +1 -1
  33. data/spec/acceptance/recipes/apache_acceptance_spec.rb +25 -0
  34. data/spec/acceptance/recipes/git_acceptance_spec.rb +11 -11
  35. data/spec/acceptance/recipes/postgres_acceptance_spec.rb +11 -11
  36. data/spec/acceptance/recipes/rbenv_acceptance_spec.rb +13 -13
  37. data/spec/acceptance/recipes/ruby_acceptance_spec.rb +15 -15
  38. data/spec/support/vagrant.rb +21 -16
  39. data/spec/vagrant_boxes/centos63/.gitkeep +0 -0
  40. data/{Vagrantfile → spec/vagrant_boxes/centos63/Vagrantfile} +5 -4
  41. data/spec/vagrant_boxes/ubuntu10/Vagrantfile +100 -0
  42. data/spec/vagrant_boxes/ubuntu12/Vagrantfile +100 -0
  43. data/spec/vito/command_line/command_spec.rb +20 -0
  44. data/spec/vito/command_line/options_spec.rb +50 -0
  45. data/spec/vito/command_line/string_spec.rb +32 -0
  46. data/spec/vito/commands/install_spec.rb +9 -0
  47. data/spec/vito/connection_spec.rb +2 -2
  48. data/spec/vito/core_ext/string_spec.rb +19 -0
  49. data/spec/vito/dsl/installation_spec.rb +2 -2
  50. data/spec/vito/dsl_file_spec.rb +56 -18
  51. data/spec/vito/output_spec.rb +2 -2
  52. data/spec/vito/recipe_spec.rb +53 -3
  53. data/spec/vito/recipes/apache/install_spec.rb +140 -0
  54. data/spec/vito/recipes/passenger/paths_spec.rb +18 -0
  55. data/spec/vito/recipes/ruby_spec.rb +5 -5
  56. data/spec/vito/tasks/vagrant_bootstrap_spec.rb +65 -0
  57. data/spec/vito/tests/vagrant_test_box_spec.rb +69 -0
  58. data/spec/vito/utils/program_version_spec.rb +4 -2
  59. data/templates/apache2/vito_site +12 -0
  60. data/vito.gemspec +1 -1
  61. data/vito.rb +7 -5
  62. metadata +53 -13
  63. data/lib/vito/recipes/git.rb +0 -37
  64. data/lib/vito/recipes/postgres.rb +0 -104
  65. data/lib/vito/recipes/rbenv.rb +0 -47
  66. data/lib/vito/recipes/ruby.rb +0 -43
  67. data/lib/vito/shell_initializer.rb +0 -21
  68. data/spec/vito/shell_initializer_spec.rb +0 -22
@@ -1,24 +1,24 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe "Ruby recipe" do
4
- before do
5
- setup_vagrant
6
- end
4
+ Vito::Tests::VagrantTestBox.boxes(:ubuntu10, :ubuntu12).each do |box|
5
+ it "tests on #{box.name}" do
6
+ setup_vagrant(box)
7
7
 
8
- it "installs Git, Rbenv and then Ruby" do
9
- assert_installation("git --version").should be_false
10
- assert_installation("rbenv --version").should be_false
11
- assert_installation("ruby -v").should be_false
8
+ assert_installation(box, "git --version").should be_false
9
+ assert_installation(box, "rbenv --version").should be_false
10
+ assert_installation(box, "ruby -v").should be_false
12
11
 
13
- Vito::DslFile.new.run do
14
- server do
15
- connection :ssh, command: 'ssh -i ~/.vagrant.d/insecure_private_key vagrant@localhost -p2222', silent: true
16
- install :ruby, version: "1.9.3-p125"
12
+ Vito::DslFile.new.run do
13
+ server do
14
+ connection :ssh, command: "ssh -i ~/.vagrant.d/insecure_private_key vagrant@localhost -p#{box.ssh_port}", verbose: true
15
+ install :ruby, version: "1.9.3-p125"
16
+ end
17
17
  end
18
- end
19
18
 
20
- assert_installation("git --version").should be_true
21
- assert_installation("rbenv --version").should be_true
22
- assert_installation("ruby -v").should be_true
19
+ assert_installation(box, "git --version").should be_true
20
+ assert_installation(box, "rbenv --version").should be_true
21
+ assert_installation(box, "ruby -v").should be_true
22
+ end
23
23
  end
24
24
  end
@@ -1,34 +1,39 @@
1
1
  module RSpecSupport
2
2
  module Vagrant
3
- def connection
4
- 'ssh -i ~/.vagrant.d/insecure_private_key vagrant@localhost -p2222'
3
+ def connection(box)
4
+ "ssh -i ~/.vagrant.d/insecure_private_key vagrant@localhost -p#{box.ssh_port}"
5
5
  end
6
6
 
7
- def setup_vagrant
8
- system_command("vagrant up")
9
- raise "Box not working" unless vagrant_command("ls")
10
- reboot_vagrant_box
7
+ def setup_vagrant(box)
8
+ puts "Starting test on #{box.name}"
9
+ system_command("cd #{box.path} && vagrant up")
10
+ raise "Box not working" unless vagrant_command(box, "ls")
11
+ reboot_vagrant_box(box)
11
12
  end
12
13
 
13
- def assert_installation(command)
14
- vagrant_command(command)
14
+ def assert_installation(box, command)
15
+ vagrant_command(box, command)
15
16
  end
16
17
 
17
- def reboot_vagrant_box
18
- system_command("vagrant snapshot go initial_box")
18
+ def reboot_vagrant_box(box)
19
+ system_command("cd #{box.path} && vagrant snapshot go #{box.initial_snapshot_name}")
19
20
  end
20
21
 
21
22
  private
22
23
 
23
24
  def system_command(command)
24
- stdin, stdout, stderr, thread = Open3.popen3(command)
25
- thread.value.exitstatus == 0
25
+ #stdin, stdout, stderr, thread = Open3.popen3(command)
26
+ #puts stdout.read
27
+ #thread.value.exitstatus == 0
28
+ system(command)
26
29
  end
27
30
 
28
- def vagrant_command(command)
29
- command = "#{connection} #{command}"
30
- stdin, stdout, stderr, thread = Open3.popen3(command)
31
- thread.value.exitstatus == 0
31
+ def vagrant_command(box, command)
32
+ command = "#{connection(box)} #{command}"
33
+ #stdin, stdout, stderr, thread = Open3.popen3(command)
34
+ #puts stdout.read
35
+ #thread.value.exitstatus == 0
36
+ system(command)
32
37
  end
33
38
  end
34
39
  end
File without changes
@@ -1,17 +1,17 @@
1
1
  # -*- mode: ruby -*-
2
2
  # vi: set ft=ruby :
3
3
 
4
- Vagrant::Config.run do |config|
4
+ Vagrant.configure("2") do |config|
5
5
  # All Vagrant configuration is done here. The most common configuration
6
6
  # options are documented and commented below. For a complete reference,
7
7
  # please see the online documentation at vagrantup.com.
8
8
 
9
9
  # Every Vagrant virtual environment requires a box to build off of.
10
- config.vm.box = "ubuntu_spec_box"
10
+ config.vm.box = "centos63_test_box"
11
11
 
12
12
  # The url from where the 'config.vm.box' box will be fetched if it
13
13
  # doesn't already exist on the user's system.
14
- # config.vm.box_url = "http://domain.com/path/to/above.box"
14
+ config.vm.box_url = "https://dl.dropbox.com/u/7225008/Vagrant/CentOS-6.3-x86_64-minimal.box"
15
15
 
16
16
  # Boot with a GUI so you can see the screen. (Default is headless)
17
17
  # config.vm.boot_mode = :gui
@@ -29,7 +29,8 @@ Vagrant::Config.run do |config|
29
29
 
30
30
  # Forward a port from the guest to the host, which allows for outside
31
31
  # computers to access the VM, whereas host only networking does not.
32
- # config.vm.forward_port 23, 22
32
+ #config.vm.forward_port 23, 22
33
+ config.vm.network :forwarded_port, guest: 22, host: 2225
33
34
 
34
35
  # Share an additional folder to the guest VM. The first argument is
35
36
  # an identifier, the second is the path on the guest to mount the
@@ -0,0 +1,100 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure("2") do |config|
5
+ # All Vagrant configuration is done here. The most common configuration
6
+ # options are documented and commented below. For a complete reference,
7
+ # please see the online documentation at vagrantup.com.
8
+
9
+ # Every Vagrant virtual environment requires a box to build off of.
10
+ config.vm.box = "ubuntu10_test_box"
11
+
12
+ # The url from where the 'config.vm.box' box will be fetched if it
13
+ # doesn't already exist on the user's system.
14
+ config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box"
15
+
16
+ # Boot with a GUI so you can see the screen. (Default is headless)
17
+ # config.vm.boot_mode = :gui
18
+
19
+ # Assign this VM to a host-only network IP, allowing you to access it
20
+ # via the IP. Host-only networks can talk to the host machine as well as
21
+ # any other machines on the same network, but cannot be accessed (through this
22
+ # network interface) by any external networks.
23
+ # config.vm.network :hostonly, "192.168.33.10"
24
+
25
+ # Assign this VM to a bridged network, allowing you to connect directly to a
26
+ # network using the host's network device. This makes the VM appear as another
27
+ # physical device on your network.
28
+ # config.vm.network :bridged
29
+
30
+ # Forward a port from the guest to the host, which allows for outside
31
+ # computers to access the VM, whereas host only networking does not.
32
+ #config.vm.forward_port 23, 22
33
+ config.vm.network :forwarded_port, guest: 22, host: 2223
34
+
35
+ # Share an additional folder to the guest VM. The first argument is
36
+ # an identifier, the second is the path on the guest to mount the
37
+ # folder, and the third is the path on the host to the actual folder.
38
+ # config.vm.share_folder "v-data", "/vagrant_data", "../data"
39
+
40
+ # Enable provisioning with Puppet stand alone. Puppet manifests
41
+ # are contained in a directory path relative to this Vagrantfile.
42
+ # You will need to create the manifests directory and a manifest in
43
+ # the file ubuntu_spec_box.pp in the manifests_path directory.
44
+ #
45
+ # An example Puppet manifest to provision the message of the day:
46
+ #
47
+ # # group { "puppet":
48
+ # # ensure => "present",
49
+ # # }
50
+ # #
51
+ # # File { owner => 0, group => 0, mode => 0644 }
52
+ # #
53
+ # # file { '/etc/motd':
54
+ # # content => "Welcome to your Vagrant-built virtual machine!
55
+ # # Managed by Puppet.\n"
56
+ # # }
57
+ #
58
+ # config.vm.provision :puppet do |puppet|
59
+ # puppet.manifests_path = "manifests"
60
+ # puppet.manifest_file = "ubuntu_spec_box.pp"
61
+ # end
62
+
63
+ # Enable provisioning with chef solo, specifying a cookbooks path, roles
64
+ # path, and data_bags path (all relative to this Vagrantfile), and adding
65
+ # some recipes and/or roles.
66
+ #
67
+ # config.vm.provision :chef_solo do |chef|
68
+ # chef.cookbooks_path = "../my-recipes/cookbooks"
69
+ # chef.roles_path = "../my-recipes/roles"
70
+ # chef.data_bags_path = "../my-recipes/data_bags"
71
+ # chef.add_recipe "mysql"
72
+ # chef.add_role "web"
73
+ #
74
+ # # You may also specify custom JSON attributes:
75
+ # chef.json = { :mysql_password => "foo" }
76
+ # end
77
+
78
+ # Enable provisioning with chef server, specifying the chef server URL,
79
+ # and the path to the validation key (relative to this Vagrantfile).
80
+ #
81
+ # The Opscode Platform uses HTTPS. Substitute your organization for
82
+ # ORGNAME in the URL and validation key.
83
+ #
84
+ # If you have your own Chef Server, use the appropriate URL, which may be
85
+ # HTTP instead of HTTPS depending on your configuration. Also change the
86
+ # validation key to validation.pem.
87
+ #
88
+ # config.vm.provision :chef_client do |chef|
89
+ # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
90
+ # chef.validation_key_path = "ORGNAME-validator.pem"
91
+ # end
92
+ #
93
+ # If you're using the Opscode platform, your validator client is
94
+ # ORGNAME-validator, replacing ORGNAME with your organization name.
95
+ #
96
+ # IF you have your own Chef Server, the default validation client name is
97
+ # chef-validator, unless you changed the configuration.
98
+ #
99
+ # chef.validation_client_name = "ORGNAME-validator"
100
+ end
@@ -0,0 +1,100 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure("2") do |config|
5
+ # All Vagrant configuration is done here. The most common configuration
6
+ # options are documented and commented below. For a complete reference,
7
+ # please see the online documentation at vagrantup.com.
8
+
9
+ # Every Vagrant virtual environment requires a box to build off of.
10
+ config.vm.box = "ubuntu12_test_box"
11
+
12
+ # The url from where the 'config.vm.box' box will be fetched if it
13
+ # doesn't already exist on the user's system.
14
+ config.vm.box_url = "https://dl.dropboxusercontent.com/u/165709740/boxes/precise64-vanilla.box"
15
+
16
+ # Boot with a GUI so you can see the screen. (Default is headless)
17
+ # config.vm.boot_mode = :gui
18
+
19
+ # Assign this VM to a host-only network IP, allowing you to access it
20
+ # via the IP. Host-only networks can talk to the host machine as well as
21
+ # any other machines on the same network, but cannot be accessed (through this
22
+ # network interface) by any external networks.
23
+ # config.vm.network :hostonly, "192.168.33.10"
24
+
25
+ # Assign this VM to a bridged network, allowing you to connect directly to a
26
+ # network using the host's network device. This makes the VM appear as another
27
+ # physical device on your network.
28
+ # config.vm.network :bridged
29
+
30
+ # Forward a port from the guest to the host, which allows for outside
31
+ # computers to access the VM, whereas host only networking does not.
32
+ #config.vm.forward_port 23, 22
33
+ config.vm.network :forwarded_port, guest: 22, host: 2224
34
+
35
+ # Share an additional folder to the guest VM. The first argument is
36
+ # an identifier, the second is the path on the guest to mount the
37
+ # folder, and the third is the path on the host to the actual folder.
38
+ # config.vm.share_folder "v-data", "/vagrant_data", "../data"
39
+
40
+ # Enable provisioning with Puppet stand alone. Puppet manifests
41
+ # are contained in a directory path relative to this Vagrantfile.
42
+ # You will need to create the manifests directory and a manifest in
43
+ # the file ubuntu_spec_box.pp in the manifests_path directory.
44
+ #
45
+ # An example Puppet manifest to provision the message of the day:
46
+ #
47
+ # # group { "puppet":
48
+ # # ensure => "present",
49
+ # # }
50
+ # #
51
+ # # File { owner => 0, group => 0, mode => 0644 }
52
+ # #
53
+ # # file { '/etc/motd':
54
+ # # content => "Welcome to your Vagrant-built virtual machine!
55
+ # # Managed by Puppet.\n"
56
+ # # }
57
+ #
58
+ # config.vm.provision :puppet do |puppet|
59
+ # puppet.manifests_path = "manifests"
60
+ # puppet.manifest_file = "ubuntu_spec_box.pp"
61
+ # end
62
+
63
+ # Enable provisioning with chef solo, specifying a cookbooks path, roles
64
+ # path, and data_bags path (all relative to this Vagrantfile), and adding
65
+ # some recipes and/or roles.
66
+ #
67
+ # config.vm.provision :chef_solo do |chef|
68
+ # chef.cookbooks_path = "../my-recipes/cookbooks"
69
+ # chef.roles_path = "../my-recipes/roles"
70
+ # chef.data_bags_path = "../my-recipes/data_bags"
71
+ # chef.add_recipe "mysql"
72
+ # chef.add_role "web"
73
+ #
74
+ # # You may also specify custom JSON attributes:
75
+ # chef.json = { :mysql_password => "foo" }
76
+ # end
77
+
78
+ # Enable provisioning with chef server, specifying the chef server URL,
79
+ # and the path to the validation key (relative to this Vagrantfile).
80
+ #
81
+ # The Opscode Platform uses HTTPS. Substitute your organization for
82
+ # ORGNAME in the URL and validation key.
83
+ #
84
+ # If you have your own Chef Server, use the appropriate URL, which may be
85
+ # HTTP instead of HTTPS depending on your configuration. Also change the
86
+ # validation key to validation.pem.
87
+ #
88
+ # config.vm.provision :chef_client do |chef|
89
+ # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
90
+ # chef.validation_key_path = "ORGNAME-validator.pem"
91
+ # end
92
+ #
93
+ # If you're using the Opscode platform, your validator client is
94
+ # ORGNAME-validator, replacing ORGNAME with your organization name.
95
+ #
96
+ # IF you have your own Chef Server, the default validation client name is
97
+ # chef-validator, unless you changed the configuration.
98
+ #
99
+ # chef.validation_client_name = "ORGNAME-validator"
100
+ end
@@ -0,0 +1,20 @@
1
+ require "spec_helper"
2
+
3
+ describe Vito::CommandLine::Command do
4
+ let(:options) { double }
5
+ let(:command_line) { double(options: options) }
6
+
7
+ subject { described_class.new(command_line) }
8
+
9
+ describe "#command" do
10
+ it "returns help if --help is passed" do
11
+ options.stub(help: true)
12
+ subject.command.should == "help"
13
+ end
14
+
15
+ it "returns run by default" do
16
+ options.stub(help: false)
17
+ subject.command.should == "install"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,50 @@
1
+ require "spec_helper"
2
+
3
+ describe Vito::CommandLine::Options do
4
+ let(:argv) { [] }
5
+
6
+ subject { described_class.new(argv) }
7
+
8
+ describe "#file" do
9
+ context "file is passed in" do
10
+ let(:argv) { ["-f", "some_path"] }
11
+ its(:file) { should == "some_path" }
12
+ end
13
+
14
+ context "command and file are passed in" do
15
+ let(:argv) { ["install", "-f", "some_path"] }
16
+ its(:file) { should == "some_path" }
17
+ end
18
+
19
+ context "no file is passed in" do
20
+ let(:argv) { ["-x", "no_file"] }
21
+ its(:file) { should be_nil }
22
+ end
23
+ end
24
+
25
+ describe "#help" do
26
+ context "-h is passed in" do
27
+ let(:argv) { ["-f", "some_path", "-h"] }
28
+ its(:help) { should be_true }
29
+ end
30
+
31
+ context "--help is passed in" do
32
+ let(:argv) { ["-f", "some_path", "--help"] }
33
+ its(:help) { should be_true }
34
+ end
35
+
36
+ context "neither -h nor --help is passed in" do
37
+ let(:argv) { ["-f", "some_path"] }
38
+ its(:help) { should be_false }
39
+ end
40
+ end
41
+
42
+ describe "#available_options" do
43
+ it "returns all available options" do
44
+ subject.available_options.should == [
45
+ [["-f", "--file filename"], "Defines a file"],
46
+ [["-h", "--help"], "Shows this documentation"]
47
+ ]
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,32 @@
1
+ require "spec_helper"
2
+
3
+ describe Vito::CommandLine::String do
4
+ let(:argv) { [] }
5
+ let(:dsl_file) { double }
6
+
7
+ subject { described_class.new(argv) }
8
+
9
+ describe "#run" do
10
+ describe "no command given" do
11
+ it "runs the default operation" do
12
+ Vito::DslFile.should_receive(:new).with(subject) { dsl_file }
13
+ dsl_file.should_receive(:run)
14
+ subject.run
15
+ end
16
+ end
17
+ end
18
+
19
+ describe "#options" do
20
+ it "returns an options object" do
21
+ Vito::CommandLine::Options.stub(:new).with(argv) { :options }
22
+ subject.options.should == :options
23
+ end
24
+ end
25
+
26
+ describe "#command" do
27
+ it "returns the command to be used" do
28
+ Vito::CommandLine::Command.stub(:new).with(subject) { double(command: :command) }
29
+ subject.command.should == :command
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,9 @@
1
+ require "vito/commands/install"
2
+
3
+ describe Vito::Commands::Install do
4
+ describe "#some_method" do
5
+ it "returns true" do
6
+
7
+ end
8
+ end
9
+ end