katar 2.0.0 → 2.1.0

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.
data/bin/katar CHANGED
@@ -1,6 +1,6 @@
1
- #!/usr/bin/env ruby
2
-
3
- katar_path = File.expand_path('../../lib', __FILE__)
4
- $LOAD_PATH.unshift(katar_path)
5
-
1
+ #!/usr/bin/env ruby
2
+
3
+ katar_path = File.expand_path('../../lib', __FILE__)
4
+ $LOAD_PATH.unshift(katar_path)
5
+
6
6
  require "katar/cli"
data/katar.gemspec CHANGED
@@ -1,26 +1,26 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'katar/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "katar"
8
- spec.version = Katar::VERSION
9
- spec.authors = ["AcMitch"]
10
- spec.email = ["adam.cameron.mitchell@gmail.com"]
11
- spec.summary = "Katar provides a simple, elegant way to manage and provision a Vagrant box on your local machine."
12
- spec.description = "Katar provides a simple, elegant way to manage and provision a Vagrant box on your local machine."
13
- spec.homepage = ""
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = ["katar"]
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency 'rspec', '~> 3.3', '>= 3.3.0'
22
- spec.add_runtime_dependency 'rubyzip', '~> 1.1', '>= 1.1.7'
23
- spec.add_development_dependency "bundler", "~> 1.7"
24
- spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_dependency "thor", "~> 0.19.1"
26
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'katar/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "katar"
8
+ spec.version = Katar::VERSION
9
+ spec.authors = ["AcMitch"]
10
+ spec.email = ["adam.cameron.mitchell@gmail.com"]
11
+ spec.summary = "Katar provides a simple, elegant way to manage and provision a Vagrant box on your local machine."
12
+ spec.description = "Katar provides a simple, elegant way to manage and provision a Vagrant box on your local machine."
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = ["katar"]
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency 'rspec', '~> 3.3', '>= 3.3.0'
22
+ spec.add_runtime_dependency 'rubyzip', '~> 1.1', '>= 1.1.7'
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_dependency "thor", "~> 0.19.1"
26
+ end
data/lib/katar.rb CHANGED
@@ -1,5 +1,5 @@
1
- require "katar/version"
2
-
3
- module Katar
4
-
5
- end
1
+ require "katar/version"
2
+
3
+ module Katar
4
+
5
+ end
data/lib/katar/cli.rb CHANGED
@@ -1,3 +1,3 @@
1
- require "katar/commands/application"
2
-
1
+ require "katar/commands/application"
2
+
3
3
  Katar::Commands::Application.start(ARGV)
