Reworked to use Ruby since its needed for Puppet

This commit is contained in:
Gene Liverman 2017-05-07 09:01:12 -07:00
parent bff34cde83
commit 4f0169d4fc
21 changed files with 73 additions and 38 deletions

View file

@ -1,16 +0,0 @@
import platform
my_platform=platform.platform().lower()
if 'darwin' in my_platform:
mac_version=platform.mac_ver()[0].split('.')
if int(mac_version[0]) == 10 and int(mac_version[1]) >= 12:
print("It seems you are on macOS")
elif int(mac_version[0]) == 10 and int(mac_version[1]) < 12:
print("It seems you are on OS X")
else:
print("What tha... you're Apple is pre-OS X (" + platform.mac_ver()[0] + " to be exact)" )
elif 'linux' in my_platform:
print("It seems you are on Linux")
else:
print("Not sure what OS you are on but here's what I see: " + my_platform)

23
bin/dots.rb Executable file
View file

@ -0,0 +1,23 @@
require 'open3'
require 'os'
if OS.mac?
stdout, _stderr, _status = Open3.capture3('sw_vers -productVersion')
if Integer(stdout.strip.split('.')[0]) == 10
if Integer(stdout.strip.split('.')[1]) >= 12
puts "It seems you are on macOS #{stdout.strip}"
else
puts "It seems you are on OX X #{stdout.strip}"
end
elsif Integer(stdout.strip.split('.')[0]) < 10
puts "Wow... you're sure running an old os (#{stdout.strip} to be exact)"
else
abort("It seems you are on a Mac but I don't know what to do on v#{stdout.strip}")
end
elsif OS.liux?
puts 'It seems you are on Linux'
elsif OS.windows?
puts 'It seems you are on Windows'
else
abort("I'm not sure what to do with this OS...")
end

View file

@ -1,4 +0,0 @@
---
BUNDLE_JOBS: "3"
BUNDLE_PATH: "vendor/bundle"
BUNDLE_DISABLE_SHARED_GEMS: "true"

View file

@ -1,34 +0,0 @@
# vim:ft=ruby
source 'https://rubygems.org'
if ENV.key?('PUPPET_VERSION')
puppetversion = "#{ENV['PUPPET_VERSION']}"
else
puppetversion = ['~> 4.0']
end
group :development, :unit_tests do
gem 'json', '>= 2.0.2'
gem 'json_pure', '>= 2.0.2'
gem 'metadata-json-lint', '~> 1.0'
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '~> 1.1'
gem 'r10k', '~> 2.3'
gem 'rspec-puppet', '~> 2.5'
gem 'rugged', '~> 0.24'
gem 'yamllint', '~> 0.0.9'
# puppet-lint and plugins
gem 'puppet-lint', '~> 1.1'
gem 'puppet-lint-absolute_classname-check', '~> 0.2'
gem 'puppet-lint-absolute_template_path', '~> 1.0'
gem 'puppet-lint-empty_string-check', '~> 0.2'
gem 'puppet-lint-leading_zero-check', '~> 0.1'
gem 'puppet-lint-resource_reference_syntax', '~> 1.0'
gem 'puppet-lint-spaceship_operator_without_tag-check', '~> 0.1'
gem 'puppet-lint-trailing_newline-check', '~> 1.0'
gem 'puppet-lint-undef_in_function-check', '~> 0.2'
gem 'puppet-lint-unquoted_string-check', '~> 0.3'
gem 'puppet-lint-variable_contains_upcase', '~> 1.1'
end

View file

