puppet_plugin 0.0.1

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: 0aebde2b37c13d58457a496c3d3474591eab48a3
4
+ data.tar.gz: 20e5465bc2f803abd993d35ca3189db3f6f8481a
5
+ SHA512:
6
+ metadata.gz: c8c8a68bc017cdb343d92a1dcce8f31f9f05e7daa8d3b454fd781d8d0ddec27a1e79778b130daccb65f09dc93f5c73eeb723d360cbf42e8eea926cebdab1c2df
7
+ data.tar.gz: b11753b5e5413dafcfedd10845ea840519be20d9d4dbc0010174b6676ccfd8c73730bf462fe417f5aee13865c3a811a58f706bf8788eda4410018c03acfe1255
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,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :development do
4
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
5
+ gem "byebug"
6
+ gem "pry"
7
+ end
8
+
9
+ group :plugins do
10
+ gem "puppet_plugin", path: "."
11
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Bert Hajee
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,22 @@
1
+ # Puppet Plugin
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ vagrant plugin install puppet_plugin
10
+
11
+
12
+ ## Usage
13
+
14
+ TODO: Write usage instructions here
15
+
16
+ ## Contributing
17
+
18
+ 1. Fork it ( http://github.com/<my-github-username>/puppet_plugin/fork )
19
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
20
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
21
+ 4. Push to the branch (`git push origin my-new-feature`)
22
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ Bundler::GemHelper.install_tasks
data/Vagrantfile ADDED
@@ -0,0 +1,32 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5
+ VAGRANTFILE_API_VERSION = "2"
6
+
7
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8
+ config.vm.box = "centos-5.8-x86_64"
9
+ # config.vm.box_url = "https://dl.dropboxusercontent.com/s/sij0m2qmn02a298/centos-5.8-x86_64.box"
10
+
11
+
12
+ config.vm.synced_folder ".", "/vagrant", :mount_options => ["dmode=777","fmode=777"]
13
+
14
+
15
+ config.vm.provider :virtualbox do |vb|
16
+ vb.customize ["modifyvm", :id, "--memory", "3048"]
17
+ vb.customize ["modifyvm", :id, "--name", "db"]
18
+ vb.customize ["modifyvm", :id, "--cpus", "2"]
19
+ vb.customize ["modifyvm", :id, "--ioapic", "on"]
20
+ end
21
+
22
+ config.vm.provision :puppet do |puppet|
23
+ puppet.module_path = "puppet/modules"
24
+ puppet.manifests_path = "puppet/manifests"
25
+ puppet.manifest_file = "site.pp"
26
+ # puppet.options = "--verbose --parser future"
27
+ puppet.facter = {
28
+ 'environment' => 'obeheer1',
29
+ 'vm_type' => 'vagrant'
30
+ }
31
+ end
32
+ end
@@ -0,0 +1,101 @@
1
+ module Puppet
2
+ module CommandIdentify
3
+ class Command < Vagrant.plugin("2", "command")
4
+ def execute
5
+ @options = {}
6
+ @options[:verbose] = false
7
+ @options[:debug] = false
8
+ @options[:trace] = false
9
+ @options[:provider] = 'virtualbox'
10
+ @options[:environment] = 'obeheer1'
11
+ @options[:transport] = 'vagrant'
12
+
13
+ opts = OptionParser.new do |o|
14
+ o.banner = "Usage: vagrant identify [options] [name]"
15
+ o.separator ""
16
+ o.separator "Options:"
17
+ o.separator ""
18
+
19
+ o.on("--[no-]debug",
20
+ "Run puppet with --debug (default to false)") do |debug|
21
+ @options[:debug] = debug
22
+ end
23
+
24
+ o.on("--[no-]verbose",
25
+ "Run puppet with --verbose (default to true)") do |verbose|
26
+ @options[:verbose] = verbose
27
+ end
28
+
29
+
30
+ o.on("--[no-]trace",
31
+ "Run puppet with --trace (default to true)") do |trace|
32
+ @options[:trace] = trace
33
+ end
34
+
35
+ o.on("--environment ENV", String,
36
+ "Specify the environment. Default is: obeheer1") do |environment|
37
+ @options[:environment] = environment
38
+ end
39
+
40
+
41
+ o.on("--transport TRANSPORT", String,
42
+ "Specify the transport. Default is: vagrant") do |transport|
43
+ @options[:transport] = transport
44
+ end
45
+
46
+
47
+ o.on("--provider PROVIDER", String,
48
+ "Back the machine with a specific provider") do |provider|
49
+ @options[:provider] = provider
50
+ end
51
+
52
+ end
53
+ # Parse the options
54
+ argv = parse_options(opts)
55
+ if argv.size < 2
56
+ @env.ui.info(I18n.t("vagrant.puppet_plugin.commands.identify.need_ip_and_name"))
57
+ return 1
58
+ end
59
+
60
+ @hostname = argv[0]
61
+ @ipaddress = argv[1]
62
+
63
+ @env.ui.info(I18n.t(
64
+ "vagrant.puppet_plugin.commands.identify.starting",
65
+ hostname: @hostname,
66
+ ipaddress: @ipaddress))
67
+
68
+ with_target_vms('default', provider: @options[:provider]) do |machine|
69
+ set_name_and_ip(machine)
70
+ set_puppet_options(machine)
71
+ set_shell_command(machine)
72
+ machine.action(:up, @options)
73
+ end
74
+ end
75
+
76
+ private
77
+ def set_name_and_ip(machine)
78
+ machine.config.vm.hostname = @hostname
79
+ machine.config.vm.network(:private_network, :ip => @ipaddress)
80
+ end
81
+
82
+ def set_puppet_options(machine)
83
+ puppet = machine.config.vm.provisioners.first.config
84
+ puppet.options << '--verbose' if @options[:verbose]
85
+ puppet.options << '--debug' if @options[:debug]
86
+ puppet.facter.merge!('environment' => @options[:environment])
87
+ puppet.facter.merge!('transport' => @options[:transport])
88
+ end
89
+
90
+ def set_shell_command(machine)
91
+ host_alias = @hostname.split('.').first
92
+ machine.config.vm.provision(:shell) # Add a shell provider
93
+ shell = machine.config.vm.provisioners.last.config
94
+ shell.inline = "puppet apply -e \"host {'#{@hostname}': ip => #{@ipaddress}, host_aliases => ['${host_alias}']} host {'localhost': ip=> '127.0.0.1', host_aliases => 'localhost.localdomain,localhost4,localhost4.localdomain4' }\""
95
+ shell.path = nil
96
+ shell.args = nil
97
+ end
98
+
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,15 @@
1
+ module Puppet
2
+ module CommandIdentify
3
+ class Plugin < Vagrant.plugin("2")
4
+ name "Identify as a known puppet node"
5
+ description <<-DESC
6
+ Boot as the specified node.
7
+ DESC
8
+
9
+ command("identify") do
10
+ require_relative "command"
11
+ Command
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module PuppetPlugin
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,11 @@
1
+ begin
2
+ require "vagrant"
3
+ rescue LoadError
4
+ raise "This plugin must run within Vagrant."
5
+ end
6
+ require 'byebug'
7
+ require 'pry'
8
+ require 'puppet_plugin/version'
9
+ require 'puppet_plugin/identify/plugin'
10
+
11
+ I18n.load_path << File.expand_path('../templates/locales/en.yml', File.dirname(__FILE__))
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'puppet_plugin/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "puppet_plugin"
8
+ spec.version = PuppetPlugin::VERSION
9
+ spec.authors = ["Bert Hajee"]
10
+ spec.email = ["hajee@moretIA.com"]
11
+ spec.summary = %q{Identify yourself as a puppet host and run the according manisfest}
12
+ spec.description = %q{Identify yourself as a puppet host and run the according manisfest}
13
+ spec.homepage = ""
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
+ end
@@ -0,0 +1,10 @@
1
+ ---
2
+ en:
3
+ vagrant:
4
+ puppet_plugin:
5
+ commands:
6
+ identify:
7
+ starting: |-
8
+ Starting node '%{hostname}' on ipaddress '%{ipaddress}'.
9
+ need_ip_and_name: |-
10
+ We need a hostname and an ipaddress as parameters
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puppet_plugin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Bert Hajee
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-14 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
+ description: Identify yourself as a puppet host and run the according manisfest
42
+ email:
43
+ - hajee@moretIA.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - Vagrantfile
54
+ - lib/puppet_plugin.rb
55
+ - lib/puppet_plugin/identify/command.rb
56
+ - lib/puppet_plugin/identify/plugin.rb
57
+ - lib/puppet_plugin/version.rb
58
+ - puppet_plugin.gemspec
59
+ - templates/locales/en.yml
60
+ homepage: ''
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.2.2
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Identify yourself as a puppet host and run the according manisfest
84
+ test_files: []