@@ -1,88 +1,88 @@
1
- require "katar/globals"
2
- require "katar/version"
3
- require "thor"
4
-
5
- module Katar
6
- module Commands
7
- class Application < Thor
8
-
9
- desc "version", "Show Katar version number"
10
- def version
11
- puts Katar::VERSION
12
- end
13
-
14
- desc "init", "Create a stub Katar.yaml file"
15
- def init
16
- require_command!("init_command")
17
- end
18
-
19
- desc "edit", "Edit the Katar.yaml file"
20
- def edit
21
- require_command!("edit_command")
22
- end
23
-
24
- desc "up", "Start the Katar machine"
25
- def up
26
- run_command "vagrant up"
27
- end
28
-
29
- desc "ssh", "Login to the Katar machine via SSH"
30
- def ssh
31
- run_command "vagrant ssh"
32
- end
33
-
34
- desc "suspend", "Suspend the Katar machine"
35
- def suspend
36
- run_command "vagrant suspend"
37
- end
38
-
39
- desc "resume", "Resume the suspended Katar machine"
40
- def resume
41
- run_command "vagrant resume"
42
- end
43
-
44
- desc "reload", "Reload the Katar machine image"
45
- def reload
46
- run_command "vagrant reload"
47
- end
48
-
49
- desc "destroy", "Destroy the Katar machine"
50
- def destroy
51
- run_command "vagrant destroy"
52
- end
53
-
54
- desc "status", "Get the status of the Katar machine"
55
- def status
56
- run_command "vagrant status"
57
- end
58
-
59
- desc "halt", "Halt the Katar machine"
60
- def halt
61
- run_command "vagrant halt"
62
- end
63
-
64
- desc "provision", "Re-provisions the Katar machine"
65
- def provision
66
- run_command "vagrant provision"
67
- end
68
-
69
- desc "update", "Update the Katar machine image"
70
- def update
71
- run_command "vagrant box update"
72
- end
73
-
74
- private
75
-
76
- def run_command(command)
77
- Dir.chdir( File.join(File.dirname(__FILE__), '../../../') ){
78
- exec command
79
- }
80
- end
81
-
82
- def require_command!(command)
83
- require "katar/commands/#{command}"
84
- end
85
-
86
- end
87
- end
1
+ require "katar/globals"
2
+ require "katar/version"
3
+ require "thor"
4
+
5
+ module Katar
6
+ module Commands
7
+ class Application < Thor
8
+
9
+ desc "version", "Show Katar version number"
10
+ def version
11
+ puts Katar::VERSION
12
+ end
13
+
14
+ desc "init", "Create a stub Katar.yaml file"
15
+ def init
16
+ require_command!("init_command")
17
+ end
18
+
19
+ desc "edit", "Edit the Katar.yaml file"
20
+ def edit
21
+ require_command!("edit_command")
22
+ end
23
+
24
+ desc "up", "Start the Katar machine"
25
+ def up
26
+ run_command "vagrant up"
27
+ end
28
+
29
+ desc "ssh", "Login to the Katar machine via SSH"
30
+ def ssh
31
+ run_command "vagrant ssh"
32
+ end
33
+
34
+ desc "suspend", "Suspend the Katar machine"
35
+ def suspend
36
+ run_command "vagrant suspend"
37
+ end
38
+
39
+ desc "resume", "Resume the suspended Katar machine"
40
+ def resume
41
+ run_command "vagrant resume"
42
+ end
43
+
44
+ desc "reload", "Reload the Katar machine image"
45
+ def reload
46
+ run_command "vagrant reload"
47
+ end
48
+
49
+ desc "destroy", "Destroy the Katar machine"
50
+ def destroy
51
+ run_command "vagrant destroy"
52
+ end
53
+
54
+ desc "status", "Get the status of the Katar machine"
55
+ def status
56
+ run_command "vagrant status"
57
+ end
58
+
59
+ desc "halt", "Halt the Katar machine"
60
+ def halt
61
+ run_command "vagrant halt"
62
+ end
63
+
64
+ desc "provision", "Re-provisions the Katar machine"
65
+ def provision
66
+ run_command "vagrant provision"
67
+ end
68
+
69
+ desc "update", "Update the Katar machine image"
70
+ def update
71
+ run_command "vagrant box update"
72
+ end
73
+
74
+ private
75
+
76
+ def run_command(command)
77
+ Dir.chdir( File.join(File.dirname(__FILE__), '../../../') ){
78
+ exec command
79
+ }
80
+ end
81
+
82
+ def require_command!(command)
83
+ require "katar/commands/#{command}"
84
+ end
85
+
86
+ end
87
+ end
88
88
  end