@ -1,135 +0,0 @@
GEM
remote: https://rubygems.org/
specs:
colored (1.2)
cri (2.6.1)
colored (~> 1.2)
diff-lcs (1.3)
facter (2.4.6)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.10.1)
faraday (>= 0.7.4, < 1.0)
fast_gettext (1.1.0)
gettext (3.2.2)
locale (>= 2.0.5)
text (>= 1.3.0)
gettext-setup (0.24)
fast_gettext (~> 1.1.0)
gettext (>= 3.0.2)
locale
hiera (3.3.1)
json (2.1.0)
json_pure (2.1.0)
locale (2.1.2)
log4r (1.1.10)
metaclass (0.0.4)
metadata-json-lint (1.1.0)
json
semantic_puppet (>= 0.1.2, < 2.0.0)
spdx-licenses (~> 1.0)
minitar (0.5.4)
mocha (1.2.1)
metaclass (~> 0.0.1)
multi_json (1.12.1)
multipart-post (2.0.0)
puppet (4.5.3)
facter (> 2.0, < 4)
hiera (>= 2.0, < 4)
json_pure
puppet-lint (1.1.0)
puppet-lint-absolute_classname-check (0.2.4)
puppet-lint (>= 1.0, < 3.0)
puppet-lint-absolute_template_path (1.0.1)
puppet-lint (>= 1.1, < 3.0)
puppet-lint-empty_string-check (0.2.2)
puppet-lint (>= 1.0, < 3.0)
puppet-lint-leading_zero-check (0.1.1)
puppet-lint (>= 1.0, < 3.0)
puppet-lint-resource_reference_syntax (1.0.10)
puppet-lint (>= 1.0, < 3.0)
puppet-lint-spaceship_operator_without_tag-check (0.1.1)
puppet-lint (>= 1.0, < 3.0)
puppet-lint-trailing_newline-check (1.1.0)
puppet-lint (>= 1.0, < 3.0)
puppet-lint-undef_in_function-check (0.2.1)
puppet-lint (>= 1.0, < 3.0)
puppet-lint-unquoted_string-check (0.3.0)
puppet-lint (>= 1.0, < 3.0)
puppet-lint-variable_contains_upcase (1.2.0)
puppet-lint (>= 1.0, < 3.0)
puppet-syntax (2.4.0)
rake
puppet_forge (2.2.4)
faraday (~> 0.9.0)
faraday_middleware (>= 0.9.0, < 0.11.0)
gettext-setup (~> 0.11)
minitar
semantic_puppet (~> 0.1.0)
puppetlabs_spec_helper (1.1.1)
mocha
puppet-lint
puppet-syntax
rake
rspec-puppet
r10k (2.5.4)
colored (= 1.2)
cri (~> 2.6.1)
gettext-setup (~> 0.5)
log4r (= 1.1.10)
minitar (= 0.5.4)
multi_json (~> 1.10)
puppet_forge (~> 2.2)
semantic_puppet (~> 0.1.0)
rake (12.0.0)
rspec (3.6.0)
rspec-core (~> 3.6.0)
rspec-expectations (~> 3.6.0)
rspec-mocks (~> 3.6.0)
rspec-core (3.6.0)
rspec-support (~> 3.6.0)
rspec-expectations (3.6.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-mocks (3.6.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-puppet (2.5.0)
rspec
rspec-support (3.6.0)
rugged (0.25.1.1)
semantic_puppet (0.1.4)
gettext-setup (>= 0.3)
spdx-licenses (1.1.0)
text (1.3.1)
trollop (2.1.2)
yamllint (0.0.9)
trollop (~> 2)
PLATFORMS
ruby
DEPENDENCIES
json (>= 2.0.2)
json_pure (>= 2.0.2)
metadata-json-lint (~> 1.0)
puppet (~> 4.0)
puppet-lint (~> 1.1)
puppet-lint-absolute_classname-check (~> 0.2)
puppet-lint-absolute_template_path (~> 1.0)
puppet-lint-empty_string-check (~> 0.2)
puppet-lint-leading_zero-check (~> 0.1)
puppet-lint-resource_reference_syntax (~> 1.0)
puppet-lint-spaceship_operator_without_tag-check (~> 0.1)
puppet-lint-trailing_newline-check (~> 1.0)
puppet-lint-undef_in_function-check (~> 0.2)
puppet-lint-unquoted_string-check (~> 0.3)
puppet-lint-variable_contains_upcase (~> 1.1)
puppetlabs_spec_helper (~> 1.1)
r10k (~> 2.3)
rspec-puppet (~> 2.5)
rugged (~> 0.24)
yamllint (~> 0.0.9)
BUNDLED WITH
1.14.6

View file

@ -1,4 +0,0 @@
forge "http://forge.puppetlabs.com"
mod 'puppetlabs-vcsrepo', '1.5.0'

View file

@ -1,2 +0,0 @@
modulepath = modules:site:$basemodulepath
config_version = 'scripts/config_version.sh $environmentpath $environment'

View file

@ -1 +0,0 @@
---

View file

@ -1 +0,0 @@
---

View file

@ -1,14 +0,0 @@
## site.pp ##
# DEFAULT NODE
# The default node definition matches any node lacking a more specific node
# definition. If there are no other nodes in this file, classes declared here
# will be included in every node's catalog, *in addition* to any classes
# specified in the via an ENC for that node.
node default {
# This is where you can declare classes for all nodes.
# Example:
# class { 'my_class': }
}

View file

@ -1,2 +0,0 @@
---
cachedir: 'vendor/r10k'

View file

@ -1,10 +0,0 @@
#!/usr/bin/env ruby
require 'json'
environmentpath = ARGV[0]
environment = ARGV[1]
r10k_deploy_file_path = File.join(environmentpath, environment, '.r10k-deploy.json')
# output the sha1 from the control-repo
puts JSON.parse(File.read(r10k_deploy_file_path))['signature']

View file

@ -1,24 +0,0 @@
#!/usr/bin/env ruby
begin
require 'rugged'
rescue LoadError => e
t = Time.new
puts t.to_i
else
environmentpath = ARGV[0]
environment = ARGV[1]
repo = Rugged::Repository.discover(File.join(environmentpath, environment))
head = repo.head
# sha1 hash of the newest commit
head_sha = head.target_id
# the commit message associated the newest commit
commit = repo.lookup(head_sha)
# add something to find the remote url
puts head_sha
end

View file

@ -1,12 +0,0 @@
#!/bin/bash
if [ -e $1/$2/.r10k-deploy.json ]
then
/opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/code_manager_config_version.rb $1 $2
elif [ -e /opt/puppetlabs/server/pe_version ]
then
/opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/config_version.rb $1 $2
else
/usr/bin/git --version > /dev/null 2>&1 &&
/usr/bin/git --git-dir $1/$2/.git rev-parse HEAD ||
date +%s
fi

View file

@ -1,4 +0,0 @@
# the base profile should include component modules that will be on all nodes
class profile::base {
}

View file

@ -1,7 +0,0 @@
# Includes all the profiles needed for a server.
# One big difference between this and the workstation role is that you generally
# are not standing in front of the system and / or there is no graphical
# interface.
class role::workstation {
include ::profile::base
}

View file

@ -1,4 +0,0 @@
# Includes all the profiles needed for a workstation
class role::workstation {
include ::profile::base
}