From 521cee1388c5c546660b275bc885000bf4faa262 Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Wed, 30 Apr 2014 10:11:34 -0700 Subject: [PATCH] Add a basic Ruby environment for running linting and validation locally This commit also includes the CI scripts necessary to validate pull requests at a basic level before merging them into `staging` --- .gitignore | 2 + Gemfile | 17 ++++ Gemfile.lock | 112 +++++++++++++++++++++++++ README.md | 5 +- Rakefile | 11 +++ ci/00_setupgems.sh | 5 ++ ci/10_validatepuppet.sh | 3 + dist/profile/manifests/puppetmaster.pp | 3 + dist/role/manifests/puppetmaster.pp | 2 + spec/spec_helper.rb | 0 10 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 Rakefile create mode 100755 ci/00_setupgems.sh create mode 100755 ci/10_validatepuppet.sh create mode 100644 spec/spec_helper.rb diff --git a/.gitignore b/.gitignore index 1377554..62f702d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *.swp +.vagrant* +.ruby-* diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..3db0dde --- /dev/null +++ b/Gemfile @@ -0,0 +1,17 @@ +source 'https://rubygems.org' + +gem 'rake' +gem 'rspec-puppet' +gem 'puppet-lint' +gem 'puppet', '~> 3.4.0' + +group :development do + # XXX: Shouldn't be needed anywhere by rtyler's machine, since Vagrant does'nt + # have proper installers for FreeBSD :( + gem 'vagrant', :github => 'mitchellh/vagrant', :ref => 'v1.5.4' +end + +# Vagrant plugins +group :plugins do + gem 'vagrant-aws', :github => 'mitchellh/vagrant-aws' +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..543aba9 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,112 @@ +GIT + remote: git://github.com/mitchellh/vagrant-aws.git + revision: d125a2f8ca5422f55f555ab921aaac968d1e6e72 + specs: + vagrant-aws (0.5.0.dev) + fog (~> 1.18) + +GIT + remote: git://github.com/mitchellh/vagrant.git + revision: 285c7cdb2b3127d6dad4c2288cf9af6f15de6545 + ref: v1.5.4 + specs: + vagrant (1.5.4) + bundler (~> 1.5.2) + childprocess (~> 0.5.0) + erubis (~> 2.7.0) + i18n (~> 0.6.0) + listen (~> 2.7.1) + log4r (~> 1.1.9, < 1.1.11) + net-scp (~> 1.1.0) + net-ssh (>= 2.6.6, < 2.8.0) + rb-kqueue (~> 0.2.0) + wdm (~> 0.1.0) + +GEM + remote: https://rubygems.org/ + specs: + builder (3.2.2) + celluloid (0.15.2) + timers (~> 1.1.0) + celluloid-io (0.15.0) + celluloid (>= 0.15.0) + nio4r (>= 0.5.0) + childprocess (0.5.3) + ffi (~> 1.0, >= 1.0.11) + diff-lcs (1.2.5) + erubis (2.7.0) + excon (0.33.0) + facter (1.7.5) + ffi (1.9.3) + fog (1.22.0) + fog-brightbox + fog-core (~> 1.21, >= 1.21.1) + fog-json + nokogiri (~> 1.5, >= 1.5.11) + fog-brightbox (0.0.2) + fog-core + fog-json + fog-core (1.22.0) + builder + excon (~> 0.33) + formatador (~> 0.2) + mime-types + net-scp (~> 1.1) + net-ssh (>= 2.1.3) + fog-json (1.0.0) + multi_json (~> 1.0) + formatador (0.2.4) + hiera (1.3.2) + json_pure + i18n (0.6.9) + json_pure (1.8.1) + listen (2.7.3) + celluloid (>= 0.15.2) + celluloid-io (>= 0.15.0) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + log4r (1.1.10) + mime-types (2.2) + mini_portile (0.5.3) + multi_json (1.9.3) + net-scp (1.1.2) + net-ssh (>= 2.6.5) + net-ssh (2.7.0) + nio4r (1.0.0) + nokogiri (1.6.1) + mini_portile (~> 0.5.0) + puppet (3.4.3) + facter (~> 1.6) + hiera (~> 1.0) + rgen (~> 0.6.5) + puppet-lint (0.3.2) + rake (10.3.1) + rb-fsevent (0.9.4) + rb-inotify (0.9.4) + ffi (>= 0.5.0) + rb-kqueue (0.2.2) + ffi (>= 0.5.0) + rgen (0.6.6) + rspec (2.14.1) + rspec-core (~> 2.14.0) + rspec-expectations (~> 2.14.0) + rspec-mocks (~> 2.14.0) + rspec-core (2.14.8) + rspec-expectations (2.14.5) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.14.6) + rspec-puppet (1.0.1) + rspec + timers (1.1.0) + wdm (0.1.0) + +PLATFORMS + ruby + +DEPENDENCIES + puppet (~> 3.4.0) + puppet-lint + rake + rspec-puppet + vagrant! + vagrant-aws! diff --git a/README.md b/README.md index 5b63ab4..693c93b 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,13 @@ # Jenkins Infra +[![Build +Status](https://jenkins.ci.cloudbees.com/buildStatus/icon?job=infra/jenkins-infra)](https://jenkins.ci.cloudbees.com/job/infra/job/jenkins-infra/) + + This repository is the [r10k](https://github.com/adrienthebo/r10k) control repository for the [Jenkins](https://jenkins-ci.org) project's own infrastructure. - **NOTE:** This repository and workflow are still a **work in progress** ## Contributing diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..041ce1f --- /dev/null +++ b/Rakefile @@ -0,0 +1,11 @@ +require 'puppet-lint/tasks/puppet-lint' + +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.ignore_paths = ["modules/**/*.pp"] + +desc "Validate the Puppet syntax of all manifests" +task :validate do + Dir['./**/*.pp'].each do |filename| + sh "puppet parser validate '#{filename}'" + end +end diff --git a/ci/00_setupgems.sh b/ci/00_setupgems.sh new file mode 100755 index 0000000..fd2f8f0 --- /dev/null +++ b/ci/00_setupgems.sh @@ -0,0 +1,5 @@ +#!/bin/sh -xe + +gem install bundler --no-ri --no-rdoc + +bundle install --without development plugins diff --git a/ci/10_validatepuppet.sh b/ci/10_validatepuppet.sh new file mode 100755 index 0000000..62ea972 --- /dev/null +++ b/ci/10_validatepuppet.sh @@ -0,0 +1,3 @@ +#!/bin/sh -xe + +bundle exec rake validate lint diff --git a/dist/profile/manifests/puppetmaster.pp b/dist/profile/manifests/puppetmaster.pp index a7e857a..eab6aa3 100644 --- a/dist/profile/manifests/puppetmaster.pp +++ b/dist/profile/manifests/puppetmaster.pp @@ -1,3 +1,6 @@ +# +# profile::puppetmaster is a governing what a Jenkins puppetmaster should look +# like class profile::puppetmaster { # Mange hiera.yaml file { '/etc/puppetlabs/puppet/hiera.yaml': diff --git a/dist/role/manifests/puppetmaster.pp b/dist/role/manifests/puppetmaster.pp index e2d69b5..2fc5d97 100644 --- a/dist/role/manifests/puppetmaster.pp +++ b/dist/role/manifests/puppetmaster.pp @@ -1,3 +1,5 @@ +# +# role::puppetmaster defines what a node role that should look like class role::puppetmaster { include profile::puppetmaster } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..e69de29