From 35650767e03221a139ac21231ae09308221d1928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 3 Feb 2014 15:06:12 +0100 Subject: [PATCH] add puppet --- README.md | 12 ++++++++ Vagrantfile | 66 +++++++++++++++++++++++++------------------- manifests/default.pp | 30 ++++++++++++++++++++ modules/network | 1 + nodes/node0.json | 11 +++++++- 5 files changed, 90 insertions(+), 30 deletions(-) create mode 100644 manifests/default.pp create mode 160000 modules/network diff --git a/README.md b/README.md index 584ccc7..0866b80 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + Für das Basissetup wird vagrant, virtualbox und ruby (> 1.9) benötigt: $ vagrant --version @@ -9,6 +10,9 @@ Für das Basissetup wird vagrant, virtualbox und ruby (> 1.9) benötigt: $ ruby --version ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux] +Für Chef +======== + Ruby-Abhängigkeiten installieren: $ cd chef-lctp && bundle @@ -37,3 +41,11 @@ bzw. $ vagrant ssh node1.lctp auf den VMs einloggen + +Für Puppet +========== + +Puppet Module auschecken: + + $ git submodule init + $ git submodule update diff --git a/Vagrantfile b/Vagrantfile index 969de6c..c2586c4 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -10,9 +10,10 @@ def load_json(name) end boxes = [ - { name: "node0.lctp", role: :head_node, mac: "5CA1AB1E0001", json: load_json("node0.json") }, - { name: "node1.lctp", role: :compute_node, mac: "5CA1AB1E0002", json: load_json("node1.json") }, - #{ name: "node2.lctp", role: :compute_node, mac: "5CA1AB1E0003", json: load_json("node2.json") }, + #{ name: "puppet0.lctp", provision: :puppet, mac: "5CA1AB1E0F01"}, + { name: "node0.lctp", provision: :chef, role: :head_node, mac: "5CA1AB1E0001", json: load_json("node0.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| @@ -27,30 +28,10 @@ boxes = [ end 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_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" } - ssh_port = 2222 boxes.each do |box| config.vm.define box[:name] do |node| @@ -69,19 +50,46 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| "--macaddress2", box[:mac]] end - config.vm.network :forwarded_port, + node.vm.network :forwarded_port, guest: 22, host: ssh_port, id: "ssh", auto_correct: true ssh_port += 1 - node.vm.hostname = box[:name] - node.vm.provision :chef_solo do |chef| - chef_default.call(chef) - chef.add_role box[:role].to_s - chef.json = box[:json] + + if box[:provision] == :chef + node.vm.box = "opscode_ubuntu-12.04_chef-11.4.4" + 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 diff --git a/manifests/default.pp b/manifests/default.pp new file mode 100644 index 0000000..214bac6 --- /dev/null +++ b/manifests/default.pp @@ -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"], +} diff --git a/modules/network b/modules/network new file mode 160000 index 0000000..ae7f0ca --- /dev/null +++ b/modules/network @@ -0,0 +1 @@ +Subproject commit ae7f0ca490d55d960193926a6d29c92a611d6e6c diff --git a/nodes/node0.json b/nodes/node0.json index d933e69..65a35d4 100644 --- a/nodes/node0.json +++ b/nodes/node0.json @@ -23,6 +23,9 @@ "netmask": "255.255.255.0" }, "hosts": { + "puppet0": { + "mac": "5c:a1:ab:1e:0F:01" + }, "node1": { "mac": "5c:a1:ab:1e:00:02" }, @@ -38,13 +41,19 @@ "zones" : { "lctp": { "records": [ + { "name": "puppet0", "type": "A", "value": "172.28.128.201" }, { "name": "node0", "type": "A", "value": "172.28.128.1" }, { "name": "node1", "type": "A", "value": "172.28.128.101" }, { "name": "node2", "type": "A", "value": "172.28.128.102" } ] }, "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"]