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,4 +1,5 @@
--- ---
BUNDLE_DISABLE_SHARED_GEMS: "true"
BUNDLE_JOBS: "3" BUNDLE_JOBS: "3"
BUNDLE_PATH: "vendor/bundle" BUNDLE_PATH: "vendor/bundle"
BUNDLE_DISABLE_SHARED_GEMS: "true" BUNDLE_RETRY: "3"

5
.gitignore vendored
View file

@ -1,2 +1,3 @@
.vagrant/ /.vagrant/
bin/puppet/vendor/ /vendor/

1
.ruby-version Normal file
View file

@ -0,0 +1 @@
2.4.1

View file

@ -1,7 +1,12 @@
language: python language: ruby
python: cache: bundler
- '2.7'
- '3.3'
- pypy
script: pytest
rvm:
- 2.4.1
- 2.3.1
- 2.2.0
- 2.0.0
notifications:
slack:
secure: "HLf1vdPyg/2ezvShnwmRRtkXXap2yrMCsbU9Ow2moIhdPfDBhecXBBUsZ7/9vkIq6aTjvNb40708Q72Ndhycr1v9BE4y1KGTxcid99IhRuQEBFKkJRQpRSAqUhKq46hgUb986alQ5NoxYfMgXIC9+HzQYkoM1TXVrS3+D0cqBpkjUGl5pBG2DCa6nyAVeXzmVcs4+xeEOhkblfE5I7mXiFO0/aVcUeo+TYwSwDslPWx8OFd2PJjuceLMM8B1iBk4zY47FMdveUSA4lDQAtYMantiJvUrAGcyOUNEQZ8AsvVHuYW4HL3h3dvKXy6DM9ejwYxSFIYYtDlfCvTkY/m5HPCXvwLjABxV1JGCNkVs2vhmiCcvKSt4T4IdPxoGnMiT0UljVke5SY16hYaHkoaBtuzkRqCkRjD+nyPH5Y90c4D0uhrlob9dmUS7RkRqIZRDoaPoNS2xfrIHyEpsaXYr4rY0gBVB+ILd1DWJPIyAjRURkOVxKg1+0Tslq3B1FLAMmW/SkqYTtek680I5r+BDPFA9Eo+hxYqpWed/j68imRy6x6ZvwjS0ku+TG1G4z3P0W0wbys31/uC0PRP6YRJt1APKYxzP13rMWc21LXJoUgFtu19PbaCG2tHeb2oEdWkv3ilbbpMogjkU0+lrBP3ZLSIduuEvDDC9kpQy6Nrea5Y="

View file

@ -1,23 +1,28 @@
# vim:ft=ruby # vim:ft=ruby
source 'https://rubygems.org' source 'https://rubygems.org'
ruby '>= 2.0.0'
if ENV.key?('PUPPET_VERSION') if ENV.key?('PUPPET_VERSION')
puppetversion = "#{ENV['PUPPET_VERSION']}" puppetversion = "#{ENV['PUPPET_VERSION']}"
else else
puppetversion = ['~> 4.0'] puppetversion = ['~> 4.0']
end end
group :development, :unit_tests do group :production do
gem 'os', '~> 1.0'
gem 'puppet', puppetversion
gem 'r10k', '~> 2.3'
gem 'rugged', '~> 0.24'
end
gem 'json', '>= 2.0.2' group :development, :unit_tests do
gem 'json_pure', '>= 2.0.2' gem 'json', '>= 2.0.2'
gem 'metadata-json-lint', '~> 1.0' gem 'json_pure', '>= 2.0.2'
gem 'puppet', puppetversion gem 'metadata-json-lint', '~> 1.0'
gem 'puppetlabs_spec_helper', '~> 1.1' gem 'puppetlabs_spec_helper', '~> 1.1'
gem 'r10k', '~> 2.3' gem 'rspec-puppet', '~> 2.5'
gem 'rspec-puppet', '~> 2.5' gem 'yamllint', '~> 0.0.9'
gem 'rugged', '~> 0.24'
gem 'yamllint', '~> 0.0.9'
# puppet-lint and plugins # puppet-lint and plugins
gem 'puppet-lint', '~> 1.1' gem 'puppet-lint', '~> 1.1'

