Quellcode durchsuchen

start upppet run

Chris Mague vor 7 Jahren
Ursprung
Commit
d3fbaa4062
7 geänderte Dateien mit 87 neuen und 10 gelöschten Zeilen
  1. 0 2
      .gitignore
  2. 1 0
      .ruby-gemset
  3. 1 0
      .ruby-version
  4. 4 0
      Gemfile
  5. 70 0
      Rakefile
  6. 3 2
      Vagrantfile
  7. 8 6
      puppet/ext/hiera.yaml

+ 0 - 2
.gitignore

@@ -4,6 +4,4 @@
 puppet/modules/*
 .rvmrc
 Gemfile.lock
-.ruby-gemset
-.ruby-version
 *.log

+ 1 - 0
.ruby-gemset

@@ -0,0 +1 @@
+vagrant-puppet

+ 1 - 0
.ruby-version

@@ -0,0 +1 @@
+ruby-2.3.3

+ 4 - 0
Gemfile

@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+gem "r10k" 
+gem "rake" 

+ 70 - 0
Rakefile

@@ -0,0 +1,70 @@
+require 'yaml'
+require 'popen4'
+STDOUT.sync = true
+
+task :default => :setup
+##########################################################################
+def run_command(cmd)
+  cmdrun = IO.popen(cmd)
+  output = cmdrun.read
+  cmdrun.close
+  if $?.to_i > 0
+    puts "count not run #{cmd}, it returned an error #{output}"
+    exit 2
+  end
+  puts "OK: ran command #{cmd}"
+end
+##########################################################################
+hf = Dir.glob('puppet/ext/data/common.yaml')
+errors = []
+desc 'Check Playbook Syntax'
+task :lint_hiera do
+  hf.each do |playbook_file|
+    begin
+      YAML.load_file(playbook_file)
+    rescue Exception => e
+      errors << e.message
+    end
+  end
+  if errors.empty?
+    puts "Rake: #{hf.length} playbook files all checkout!"
+  else
+    errors.each do |err|
+      puts "ERROR: YAML parse errors"
+      puts err
+    end
+    exit 1
+  end
+end
+##########################################################################
+desc 'Check Prereqs'
+task :check_prereqs do
+  [ 'rvm', 'bundler', 'r10k' ].each do |st|
+    cmdrun = IO.popen("type -a #{st} >/dev/null 2>&1")
+    cmdrun.close
+    if $?.to_i > 0
+      puts "Could not find binary #{st}"
+      exit 2
+    end
+  end
+  puts "OK: we have everything we need"
+end
+
+desc 'Update the Puppet Modules'
+task :update_puppet do
+  puts 'Rake: updating puppet modules'
+  run_command('cd puppet && rm -rf modules/* && r10k puppetfile install')
+end
+
+task :bundle_gems do
+  run_command('bundle install')
+end
+
+task :bundler_install do
+  run_command('gem install bundler')
+end
+
+desc 'Setup'
+task :setup => [:check_prereqs, :bundler_install, :bundle_gems, :update_puppet, :lint_hiera ] do
+  puts 'Rake: Building the ami '
+end

+ 3 - 2
Vagrantfile

@@ -18,8 +18,9 @@ Vagrant.configure("2") do |config|
 
   config.vm.provision :puppet do |puppet|
     puppet.hiera_config_path = "puppet/ext/hiera.yaml"
-    puppet.manifests_path    = "puppet"
-    puppet.options           = ["--modulepath", "/tmp/vagrant-puppet/puppet/modules"]
+    puppet.manifest_file     = "puppet/site.pp"
+    puppet.manifests_path    = "puppet/"
+    puppet.module_path       = "puppet/modules"
     puppet.manifest_file     = "site.pp"
   end
 

+ 8 - 6
puppet/ext/hiera.yaml

@@ -1,7 +1,9 @@
 ---
-:backends:
-  - yaml
-:yaml:
-  :datadir: /tmp/data
-:hierarchy:
-  - common
+version: 5
+defaults:
+  datadir: /vagrant/puppet/ext/data
+  data_hash: yaml_data
+hierarchy:
+  - name: "Common YAML hierarchy levels"
+    paths:
+      - "common.yaml"