add puppet

This commit is contained in:
Jörg Thalheim 2014-02-03 15:06:12 +01:00
parent 08e161ee65
commit 35650767e0
5 changed files with 90 additions and 30 deletions

View File

@ -1,3 +1,4 @@
Für das Basissetup wird vagrant, virtualbox und ruby (> 1.9) benötigt: Für das Basissetup wird vagrant, virtualbox und ruby (> 1.9) benötigt:
$ vagrant --version $ vagrant --version
@ -9,6 +10,9 @@ Für das Basissetup wird vagrant, virtualbox und ruby (> 1.9) benötigt:
$ ruby --version $ ruby --version
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux] ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]
Für Chef
========
Ruby-Abhängigkeiten installieren: Ruby-Abhängigkeiten installieren:
$ cd chef-lctp && bundle $ cd chef-lctp && bundle
@ -37,3 +41,11 @@ bzw.
$ vagrant ssh node1.lctp $ vagrant ssh node1.lctp
auf den VMs einloggen auf den VMs einloggen
Für Puppet
==========
Puppet Module auschecken:
$ git submodule init
$ git submodule update

66
Vagrantfile vendored
View File

@ -10,9 +10,10 @@ def load_json(name)
end end
boxes = [ boxes = [
{ name: "node0.lctp", role: :head_node, mac: "5CA1AB1E0001", json: load_json("node0.json") }, #{ name: "puppet0.lctp", provision: :puppet, mac: "5CA1AB1E0F01"},
{ name: "node1.lctp", role: :compute_node, mac: "5CA1AB1E0002", json: load_json("node1.json") }, { name: "node0.lctp", provision: :chef, role: :head_node, mac: "5CA1AB1E0001", json: load_json("node0.json") },
#{ name: "node2.lctp", role: :compute_node, mac: "5CA1AB1E0003", json: load_json("node2.json") }, { name: "node1.lctp", provision: :chef, role: :compute_node, mac: "5CA1AB1E0002", json: load_json("node1.json") }
#{ name: "node2.lctp", provision: chef, role: :compute_node, mac: "5CA1AB1E0003", json: load_json("node2.json") }
] ]
["vbguest", "berkshelf"].each do |plugin| ["vbguest", "berkshelf"].each do |plugin|
@ -27,30 +28,10 @@ boxes = [
end end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "opscode_ubuntu-12.04_chef-11.4.4"
config.vm.box_url = "https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_chef-11.4.4.box"
# Enabling the Berkshelf plugin. To enable this globally, add this configuration
# option to your ~/.vagrant.d/Vagrantfile file
config.berkshelf.enabled = true
config.vbguest.auto_update = true config.vbguest.auto_update = true
config.vbguest.auto_reboot = true config.vbguest.auto_reboot = true
chef_default = proc do |chef|
chef.cookbooks_path = "cookbooks"
chef.data_bags_path = "data_bags"
chef.roles_path = "roles"
end
# Update Chef in VM to specific version before running chef provisioner
config.vm.provision :shell do |shell|
shell.path = "script/upgrade_chef.sh"
# target version
shell.args = "11.8.2"
end
config.vm.provision(:shell){ |shell| shell.path = "script/fix_stdin_error.sh" } config.vm.provision(:shell){ |shell| shell.path = "script/fix_stdin_error.sh" }
ssh_port = 2222 ssh_port = 2222
boxes.each do |box| boxes.each do |box|
config.vm.define box[:name] do |node| config.vm.define box[:name] do |node|
@ -69,19 +50,46 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
"--macaddress2", box[:mac]] "--macaddress2", box[:mac]]
end end
config.vm.network :forwarded_port, node.vm.network :forwarded_port,
guest: 22, guest: 22,
host: ssh_port, host: ssh_port,
id: "ssh", id: "ssh",
auto_correct: true auto_correct: true
ssh_port += 1 ssh_port += 1
node.vm.hostname = box[:name] node.vm.hostname = box[:name]
node.vm.provision :chef_solo do |chef|
chef_default.call(chef) if box[:provision] == :chef
chef.add_role box[:role].to_s node.vm.box = "opscode_ubuntu-12.04_chef-11.4.4"
chef.json = box[:json] node.vm.box_url = "https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_chef-11.4.4.box"
# Enabling the Berkshelf plugin. To enable this globally, add this configuration
# option to your ~/.vagrant.d/Vagrantfile file
node.berkshelf.enabled = true
# Update Chef in VM to specific version before running chef provisioner
node.vm.provision :shell do |shell|
shell.path = "script/upgrade_chef.sh"
# target version
shell.args = "11.8.2"
end
node.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.data_bags_path = "data_bags"
chef.roles_path = "roles"
chef.add_role box[:role].to_s
chef.json = box[:json]
end
elsif box[:provision] == :puppet
node.vm.box = "ubuntu-server-12042-x64-vbox4210"
node.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210.box"
node.vm.provision :puppet, options: ["--pluginsync"] do |puppet|
puppet.module_path = "modules"
end
else
$stderr.puts "Unknown provisioning #{box[:provision]}"
end end
end end
end end
end end

30
manifests/default.pp Normal file
View File

@ -0,0 +1,30 @@
package { 'ntp':
ensure => present,
}
service { 'ntp':
ensure => running,
enable => true,
}
package { 'htop':
ensure => present,
}
package { 'ifmetric':
ensure => present,
}
class { "network::interfaces":
interfaces => {
"eth0" => {
"method" => "dhcp",
"metric" => 100,
},
"eth1" => {
"method" => "dhcp",
"metric" => 50,
}
},
auto => ["eth0", "eth1"],
}

1
modules/network Submodule

@ -0,0 +1 @@
Subproject commit ae7f0ca490d55d960193926a6d29c92a611d6e6c

View File

@ -23,6 +23,9 @@
"netmask": "255.255.255.0" "netmask": "255.255.255.0"
}, },
"hosts": { "hosts": {
"puppet0": {
"mac": "5c:a1:ab:1e:0F:01"
},
"node1": { "node1": {
"mac": "5c:a1:ab:1e:00:02" "mac": "5c:a1:ab:1e:00:02"
}, },
@ -38,13 +41,19 @@
"zones" : { "zones" : {
"lctp": { "lctp": {
"records": [ "records": [
{ "name": "puppet0", "type": "A", "value": "172.28.128.201" },
{ "name": "node0", "type": "A", "value": "172.28.128.1" }, { "name": "node0", "type": "A", "value": "172.28.128.1" },
{ "name": "node1", "type": "A", "value": "172.28.128.101" }, { "name": "node1", "type": "A", "value": "172.28.128.101" },
{ "name": "node2", "type": "A", "value": "172.28.128.102" } { "name": "node2", "type": "A", "value": "172.28.128.102" }
] ]
}, },
"128.28.172.in-addr.arpa": { "128.28.172.in-addr.arpa": {
"records": [{ "name": "101", "type": "PTR", "value": "node1" }] "records": [
{ "name": "201", "type": "PTR", "value": "puppet0" },
{ "name": "1", "type": "PTR", "value": "node0" },
{ "name": "101", "type": "PTR", "value": "node1" },
{ "name": "102", "type": "PTR", "value": "node2" }
]
} }
}, },
"trusted_subnets": ["localhost", "localnets", "172.28.128.0/24"] "trusted_subnets": ["localhost", "localnets", "172.28.128.0/24"]