vagrant-blockwart 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9ef473ba47c6960391a1a10452d2643d1b63ca17
4
+ data.tar.gz: 30e73c2aeb8a678bde5e51d3f2a35d594ba68e9a
5
+ SHA512:
6
+ metadata.gz: 6704945ac32a72a34e221ea084ed2eeb20b6e7f82bac8cfabc78458bd5f8d1ebc58784e2d171a5bb345bd10503c8430f0b83e174b1aa0751afd8289845173f07
7
+ data.tar.gz: 434d7f693e2f2bd03f1ab393982b3fe0892519aef088dc35f0a3e6fae00174ad27180af084697e22e6febfd287d5267ba3fffa3e0872587248979ab8bac9a3a7
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vagrant-blockwart.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Benjamin Kendinibilir
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Vagrant Blockwart Provisioner
2
+
3
+ This is a [Vagrant](http://www.vagrantup.com) plugin that adds an [Blockwart](http://blockwart.org) provisioner to Vagrant, supporting to provision your virtual machines with a local Blockwart repository.
4
+
5
+ ## Installation
6
+
7
+ First [install Blockwart](http://docs.blockwart.org/en/latest/installation.html):
8
+
9
+ pip install blockwart
10
+
11
+ Then just type it on your vagrant environment:
12
+
13
+ vagrant plugin install vagrant-blockwart
14
+
15
+ ## Usage
16
+
17
+ https://github.com/bkendinibilir/vagrant-blockwart-example
18
+
19
+ ## Contributing
20
+
21
+ 1. Fork it
22
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
23
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
24
+ 4. Push to the branch (`git push origin my-new-feature`)
25
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ require "vagrant-blockwart/plugin"
@@ -0,0 +1,39 @@
1
+ module VagrantPlugins
2
+ module Blockwart
3
+ class BwManage
4
+
5
+ def initialize(repo_path)
6
+ @repo_path = repo_path
7
+ end
8
+
9
+ def bw_cli(params, ret_stdout=true)
10
+ params = params.gsub(/[^a-zA-Z0-9\-\_\.\s]/,'')
11
+ old_path = Dir.pwd
12
+ Dir.chdir(@repo_path)
13
+ if ret_stdout
14
+ result = `bw #{params}`
15
+ else
16
+ result = system("bw #{params}")
17
+ end
18
+ Dir.chdir(old_path)
19
+ return result
20
+ end
21
+
22
+ def nodes()
23
+ nodes = bw_cli("nodes")
24
+ return nodes.split("\n")
25
+ end
26
+
27
+ def node_hosts()
28
+ nodes = bw_cli("nodes --hostname")
29
+ return nodes.split("\n")
30
+ end
31
+
32
+ def apply(node)
33
+ node = node.gsub(/[^a-zA-Z0-9\-\_\.]/,'')
34
+ return bw_cli("apply #{node}", ret_stdout=false)
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,42 @@
1
+ module VagrantPlugins
2
+ module Blockwart
3
+ class Config < Vagrant.plugin("2", :config)
4
+ attr_accessor :repo_path
5
+ attr_accessor :node_name
6
+ attr_accessor :node_host
7
+
8
+ def initialize
9
+ @repo_path = UNSET_VALUE
10
+ @node_name = UNSET_VALUE
11
+ @node_host = UNSET_VALUE
12
+ end
13
+
14
+ def finalize!
15
+ @repo_path = "blockwart/" if @repo_path == UNSET_VALUE
16
+ @node_name = nil if @node_name == UNSET_VALUE
17
+ @node_host = nil if @node_host == UNSET_VALUE
18
+ end
19
+
20
+ def validate(machine)
21
+ errors = _detected_errors
22
+
23
+ unless File.directory?(repo_path) and File.exist?("#{repo_path}/nodes.py") and File.exist?("#{repo_path}/groups.py")
24
+ errors << "Blockwart repository is missing in repo_path='#{repo_path}'.\n" +
25
+ " Create a new one with 'bw repo create'."
26
+ end
27
+
28
+ unless @node_name
29
+ errors << "Blockwart config 'node_name' is not set. Use the node name from your blockwart nodes.py."
30
+ end
31
+
32
+ unless @node_host
33
+ errors << "Blockwart config 'node_host' is not set. Use the node host from your blockwart nodes.py.\n" +
34
+ " This does not have to be a valid host name (e.g. 'node1.vm'), but it should be a unique one,\n" +
35
+ " because it will be written in your ssh config file."
36
+ end
37
+
38
+ { "vagrant-blockwart" => errors }
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,19 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module Blockwart
5
+ class Plugin < Vagrant.plugin("2")
6
+ name "vagrant-blockwart"
7
+
8
+ config(:blockwart, :provisioner) do
9
+ require_relative "config"
10
+ Config
11
+ end
12
+
13
+ provisioner(:blockwart) do
14
+ require_relative "provisioner"
15
+ Provisioner
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,32 @@
1
+ require "fileutils"
2
+ require_relative "bwmanage"
3
+ require_relative "sshconf"
4
+
5
+ module VagrantPlugins
6
+ module Blockwart
7
+ class Provisioner < Vagrant.plugin("2", :provisioner)
8
+
9
+ def initialize(machine, config)
10
+ super(machine, config)
11
+ @logger = Log4r::Logger.new("vagrant::provisioners::blockwart")
12
+ end
13
+
14
+ def configure(root_config)
15
+ end
16
+
17
+ def provision
18
+ ssh = SshConf.new
19
+ ssh.update(config.node_host, @machine.ssh_info)
20
+ bw = BwManage.new(config.repo_path)
21
+ bw.apply(config.node_name)
22
+ end
23
+
24
+ def cleanup
25
+ bw = BwManage.new(config.repo_path)
26
+ ssh = SshConf.new
27
+ ssh.remove_hosts(bw.node_hosts)
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,63 @@
1
+ require "ssh-config"
2
+
3
+ module VagrantPlugins
4
+ module Blockwart
5
+ class SshConf
6
+
7
+ def initialize()
8
+ touch()
9
+ @ssh_config = ConfigFile.new
10
+ end
11
+
12
+ def touch()
13
+ unless File.directory?(ENV['HOME'] + "/.ssh")
14
+ FileUtils.mkdir_p(ENV['HOME'] + "/.ssh")
15
+ end
16
+ FileUtils.touch(ENV['HOME'] + "/.ssh/config")
17
+ end
18
+
19
+ def update(host, ssh_info)
20
+ @ssh_config.set(host, 'HostName', ssh_info[:host])
21
+ @ssh_config.set(host, 'Port', ssh_info[:port])
22
+ @ssh_config.set(host, 'User', ssh_info[:username])
23
+
24
+ ssh_keys = ssh_info[:private_key_path]
25
+ ssh_keys.each do |ssh_key|
26
+ @ssh_config.set(host, 'IdentityFile', ssh_key)
27
+ end
28
+
29
+ if ssh_info[:forward_agent]
30
+ @ssh_config.set(host, 'ForwardAgent', 'yes')
31
+ end
32
+
33
+ if ssh_info[:forward_x11]
34
+ @ssh_config.set(host, 'ForwardX11', 'yes')
35
+ end
36
+
37
+ if ssh_info[:proxy_command]
38
+ @ssh_config.set(host, 'ProxyCommand', ssh_info[:proxy_command])
39
+ end
40
+
41
+ @ssh_config.set(host, 'UserKnownHostsFile', '/dev/null')
42
+ @ssh_config.set(host, 'StrictHostKeyChecking', 'no')
43
+ @ssh_config.set(host, 'PasswordAuthentication', 'no')
44
+ @ssh_config.set(host, 'IdentitiesOnly', 'yes')
45
+ @ssh_config.set(host, 'LogLevel', 'FATAL')
46
+
47
+ @ssh_config.save()
48
+ end
49
+
50
+ def remove_host(host)
51
+ @ssh_config.rm!(host)
52
+ end
53
+
54
+ def remove_hosts(hosts)
55
+ hosts.each do |host|
56
+ @ssh_config.rm(host)
57
+ end
58
+ @ssh_config.save()
59
+ end
60
+
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,5 @@
1
+ module Vagrant
2
+ module Blockwart
3
+ VERSION = "0.1.2"
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-blockwart/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-blockwart"
8
+ spec.version = Vagrant::Blockwart::VERSION
9
+ spec.authors = "Benjamin Kendinibilir"
10
+ spec.email = "bkendinibilir@seibert-media.net"
11
+ spec.summary = "Vagrant Blockwart provisioner."
12
+ spec.description = "Enables Vagrant to provision machines with Blockwart."
13
+ spec.homepage = "https://github.com/bkendinibilir/vagrant-blockwart"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_runtime_dependency "ssh-config", "~> 0.1.3"
24
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-blockwart
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Benjamin Kendinibilir
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: ssh-config
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.3
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.3
55
+ description: Enables Vagrant to provision machines with Blockwart.
56
+ email: bkendinibilir@seibert-media.net
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - .gitignore
62
+ - Gemfile
63
+ - LICENSE.txt
64
+ - README.md
65
+ - Rakefile
66
+ - lib/vagrant-blockwart.rb
67
+ - lib/vagrant-blockwart/bwmanage.rb
68
+ - lib/vagrant-blockwart/config.rb
69
+ - lib/vagrant-blockwart/plugin.rb
70
+ - lib/vagrant-blockwart/provisioner.rb
71
+ - lib/vagrant-blockwart/sshconf.rb
72
+ - lib/vagrant-blockwart/version.rb
73
+ - vagrant-blockwart.gemspec
74
+ homepage: https://github.com/bkendinibilir/vagrant-blockwart
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.0.3
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Vagrant Blockwart provisioner.
98
+ test_files: []