vagrant-kaigara 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f97981cac3bec99e80c62e6f3f585f7f3f14254a
4
- data.tar.gz: d3b35f0d21a0f781b6c2c9f63119414ccb8c720a
3
+ metadata.gz: f6e6cf2163dad0c1fc241578cc82e108f356e526
4
+ data.tar.gz: 7330c59066196159d2fb2595124184a83bc5d967
5
5
  SHA512:
6
- metadata.gz: f261acb844889ea6120f163e6992e4f0b41d67794b3790134b34806b80e66ae03eb128edb49191731f9cea6077fd37323f3c054b931356488074e9ad4c8ebf1c
7
- data.tar.gz: 44f5375416e8ec4ff0d9b10d6e4b17d23e6e53abd97f1ce6a47221549ea57863197180161c5b0c78c0f1d4c21e7b197695460d8806a0a8d07c610d131126f07f
6
+ metadata.gz: 3674c4d9433bedf80a51b193fcefa57e1cfbf9bc5c7801c700d3e94cbd590a10eb676fb1dc474975cc70962a26bcaf6831446605b214909cb0cad69d7c2f38a6
7
+ data.tar.gz: 27602bf596d43b773ff0221250973e38525081ad5d339bdc5ed80e6805ea2ddad272c341c2aaed202040cae4e9d3392743698cf7e3d27a3b7cc02e321036e677
data/.travis.yml CHANGED
@@ -2,6 +2,3 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.2.3
5
- before_install:
6
- - gem install bundler -v '1.12.0'
7
- - bundle _1.12.0_ install
data/README.md CHANGED
@@ -1,38 +1,29 @@
1
1
  # Vagrant::Kaigara
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/vagrant/kaigara`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [![Build Status](https://travis-ci.org/helios-technologies/vagrant-kaigara.svg?branch=master)](https://travis-ci.org/helios-technologies/vagrant-kaigara) [![Gem Version](https://badge.fury.io/rb/vagrant-kaigara.svg)](https://badge.fury.io/rb/vagrant-kaigara)
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ This is a gem for provisioning vagrant with [kaigara](https://github.com/helios-technologies/kaigara)
6
6
 
7
7
  ## Installation
8
8
 
9
- Add this line to your application's Gemfile:
9
+ You can install with plugin with vagrant cli:
10
10
 
11
- ```ruby
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
- TODO: Write usage instructions here
26
-
27
- ## Development
15
+ You should have [kaigara](https://github.com/helios-technologies/kaigara) installed on host machine.
28
16
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
17
+ Add this to your Vagrantfile:
18
+ ```ruby
19
+ config.vm.provision :kaigara
20
+ ```
30
21
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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/[USERNAME]/vagrant-kaigara.
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
- puts "Installing RVM..."
6
- script = %{
7
- apt-get install curl
8
- echo 'export rvm_prefix="$HOME"' > /root/.rvmrc
9
- echo 'export rvm_path="$HOME/.rvm"' >> /root/.rvmrc
10
- gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
11
- curl -L get.rvm.io |rvm_path=/opt/rvm bash -s stable
12
- rvm use --install --default 2.3.0
13
- }
14
-
15
- script.each_line do |l|
16
- @machine.communicate.sudo(l)
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
- puts "Installing Kaigara..."
20
- @machine.communicate.sudo("gem install kaigara")
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
- puts "Provisioning..."
23
- @machine.communicate.sudo("cd /vagrant && kaish sysops exec")
68
+ def kaigara_installed?
69
+ @machine.communicate.test('kaish', sudo: true)
24
70
  end
25
71
  end
26
72
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Kaigara
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-kaigara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Koval