@@ -1,28 +1,28 @@
1
- require "thor"
2
-
3
- module Katar
4
- module Commands
5
- class EditCommand < Thor
6
-
7
- desc "edit", "Edit the Katar.yaml file"
8
- def edit
9
-
10
- if windows?
11
- exec "start #{Katar::DIR}/Katar.yaml"
12
- end
13
-
14
- exec "open #{Katar::DIR}/Katar.yaml"
15
-
16
- end
17
-
18
- private
19
-
20
- def windows?
21
- (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
22
- end
23
-
24
- end
25
- end
26
- end
27
-
1
+ require "thor"
2
+
3
+ module Katar
4
+ module Commands
5
+ class EditCommand < Thor
6
+
7
+ desc "edit", "Edit the Katar.yaml file"
8
+ def edit
9
+
10
+ if windows?
11
+ exec "start #{Katar::DIR}/Katar.yaml"
12
+ end
13
+
14
+ exec "open #{Katar::DIR}/Katar.yaml"
15
+
16
+ end
17
+
18
+ private
19
+
20
+ def windows?
21
+ (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+
28
28
  Katar::Commands::EditCommand.start(ARGV)
@@ -1,28 +1,28 @@
1
- require 'fileutils'
2
- require "thor"
3
-
4
- module Katar
5
- module Commands
6
- class InitCommand < Thor
7
-
8
- desc "init", "Create a stub Katar.yaml file"
9
- def init
10
- create_directory and copy_stubs
11
- puts "Katar initialized!"
12
- end
13
-
14
- private
15
-
16
- def create_directory
17
- Dir.mkdir Katar::DIR if ! Dir.exists? Katar::DIR
18
- end
19
-
20
- def copy_stubs
21
- FileUtils.cp_r File.expand_path('../../../stubs', __FILE__) + "/.", Katar::DIR
22
- end
23
-
24
- end
25
- end
26
- end
27
-
1
+ require 'fileutils'
2
+ require "thor"
3
+
4
+ module Katar
5
+ module Commands
6
+ class InitCommand < Thor
7
+
8
+ desc "init", "Create a stub Katar.yaml file"
9
+ def init
10
+ create_directory and copy_stubs
11
+ puts "Katar initialized!"
12
+ end
13
+
14
+ private
15
+
16
+ def create_directory
17
+ Dir.mkdir Katar::DIR if ! Dir.exists? Katar::DIR
18
+ end
19
+
20
+ def copy_stubs
21
+ FileUtils.cp_r File.expand_path('../../../stubs', __FILE__) + "/.", Katar::DIR
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+
28
28
  Katar::Commands::InitCommand.start(ARGV)
data/lib/katar/globals.rb CHANGED
@@ -1,3 +1,3 @@
1
- module Katar
2
- DIR = File.expand_path("~/.katar")
1
+ module Katar
2
+ DIR = File.expand_path("~/.katar")
3
3
  end
data/lib/katar/vagrant.rb CHANGED
@@ -1,145 +1,150 @@
1
- module Katar
2
- def Katar.configure(config, settings)
3
- # Set The VM Provider
4
- ENV['VAGRANT_DEFAULT_PROVIDER'] = settings["provider"] = "virtualbox"
5
-
6
- # Configure Local Variable To Access Scripts From Remote Location
7
- scriptDir = File.expand_path('../../scripts', __FILE__)
8
-
9
- # Prevent TTY Errors
10
- config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
11
-
12
- # Allow SSH Agent Forward from The Box
13
- config.ssh.forward_agent = true
14
-
15
- # Configure The Box
16
- config.vm.box = settings["box"] ||= "acmitch/katar-box"
17
- config.vm.box_version = settings["version"] ||= ">= 0"
18
- config.vm.hostname = settings["hostname"] ||= "katar"
19
-
20
- # Configure A Private Network IP
21
- config.vm.network :private_network, ip: settings["ip"] ||= "192.168.10.11"
22
-
23
- # Configure A Few VirtualBox Settings
24
- config.vm.provider "virtualbox" do |vb|
25
- vb.name = settings["name"] ||= "katar"
26
- vb.gui = settings["desktop"] ||= false
27
- vb.customize ["modifyvm", :id, "--memory", settings["memory"] ||= "2048"]
28
- vb.customize ["modifyvm", :id, "--cpus", settings["cpus"] ||= "1"]
29
- vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
30
- vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
31
- vb.customize ["modifyvm", :id, "--ostype", "Ubuntu_64"]
32
- vb.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
33
- end
34
-
35
- # Configure A Few Parallels Settings
36
- config.vm.provider "parallels" do |v|
37
- v.update_guest_tools = true
38
- v.memory = settings["memory"] ||= 2048
39
- v.cpus = settings["cpus"] ||= 1
40
- end
41
-
42
- # Configure Proxies
43
- if settings.include? "proxies"
44
- if !Vagrant.has_plugin?("vagrant-proxyconf")
45
- system('vagrant plugin install vagrant-proxyconf')
46
- raise("vagrant-proxyconf installed. Run command again.");
47
- end
48
-
49
- settings["proxies"].each do |proxy|
50
- # Environment and package managers
51
- config.proxy.http = proxy["http"] ||= nil
52
- config.proxy.https = proxy["https"] ||= nil
53
- end
54
- end
55
-
56
- # Standardize Ports Naming Schema
57
- if (settings.has_key?("ports"))
58
- settings["ports"].each do |port|
59
- port["guest"] ||= port["to"]
60
- port["host"] ||= port["send"]
61
- port["protocol"] ||= "tcp"
62
- end
63
- else
64
- settings["ports"] = []
65
- end
66
-
67
- # Default Port Forwarding
68
- default_ports = {
69
- 80 => 8000,
70
- 443 => 44300,
71
- 3306 => 33060,
72
- 5432 => 54320
73
- }
74
-
75
- # Use Default Port Forwarding Unless Overridden
76
- default_ports.each do |guest, host|
77
- unless settings["ports"].any? { |mapping| mapping["guest"] == guest }
78
- config.vm.network "forwarded_port", guest: guest, host: host, auto_correct: true
79
- end
80
- end
81
-
82
- # Add Custom Ports From Configuration
83
- if settings.has_key?("ports")
84
- settings["ports"].each do |port|
85
- config.vm.network "forwarded_port", guest: port["guest"], host: port["host"], protocol: port["protocol"], auto_correct: true
86
- end
87
- end
88
-
89
- # Configure The Public Key For SSH Access
90
- if settings.include? 'authorize'
91
- if File.exists? File.expand_path(settings["authorize"])
92
- config.vm.provision "shell" do |s|
93
- s.inline = "echo $1 | grep -xq \"$1\" /home/vagrant/.ssh/authorized_keys || echo $1 | tee -a /home/vagrant/.ssh/authorized_keys"
94
- s.args = [File.read(File.expand_path(settings["authorize"]))]
95
- end
96
- end
97
- end
98
-
99
- # Copy The SSH Private Keys To The Box
100
- if settings.include? 'keys'
101
- settings["keys"].each do |key|
102
- config.vm.provision "shell" do |s|
103
- s.privileged = false
104
- s.inline = "echo \"$1\" > /home/vagrant/.ssh/$2 && chmod 600 /home/vagrant/.ssh/$2"
105
- s.args = [File.read(File.expand_path(key)), key.split('/').last]
106
- end
107
- end
108
- end
109
-
110
- # Register All Of The Configured Shared Folders
111
- if settings.include? 'folders'
112
- settings["folders"].each do |folder|
113
-
114
- if (folder["type"] == "nfs")
115
- mount_opts = folder["mount_options"] ? folder["mount_options"] : ['actimeo=1']
116
- else
117
- mount_opts = folder["mount_options"] ? folder["mount_options"] : []
118
- end
119
-
120
- # For b/w compatibility keep separate 'mount_opts', but merge with options
121
- options = (folder["options"] || {}).merge({ mount_options: mount_opts })
122
-
123
- # Double-splat (**) operator only works with symbol keys, so convert
124
- options.keys.each{|k| options[k.to_sym] = options.delete(k) }
125
-
126
- config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= nil, **options
127
- end
128
- end
129
-
130
- # Configure All Of The Server Environment Variables
131
- config.vm.provision "shell" do |s|
132
- s.path = scriptDir + "/clear-variables.sh"
133
- end
134
-
135
- if settings.has_key?("variables")
136
- settings["variables"].each do |var|
137
- config.vm.provision "shell" do |s|
138
- s.inline = "echo \"\n# Set Katar Environment Variable\nexport $1=$2\" >> /home/vagrant/.profile"
139
- s.args = [var["key"], var["value"]]
140
- end
141
- end
142
- end
143
-
144
- end
1
+ module Katar
2
+ def Katar.configure(config, settings)
3
+ # Set The VM Provider
4
+ ENV['VAGRANT_DEFAULT_PROVIDER'] = settings["provider"] = "virtualbox"
5
+
6
+ # Configure Local Variable To Access Scripts From Remote Location
7
+ scriptDir = File.expand_path('../../scripts', __FILE__)
8
+
9
+ # Prevent TTY Errors
10
+ config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
11
+
12
+ # Allow SSH Agent Forward from The Box
13
+ config.ssh.forward_agent = true
14
+
15
+ # Configure The Box
16
+ config.vm.box = settings["box"] ||= "acmitch/katar-box"
17
+ config.vm.box_version = settings["version"] ||= ">= 0"
18
+ config.vm.hostname = settings["hostname"] ||= "katar"
19
+
20
+ # Configure A Private Network IP
21
+ config.vm.network :private_network, ip: settings["ip"] ||= "192.168.10.11"
22
+
23
+ # Configure A Few VirtualBox Settings
24
+ config.vm.provider "virtualbox" do |vb|
25
+ vb.name = settings["name"] ||= "katar"
26
+ vb.gui = settings["desktop"] ||= false
27
+ vb.customize ["modifyvm", :id, "--memory", settings["memory"] ||= "2048"]
28
+ vb.customize ["modifyvm", :id, "--cpus", settings["cpus"] ||= "1"]
29
+ vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
30
+ vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
31
+ vb.customize ["modifyvm", :id, "--ostype", "Ubuntu_64"]
32
+ vb.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
33
+ end
34
+
35
+ # Configure A Few Parallels Settings
36
+ config.vm.provider "parallels" do |v|
37
+ v.update_guest_tools = true
38
+ v.memory = settings["memory"] ||= 2048
39
+ v.cpus = settings["cpus"] ||= 1
40
+ end
41
+
42
+ # Configure Proxies
43
+ if settings.include? "proxies"
44
+ if !Vagrant.has_plugin?("vagrant-proxyconf")
45
+ system('vagrant plugin install vagrant-proxyconf')
46
+ raise("vagrant-proxyconf installed. Run command again.");
47
+ end
48
+
49
+ settings["proxies"].each do |proxy|
50
+ # Environment and package managers
51
+ config.proxy.http = proxy["http"] ||= nil
52
+ config.proxy.https = proxy["https"] ||= nil
53
+ end
54
+ end
55
+
56
+ # Standardize Ports Naming Schema
57
+ if (settings.has_key?("ports"))
58
+ settings["ports"].each do |port|
59
+ port["guest"] ||= port["to"]
60
+ port["host"] ||= port["send"]
61
+ port["protocol"] ||= "tcp"
62
+ end
63
+ else
64
+ settings["ports"] = []
65
+ end
66
+
67
+ # Default Port Forwarding
68
+ default_ports = {
69
+ 80 => 8000,
70
+ 443 => 44300,
71
+ 3306 => 33060,
72
+ 5432 => 54320
73
+ }
74
+
75
+ # Use Default Port Forwarding Unless Overridden
76
+ default_ports.each do |guest, host|
77
+ unless settings["ports"].any? { |mapping| mapping["guest"] == guest }
78
+ config.vm.network "forwarded_port", guest: guest, host: host, auto_correct: true
79
+ end
80
+ end
81
+
82
+ # Add Custom Ports From Configuration
83
+ if settings.has_key?("ports")
84
+ settings["ports"].each do |port|
85
+ config.vm.network "forwarded_port", guest: port["guest"], host: port["host"], protocol: port["protocol"], auto_correct: true
86
+ end
87
+ end
88
+
89
+ # Configure The Public Key For SSH Access
90
+ if settings.include? 'authorize'
91
+ if File.exists? File.expand_path(settings["authorize"])
92
+ config.vm.provision "shell" do |s|
93
+ s.inline = "echo $1 | grep -xq \"$1\" /home/vagrant/.ssh/authorized_keys || echo $1 | tee -a /home/vagrant/.ssh/authorized_keys"
94
+ s.args = [File.read(File.expand_path(settings["authorize"]))]
95
+ end
96
+ end
97
+ end
98
+
99
+ # Copy The SSH Private Keys To The Box
100
+ if settings.include? 'keys'
101
+ settings["keys"].each do |key|
102
+ config.vm.provision "shell" do |s|
103
+ s.privileged = false
104
+ s.inline = "echo \"$1\" > /home/vagrant/.ssh/$2 && chmod 600 /home/vagrant/.ssh/$2"
105
+ s.args = [File.read(File.expand_path(key)), key.split('/').last]
106
+ end
107
+ end
108
+ end
109
+
110
+ if settings.include? 'folders'
111
+ settings["folders"].each do |folder|
112
+ mount_opts = []
113
+
114
+ if (folder["type"] == "nfs")
115
+ mount_opts = folder["mount_options"] ? folder["mount_options"] : ['actimeo=1', 'nolock']
116
+ elsif (folder["type"] == "smb")
117
+ mount_opts = folder["mount_options"] ? folder["mount_options"] : ['vers=3.02', 'mfsymlinks']
118
+ end
119
+
120
+ # For b/w compatibility keep separate 'mount_opts', but merge with options
121
+ options = (folder["options"] || {}).merge({ mount_options: mount_opts })
122
+
123
+ # Double-splat (**) operator only works with symbol keys, so convert
124
+ options.keys.each{|k| options[k.to_sym] = options.delete(k) }
125
+
126
+ config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= nil, **options
127
+
128
+ # Bindfs support to fix shared folder (NFS) permission issue on Mac
129
+ if Vagrant.has_plugin?("vagrant-bindfs")
130
+ config.bindfs.bind_folder folder["to"], folder["to"]
131
+ end
132
+ end
133
+ end
134
+
135
+ # Configure All Of The Server Environment Variables
136
+ config.vm.provision "shell" do |s|
137
+ s.path = scriptDir + "/clear-variables.sh"
138
+ end
139
+
140
+ if settings.has_key?("variables")
141
+ settings["variables"].each do |var|
142
+ config.vm.provision "shell" do |s|
143
+ s.inline = "echo \"\n# Set Katar Environment Variable\nexport $1=$2\" >> /home/vagrant/.profile"
144
+ s.args = [var["key"], var["value"]]
145
+ end
146
+ end
147
+ end
148
+
149
+ end
145
150
  end