vagrant-kaigara 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/.travis.yml +0 -3
- data/README.md +11 -20
- data/lib/vagrant-kaigara/provisioner.rb +62 -16
- data/lib/vagrant-kaigara/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6e6cf2163dad0c1fc241578cc82e108f356e526
|
4
|
+
data.tar.gz: 7330c59066196159d2fb2595124184a83bc5d967
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3674c4d9433bedf80a51b193fcefa57e1cfbf9bc5c7801c700d3e94cbd590a10eb676fb1dc474975cc70962a26bcaf6831446605b214909cb0cad69d7c2f38a6
|
7
|
+
data.tar.gz: 27602bf596d43b773ff0221250973e38525081ad5d339bdc5ed80e6805ea2ddad272c341c2aaed202040cae4e9d3392743698cf7e3d27a3b7cc02e321036e677
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,38 +1,29 @@
|
|
1
1
|
# Vagrant::Kaigara
|
2
2
|
|
3
|
-
|
3
|
+
[](https://travis-ci.org/helios-technologies/vagrant-kaigara) [](https://badge.fury.io/rb/vagrant-kaigara)
|
4
4
|
|
5
|
-
|
5
|
+
This is a gem for provisioning vagrant with [kaigara](https://github.com/helios-technologies/kaigara)
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
-
|
9
|
+
You can install with plugin with vagrant cli:
|
10
10
|
|
11
|
-
|
12
|
-
gem 'vagrant-kaigara'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install vagrant-kaigara
|
11
|
+
$ vagrant plugin install vagrant-kaigara
|
22
12
|
|
23
13
|
## Usage
|
24
14
|
|
25
|
-
|
26
|
-
|
27
|
-
## Development
|
15
|
+
You should have [kaigara](https://github.com/helios-technologies/kaigara) installed on host machine.
|
28
16
|
|
29
|
-
|
17
|
+
Add this to your Vagrantfile:
|
18
|
+
```ruby
|
19
|
+
config.vm.provision :kaigara
|
20
|
+
```
|
30
21
|
|
31
|
-
|
22
|
+
Then run `vagrant provision`.
|
32
23
|
|
33
24
|
## Contributing
|
34
25
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
26
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/helios-technologies/vagrant-kaigara.
|
36
27
|
|
37
28
|
|
38
29
|
## License
|
@@ -1,26 +1,72 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module Kaigara
|
3
3
|
class Provisioner < Vagrant.plugin(2, :provisioner)
|
4
|
+
def initialize(machine, opts)
|
5
|
+
@machine = machine
|
6
|
+
end
|
7
|
+
|
4
8
|
def provision
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
if rvm_installed?
|
10
|
+
@machine.ui.info("RVM is already installed")
|
11
|
+
else
|
12
|
+
@machine.ui.info("Installing RVM...")
|
13
|
+
|
14
|
+
install_rvm = %{
|
15
|
+
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
|
16
|
+
curl -L get.rvm.io | sudo bash -s stable
|
17
|
+
rvm use --default --install ruby-2.3
|
18
|
+
gpasswd -a vagrant rvm
|
19
|
+
}
|
20
|
+
|
21
|
+
install_rvm.strip.each_line do |l|
|
22
|
+
@machine.ui.info(l.strip)
|
23
|
+
action(l)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
if kaigara_installed?
|
28
|
+
@machine.ui.info("Kaigara is already installed")
|
29
|
+
else
|
30
|
+
@machine.ui.info("Installing Kaigara...")
|
31
|
+
action("gem install kaigara")
|
17
32
|
end
|
18
33
|
|
19
|
-
|
20
|
-
|
34
|
+
@machine.ui.info("Provisioning...")
|
35
|
+
action("cd /vagrant && kaish sysops exec")
|
36
|
+
|
37
|
+
action("echo 'source /etc/profile' >> /root/.bashrc")
|
38
|
+
end
|
39
|
+
|
40
|
+
# Execute a command at vm
|
41
|
+
def action(command, opts = {})
|
42
|
+
@machine.communicate.tap do |comm|
|
43
|
+
comm.execute(command, { error_key: :ssh_bad_exit_status_muted, sudo: true }.merge(opts) ) do |type, data|
|
44
|
+
handle_comm(type, data)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Handle the comand output
|
50
|
+
def handle_comm(type, data)
|
51
|
+
if [:stderr, :stdout].include?(type)
|
52
|
+
color = type == :stdout ? :green : :red
|
53
|
+
|
54
|
+
data = data.chomp
|
55
|
+
return if data.empty?
|
56
|
+
|
57
|
+
options = {}
|
58
|
+
options[:color] = color
|
59
|
+
|
60
|
+
@machine.ui.info(data.chomp.strip, options) if data.chomp.length > 1
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def rvm_installed?
|
65
|
+
@machine.communicate.test('rvm', sudo: true)
|
66
|
+
end
|
21
67
|
|
22
|
-
|
23
|
-
@machine.communicate.
|
68
|
+
def kaigara_installed?
|
69
|
+
@machine.communicate.test('kaish', sudo: true)
|
24
70
|
end
|
25
71
|
end
|
26
72
|
end
|