View file

@ -1,11 +1,14 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
CFPropertyList (2.2.8)
colored (1.2) colored (1.2)
cri (2.6.1) cri (2.6.1)
colored (~> 1.2) colored (~> 1.2)
diff-lcs (1.3) diff-lcs (1.3)
facter (2.4.6) facter (2.4.6)
facter (2.4.6-universal-darwin)
CFPropertyList (~> 2.2.6)
faraday (0.9.2) faraday (0.9.2)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
faraday_middleware (0.10.1) faraday_middleware (0.10.1)
@ -33,10 +36,16 @@ GEM
metaclass (~> 0.0.1) metaclass (~> 0.0.1)
multi_json (1.12.1) multi_json (1.12.1)
multipart-post (2.0.0) multipart-post (2.0.0)
os (1.0.0)
puppet (4.5.3) puppet (4.5.3)
facter (> 2.0, < 4) facter (> 2.0, < 4)
hiera (>= 2.0, < 4) hiera (>= 2.0, < 4)
json_pure json_pure
puppet (4.5.3-universal-darwin)
CFPropertyList (~> 2.2.6)
facter (> 2.0, < 4)
hiera (>= 2.0, < 4)
json_pure
puppet-lint (1.1.0) puppet-lint (1.1.0)
puppet-lint-absolute_classname-check (0.2.4) puppet-lint-absolute_classname-check (0.2.4)
puppet-lint (>= 1.0, < 3.0) puppet-lint (>= 1.0, < 3.0)
@ -108,11 +117,14 @@ GEM
PLATFORMS PLATFORMS
ruby ruby
x86_64-darwin-16
x86_64-linux
DEPENDENCIES DEPENDENCIES
json (>= 2.0.2) json (>= 2.0.2)
json_pure (>= 2.0.2) json_pure (>= 2.0.2)
metadata-json-lint (~> 1.0) metadata-json-lint (~> 1.0)
os (~> 1.0)
puppet (~> 4.0) puppet (~> 4.0)
puppet-lint (~> 1.1) puppet-lint (~> 1.1)
puppet-lint-absolute_classname-check (~> 0.2) puppet-lint-absolute_classname-check (~> 0.2)
@ -131,5 +143,8 @@ DEPENDENCIES
rugged (~> 0.24) rugged (~> 0.24)
yamllint (~> 0.0.9) yamllint (~> 0.0.9)
RUBY VERSION
ruby 2.3.1p112
BUNDLED WITH BUNDLED WITH
1.14.6 1.14.6

View file

@ -7,7 +7,7 @@ My dot files and a tool to deploy them to various OS's
* files in [link/](link) get symlinked to `~/.{filename}` * files in [link/](link) get symlinked to `~/.{filename}`
* files in [copy/](copy) get copied to `~/.{filename}` * files in [copy/](copy) get copied to `~/.{filename}`
* this process should default to not clobbering existing files * this process should default to not clobbering existing files
* [bin/dots.py](bin/dots.py) is what users will interact with * [bin/dots.rb](bin/dots.rb) is what users will interact with
* it should bootstrap based on the OS it is being run on * it should bootstrap based on the OS it is being run on
* it should run Puppet and associated tools such as r10k via bundler * it should run Puppet and associated tools such as r10k via bundler
* it should not utilize Git submodules; it should instead use [vcsrepo](https://forge.puppet.com/puppetlabs/vcsrepo) * it should not utilize Git submodules; it should instead use [vcsrepo](https://forge.puppet.com/puppetlabs/vcsrepo)
@ -30,7 +30,7 @@ My dot files and a tool to deploy them to various OS's
```bash ```bash
git clone git@github.com:genebean/dots.git ~/.dotfiles git clone git@github.com:genebean/dots.git ~/.dotfiles
cd ~/.dotfiles/bin/puppet cd ~/.dotfiles
bundle install bundle install
bundle exec r10k puppetfile install --moduledir vendor/puppet_modules --puppetfile Puppetfile -v bundle exec r10k puppetfile install --moduledir vendor/puppet_modules --puppetfile puppet/Puppetfile -v
``` ```

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