puppet_plugin 0.0.2 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: afb214b0edd03b30daf46c9215265cd042459ff2
4
- data.tar.gz: 9cab620a6c59dd71a0c721a1723e48dea9c46a03
3
+ metadata.gz: 422e1a9c58d3f5ff39eb8162daddb150e796fbe7
4
+ data.tar.gz: d8e0b0a7ecc8f0f227cdd9bb6280663fbd350603
5
5
  SHA512:
6
- metadata.gz: b3fb270940ab0cc7b0b719c8851f469548cef0fc5b453aa9e6852a63b7b7723b61d01e27e9ffa5307c64403132f6f3efc83ff60b25ff86641f139103d75024b0
7
- data.tar.gz: af5292caf3853da582508ca248d09f5814ed2e2a77a203535a344db6671e2439fa7cf3d62ab14d6413b587f4da84ff7435dfc4ccefe10e68df3d91cd32637178
6
+ metadata.gz: 085acf996668eb47a80608a56bc82bbc5ad4a2b36efbf1b4b54063325d48ce7cbafcc3fdcfd017e33b82f11b86fc2c4771fbf613503ef0d1f631512185fd3bcb
7
+ data.tar.gz: cfa78054f89d7e973278c80a534b4ee3aa51006b333e7020311e0e46f2319b47330cc1c193ba719a76d47232cd3f2729f241e9598c91b51ff872dd264beb469d
data/.gitignore CHANGED
@@ -15,3 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .vagrant/
19
+ /puppet
data/Vagrantfile CHANGED
@@ -14,16 +14,18 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
14
14
 
15
15
  config.vm.provider :virtualbox do |vb|
16
16
  vb.customize ["modifyvm", :id, "--memory", "3048"]
17
- vb.customize ["modifyvm", :id, "--name", "db"]
17
+ # vb.customize ["modifyvm", :id, "--name", "db"]
18
18
  vb.customize ["modifyvm", :id, "--cpus", "2"]
19
19
  vb.customize ["modifyvm", :id, "--ioapic", "on"]
20
20
  end
21
21
 
22
- config.vm.provision :puppet do |puppet|
22
+ config.vm.provision :shell, :inline => '', :id => 1
23
+
24
+ config.vm.provision :puppet, :id => 2 do |puppet|
23
25
  puppet.module_path = "puppet/modules"
24
26
  puppet.manifests_path = "puppet/manifests"
25
27
  puppet.manifest_file = "site.pp"
26
- # puppet.options = "--verbose --parser future"
28
+ puppet.options = "--parser future"
27
29
  puppet.facter = {
28
30
  'environment' => 'obeheer1',
29
31
  'vm_type' => 'vagrant'
data/lib/puppet_plugin.rb CHANGED
@@ -6,6 +6,6 @@ end
6
6
  require 'byebug'
7
7
  require 'pry'
8
8
  require 'puppet_plugin/version'
9
- require 'puppet_plugin/identify/plugin'
9
+ require 'puppet_plugin/puppet/plugin'
10
10
 
11
11
  I18n.load_path << File.expand_path('../templates/locales/en.yml', File.dirname(__FILE__))
@@ -0,0 +1,129 @@
1
+ module Puppet
2
+ module CommandPuppet
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 puppet fqdn ipaddress [options]"
15
+ o.separator ""
16
+ o.separator "Options:"
17
+ o.separator ""
18
+
19
+ o.on("--[no-]puppet-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
+ o.on("--[no-]trace",
30
+ "Run puppet with --trace (default to true)") do |trace|
31
+ @options[:trace] = trace
32
+ end
33
+
34
+ o.on("--environment ENV", String,
35
+ "Specify the environment. Default is: obeheer1") do |environment|
36
+ @options[:environment] = environment
37
+ end
38
+
39
+
40
+ o.on("--transport TRANSPORT", String,
41
+ "Specify the transport. Default is: vagrant") do |transport|
42
+ @options[:transport] = transport
43
+ end
44
+
45
+
46
+ o.on("--provider PROVIDER", String,
47
+ "Back the machine with a specific provider") do |provider|
48
+ @options[:provider] = provider
49
+ end
50
+
51
+ end
52
+ # Parse the options
53
+ argv = parse_options(opts)
54
+ if argv && argv.size == 2
55
+ @fqdn = argv[0]
56
+ @ipaddress = argv[1]
57
+ @hostname = @fqdn.split('.').first
58
+ else
59
+ @env.ui.error(I18n.t("vagrant.puppet_plugin.commands.identify.need_ip_and_name"))
60
+ return 1
61
+ end
62
+
63
+ @env.ui.info(I18n.t(
64
+ "vagrant.puppet_plugin.commands.identify.starting",
65
+ hostname: @fqdn,
66
+ ipaddress: @ipaddress))
67
+ #
68
+ # Get default machine from Vagrantfile
69
+ #
70
+ machine = @env.machine(:default, @options[:provider])
71
+ #
72
+ # Set name and ipadress based on parameters
73
+ #
74
+ set_machine_name(machine)
75
+ set_name_and_ip(machine)
76
+ set_shell_command(machine)
77
+ set_puppet_options(machine)
78
+ #
79
+ # Check what state we are in and act accordingly
80
+ #
81
+ if machine.state.id == :running
82
+ machine.action(:provision, @options)
83
+ else
84
+ machine.action(:up, @options)
85
+ end
86
+ end
87
+
88
+ private
89
+ def set_machine_name(machine)
90
+ #
91
+ # This is a hack to set the machine name
92
+ #
93
+ new_name = @hostname.to_sym
94
+ machine.instance_variable_set(:@name, new_name)
95
+ machine.instance_variable_set(:@id, new_name)
96
+ ui = Vagrant::UI::Prefixed.new(@env.ui, new_name)
97
+ machine.instance_variable_set(:@ui, ui)
98
+ machine.provider_config.name = @hostname
99
+ end
100
+
101
+ def set_name_and_ip(machine)
102
+ machine.config.vm.hostname = @fqdn
103
+ machine.config.vm.network(:private_network, :ip => @ipaddress)
104
+ end
105
+
106
+ def set_puppet_options(machine)
107
+ provider = provider_with_id(2, machine)
108
+ provider.options << ' --verbose ' if @options[:verbose]
109
+ provider.options << ' --debug ' if @options[:debug]
110
+ provider.facter.merge!('environment' => @options[:environment])
111
+ provider.facter.merge!('transport' => @options[:transport])
112
+ end
113
+
114
+ def set_shell_command(machine)
115
+ provider = provider_with_id(1, machine)
116
+ command = "puppet apply -e \"host {'#{@fqdn}': ip => '#{@ipaddress}', host_aliases => ['#{@hostname}']} host {'localhost': ip=> '127.0.0.1', host_aliases => 'localhost.localdomain,localhost4,localhost4.localdomain4' }\""
117
+ provider.inline = command # Add a shell provider
118
+ shell = machine.config.vm.provisioners.last.config
119
+ shell.finalize!
120
+ end
121
+
122
+ def provider_with_id(id, machine)
123
+ id = id.to_s
124
+ machine.config.vm.provisioners.select {|p| p.id == id}.first.config
125
+ end
126
+
127
+ end
128
+ end
129
+ end
@@ -1,12 +1,12 @@
1
1
  module Puppet
2
- module CommandIdentify
2
+ module CommandPuppet
3
3
  class Plugin < Vagrant.plugin("2")
4
- name "Identify as a known puppet node"
4
+ name "Load a known puppet node and apply the it"
5
5
  description <<-DESC
6
- Boot as the specified node.
6
+ Boot as the specified node and run puppet on it.
7
7
  DESC
8
8
 
9
- command("identify") do
9
+ command("puppet") do
10
10
  require_relative "command"
11
11
  Command
12
12
  end
@@ -1,3 +1,3 @@
1
1
  module PuppetPlugin
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bert Hajee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-14 00:00:00.000000000 Z
11
+ date: 2014-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,8 +52,8 @@ files:
52
52
  - Rakefile
53
53
  - Vagrantfile
54
54
  - lib/puppet_plugin.rb
55
- - lib/puppet_plugin/identify/command.rb
56
- - lib/puppet_plugin/identify/plugin.rb
55
+ - lib/puppet_plugin/puppet/command.rb
56
+ - lib/puppet_plugin/puppet/plugin.rb
57
57
  - lib/puppet_plugin/version.rb
58
58
  - puppet_plugin.gemspec
59
59
  - templates/locales/en.yml
@@ -1,101 +0,0 @@
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.last.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