From 21e03a9609931ea36d2fd0825bcb7696b6995ec0 Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Sat, 8 Feb 2020 10:10:34 +0000 Subject: [PATCH 1/7] Fix puppet-lint: trailing_comma --- manifests/init.pp | 2 +- manifests/passenger/apache.pp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index a5544f66..ecaa26ed 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -18,7 +18,7 @@ # rvm has now autolibs enabled by default so let it manage the dependencies if $install_dependencies { class { 'rvm::dependencies': - before => Class['rvm::system'] + before => Class['rvm::system'], } } diff --git a/manifests/passenger/apache.pp b/manifests/passenger/apache.pp index 5d1ec8c8..42906b43 100644 --- a/manifests/passenger/apache.pp +++ b/manifests/passenger/apache.pp @@ -16,7 +16,7 @@ class { 'rvm::passenger::gem': ruby_version => $ruby_version, version => $version, - proxy_url => $proxy_url + proxy_url => $proxy_url, } # TODO: How can we get the gempath automatically using the ruby version From 16472678441575cb8123456fca319047062ba3f7 Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Sat, 8 Feb 2020 10:15:11 +0000 Subject: [PATCH 2/7] Fix puppet-lint: arrow_on_right_operand_line --- manifests/passenger/apache.pp | 5 ++--- manifests/system.pp | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/manifests/passenger/apache.pp b/manifests/passenger/apache.pp index 42906b43..0f8c6857 100644 --- a/manifests/passenger/apache.pp +++ b/manifests/passenger/apache.pp @@ -42,15 +42,14 @@ # build the Apache module # different passenger versions put the built module in different places (ext, libout, buildout) include apache::dev - - class { 'rvm::passenger::dependencies': } -> + include rvm::passenger::dependencies exec { 'passenger-install-apache2-module': command => "${binpath}rvm ${ruby_version} exec passenger-install-apache2-module -a", creates => $modobjectpath, environment => [ 'HOME=/root', ], path => '/usr/bin:/usr/sbin:/bin', - require => Class['rvm::passenger::gem','apache::dev'], + require => Class['rvm::passenger::gem','rvm::passenger::dependencies','apache::dev'], timeout => $install_timeout, } diff --git a/manifests/system.pp b/manifests/system.pp index 232c3308..0dab65d0 100644 --- a/manifests/system.pp +++ b/manifests/system.pp @@ -86,8 +86,8 @@ # Update the rvm installation to the version specified notify { 'rvm-get_version': message => "RVM updating from version ${::rvm_version} to ${version}", - } -> - exec { 'system-rvm-get': + } + -> exec { 'system-rvm-get': path => '/usr/local/rvm/bin:/usr/bin:/usr/sbin:/bin', command => "rvm get ${version}", before => Exec['system-rvm'], # so it doesn't run after being installed the first time From e3c95d619a23cba9a04362a68aacfdb1c2994ecd Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Sat, 8 Feb 2020 12:14:39 +0000 Subject: [PATCH 3/7] Fix puppet-lint: legacy_facts --- manifests/dependencies.pp | 2 +- manifests/dependencies/centos.pp | 4 +- manifests/params.pp | 4 +- manifests/passenger/apache.pp | 4 +- manifests/passenger/dependencies.pp | 2 +- manifests/passenger/dependencies/centos.pp | 4 +- manifests/system_user.pp | 7 +- spec/classes/dependencies_spec.rb | 89 ++++++++-------------- spec/defines/system_user_spec.rb | 51 ++++++------- spec/spec_helper.rb | 15 +++- 10 files changed, 83 insertions(+), 99 deletions(-) diff --git a/manifests/dependencies.pp b/manifests/dependencies.pp index f673f884..56df4725 100644 --- a/manifests/dependencies.pp +++ b/manifests/dependencies.pp @@ -1,6 +1,6 @@ # Install packages needed by RVM when not using autolibs class rvm::dependencies { - case $::operatingsystem { + case $facts['os']['name'] { 'Ubuntu','Debian': { require rvm::dependencies::ubuntu } 'CentOS','RedHat','Fedora','rhel','Amazon','Scientific': { require rvm::dependencies::centos } 'OracleLinux': { require rvm::dependencies::oraclelinux } diff --git a/manifests/dependencies/centos.pp b/manifests/dependencies/centos.pp index 3ebbdece..b4c9207d 100644 --- a/manifests/dependencies/centos.pp +++ b/manifests/dependencies/centos.pp @@ -1,9 +1,9 @@ # Install packages needed by RVM on RedHat systems when not using autolibs class rvm::dependencies::centos { - $version = $::operatingsystem ? { + $version = $facts['os']['name'] ? { 'Amazon' => '6.x', - default => $::operatingsystemrelease, + default => $facts['os']['release']['full'], } case $version { diff --git a/manifests/params.pp b/manifests/params.pp index 1fe60509..26f31f57 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,12 +1,12 @@ # Default module parameters class rvm::params($manage_group = true) { - $manage_rvmrc = $::osfamily ? { + $manage_rvmrc = $facts['os']['family'] ? { 'Windows' => false, default => true } - $group = $::operatingsystem ? { + $group = $facts['os']['name'] ? { default => 'rvm', } diff --git a/manifests/passenger/apache.pp b/manifests/passenger/apache.pp index 0f8c6857..0d874b2f 100644 --- a/manifests/passenger/apache.pp +++ b/manifests/passenger/apache.pp @@ -72,14 +72,14 @@ subscribe => Exec['passenger-install-apache2-module'], } - case $::osfamily { + case $facts['os']['family'] { # for redhat and (some versions of) debian OSs Apache configures # passenger_extra.conf with the details that should be located in # passenger.conf; passenger.conf can't be written to directly # without conflicting with apache module settings for that file, but # copying the file contents works fine 'debian','redhat': { - case $::osfamily { + case $facts['os']['family'] { 'redhat': { $apache_mods_path = '/etc/httpd/conf.d' } diff --git a/manifests/passenger/dependencies.pp b/manifests/passenger/dependencies.pp index 9e994c73..99026f57 100644 --- a/manifests/passenger/dependencies.pp +++ b/manifests/passenger/dependencies.pp @@ -1,6 +1,6 @@ # Package dependencies for Passenger class rvm::passenger::dependencies { - case $::operatingsystem { + case $facts['os']['name'] { 'Ubuntu','Debian': { require rvm::passenger::dependencies::ubuntu } 'CentOS','RedHat','Fedora','rhel','Amazon','Scientific': { require rvm::passenger::dependencies::centos } 'OracleLinux': { require rvm::passenger::dependencies::oraclelinux } diff --git a/manifests/passenger/dependencies/centos.pp b/manifests/passenger/dependencies/centos.pp index c13817df..4e75b8c4 100644 --- a/manifests/passenger/dependencies/centos.pp +++ b/manifests/passenger/dependencies/centos.pp @@ -1,9 +1,9 @@ # Package dependencies for Passenger on RedHat class rvm::passenger::dependencies::centos { - $version = $::operatingsystem ? { + $version = $facts['os']['name'] ? { 'Amazon' => '6.x', - default => $::operatingsystemrelease, + default => $facts['os']['release']['full'], } case $version { diff --git a/manifests/system_user.pp b/manifests/system_user.pp index 2da39cdc..bcb26762 100644 --- a/manifests/system_user.pp +++ b/manifests/system_user.pp @@ -3,6 +3,9 @@ $create = true, $manage_group = undef) { + if $facts['os']['family'] == 'Windows' { + fail('rvm::system_user is not supported on Windows') + } include rvm::params $manage_group_real = $manage_group ? { @@ -23,12 +26,12 @@ Group[$rvm::params::group] -> Exec["rvm-system-user-${name}"] } - $add_to_group = $::osfamily ? { + $add_to_group = $facts['os']['family'] ? { 'Darwin' => "/usr/sbin/dseditgroup -o edit -a ${name} -t user ${rvm::params::group}", 'FreeBSD' => "/usr/sbin/pw groupmod ${rvm::params::group} -m ${name}", default => "/usr/sbin/usermod -a -G ${rvm::params::group} ${name}", } - $check_in_group = $::osfamily ? { + $check_in_group = $facts['os']['family'] ? { 'Darwin' => "/usr/bin/dsmemberutil checkmembership -U ${name} -G ${rvm::params::group} | grep -q 'user is a member'", 'FreeBSD' => "/usr/bin/id ${name} | grep -q '(${rvm::params::group})'", default => "/bin/cat /etc/group | grep '^${rvm::params::group}:' | grep -qw ${name}", diff --git a/spec/classes/dependencies_spec.rb b/spec/classes/dependencies_spec.rb index 552770c0..5a1bc7bb 100644 --- a/spec/classes/dependencies_spec.rb +++ b/spec/classes/dependencies_spec.rb @@ -1,68 +1,39 @@ require 'spec_helper' describe 'rvm::dependencies' do - - packages = ['which','gcc','autoconf','libcurl-devel','build-essential'] - - let(:facts) {{}} - - shared_examples 'package creation' do |packages_to_have| - packages_to_have.each {|p| it { should contain_package(p)} } - (packages-packages_to_have).each {|p| it { should_not contain_package(p)} } - end - - shared_context 'redhat_facts' do |operatingsystem, operatingsystemrelease| - let(:facts) { super().merge({ - :osfamily => "RedHat", - :operatingsystem => operatingsystem, - :operatingsystemrelease => operatingsystemrelease - }) } - end - - shared_examples 'redhat' do |packages_to_have| - it_behaves_like 'package creation', packages_to_have + ['which','gcc'] - end - - shared_examples 'redhat5' do |operatingsystem, operatingsystemrelease| - include_context 'redhat_facts', operatingsystem, operatingsystemrelease - it_behaves_like 'redhat', ['autoconf'] - end - - shared_examples 'redhat6' do |operatingsystem, operatingsystemrelease| - include_context 'redhat_facts', operatingsystem, operatingsystemrelease - it_behaves_like 'redhat', ['libcurl-devel'] - end - - shared_examples 'debian' do |operatingsystem| - let(:facts) {{ - :osfamily => "Debian", - :operatingsystem => operatingsystem - }} - it_behaves_like 'package creation', ['autoconf','build-essential'] - end - - - context 'RedHat' do - operatingsystems = ['centos', 'fedora', 'rhel', 'redhat', 'scientific'] - versions = { '5.0' => 'redhat5', '6.4' => 'redhat6' } - operatingsystems.each do |os| - context os, :compile do - versions.each {|version,example| it_behaves_like example, os, version } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) do + os_facts end - end - context 'amazon linux', :compile do - let(:facts) {{ :operatingsystemmajrelease => "3" }} - it_behaves_like 'redhat6', 'Amazon', '3.4.43-43.43.amzn1.x86_64' + it { is_expected.to compile.with_all_deps } + + case os_facts[:osfamily] + when 'RedHat' + it { is_expected.to contain_package('which') } + it { is_expected.to contain_package('gcc') } + it { is_expected.not_to contain_package('build-essential') } + case os_facts[:operatingsystemmajrelease] + when '5' + if ['CentOS', 'RedHat'].include? os_facts[:operatingsystem] + it { is_expected.to contain_package('autoconf') } + it { is_expected.to contain_package('curl-devel') } + it { is_expected.not_to contain_package('libcurl-devel') } + end + when '6','7' + it { is_expected.to contain_package('libcurl-devel') } + it { is_expected.not_to contain_package('autoconf') } + it { is_expected.not_to contain_package('curl-devel') } + end + when 'Debian' + it { is_expected.to contain_package('autoconf') } + it { is_expected.to contain_package('build-essential') } + it { is_expected.not_to contain_package('which') } + it { is_expected.not_to contain_package('gcc') } + end end end +end - context 'debian', :compile do - it_behaves_like 'debian', 'ubuntu' - end - context 'other', :compile do - let(:facts) {{ :operatingsystem => 'xxx' }} - it_behaves_like 'package creation', [] - end -end diff --git a/spec/defines/system_user_spec.rb b/spec/defines/system_user_spec.rb index 0577dc1c..ce1bf8df 100644 --- a/spec/defines/system_user_spec.rb +++ b/spec/defines/system_user_spec.rb @@ -1,34 +1,31 @@ require 'spec_helper' describe 'rvm::system_user' do + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) do + os_facts + end + let(:username) { 'johndoe' } + let(:group) { 'rvm' } + let(:title) { username } - let(:username) { 'johndoe' } - let(:group) { 'rvm' } - let(:title) { username } + if os_facts[:osfamily] == 'windows' + it { is_expected.to compile.and_raise_error(%r{rvm::system_user is not supported on Windows}) } + else + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_user(username) } + it { is_expected.to contain_group(group) } - context "when using default parameters", :compile do - it { should contain_user(username) } - it { should contain_group(group) } - it { should contain_exec("rvm-system-user-#{username}").with_command("/usr/sbin/usermod -a -G #{group} #{username}") } - end - - context "when using default parameters on FreeBSD", :compile do - let(:facts) {{ - :osfamily => 'FreeBSD', - }} - - it { should contain_user(username) } - it { should contain_group(group) } - it { should contain_exec("rvm-system-user-#{username}").with_command("/usr/sbin/pw groupmod #{group} -m #{username}") } - end - - context "when using default parameters on Darwin", :compile do - let(:facts) {{ - :osfamily => 'Darwin', - }} - - it { should contain_user(username) } - it { should contain_group(group) } - it { should contain_exec("rvm-system-user-#{username}").with_command("/usr/sbin/dseditgroup -o edit -a #{username} -t user #{group}") } + case os_facts[:osfamily] + when 'FreeBSD' + it { is_expected.to contain_exec("rvm-system-user-#{username}").with_command("/usr/sbin/pw groupmod #{group} -m #{username}") } + when 'Darwin' + it { is_expected.to contain_exec("rvm-system-user-#{username}").with_command("/usr/sbin/dseditgroup -o edit -a #{username} -t user #{group}") } + else + it { is_expected.to contain_exec("rvm-system-user-#{username}").with_command("/usr/sbin/usermod -a -G #{group} #{username}") } + end + end + end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d6f2d800..ee4acb03 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,6 +2,8 @@ # https://github.com/maestrodev/puppet-modulesync require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' +include RspecPuppetFacts RSpec.configure do |c| c.mock_with :rspec @@ -18,7 +20,18 @@ :kernel => 'Linux', :osfamily => 'RedHat', :architecture => 'x86_64', - :clientcert => 'puppet.acme.com' + :clientcert => 'puppet.acme.com', + :os => { + 'architecture' => 'x86_64', + 'family' => 'RedHat', + 'hardware' => 'x86_64', + 'name' => 'CentOS', + 'release' => { + 'full' => '6.6', + 'major' => '6', + 'minor' => '6' + } + }, }.merge({}) c.before do From e840cf66a3ba1a31601baf381008eda323fda185 Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Sat, 8 Feb 2020 12:51:38 +0000 Subject: [PATCH 4/7] Update Gemfile, Rakefile Instead of doing a full modulesync, this is just enough to get some tests running. --- .gitignore | 55 +++-------- .rspec | 2 + .travis.yml | 79 +++++---------- Gemfile | 95 +++++++++++++++--- Gemfile.lock | 275 --------------------------------------------------- Rakefile | 98 +++++++++++++----- 6 files changed, 203 insertions(+), 401 deletions(-) create mode 100644 .rspec delete mode 100644 Gemfile.lock diff --git a/.gitignore b/.gitignore index 5d046865..5e135f2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,44 +1,21 @@ -# This file is managed centrally by modulesync -# https://github.com/maestrodev/puppet-modulesync - -## MAC OS -.DS_Store - -## TEXTMATE -*.tmproj -tmtags - -## EMACS -*~ -\#* -.\#* - -## VIM -*.swp -*.swo -tags - -## Bundler -.bundle +pkg/ +Gemfile.lock +Gemfile.local vendor/ - -## rbenv / rvm -.rbenv* -.rvmrc* -.ruby-* - -# IntelliJ/RubyMine -.idea/* - -## rspec +.vendor/ spec/fixtures/manifests/ spec/fixtures/modules/ - -## Puppet module -pkg/ +.vagrant/ +.bundle/ +.ruby-version coverage/ - -## Librarian-puppet -.tmp/ +log/ +.idea/ +.dependencies/ .librarian/ - +Puppetfile.lock +*.iml +.*.sw? +.yardoc/ +Guardfile +spec/fixtures/tmpdir/ diff --git a/.rspec b/.rspec new file mode 100644 index 00000000..8c18f1ab --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--format documentation +--color diff --git a/.travis.yml b/.travis.yml index cfe62560..e3807878 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,55 +1,30 @@ --- -# This file is managed centrally by modulesync -# https://github.com/maestrodev/puppet-modulesync - -sudo: false - +dist: bionic +language: ruby +cache: bundler before_install: - - rm -f Gemfile.lock - -rvm: - - "2.0" - -env: - - PUPPET_VERSION="~> 4.0.0" - - PUPPET_VERSION="~> 3.7.0" - - PUPPET_VERSION="~> 3.6.0" - - PUPPET_VERSION="~> 3.5.0" - - PUPPET_VERSION="~> 3.4.0" - - PUPPET_VERSION="~> 3.3.0" - - PUPPET_VERSION="~> 3.2.0" - + - yes | gem update --system + - bundle --version +script: + - 'bundle exec rake $CHECK' matrix: - exclude: - # No support for Ruby 2.0 before Puppet 3.2 - - rvm: '2.0' - env: PUPPET_VERSION="~> 2.7.0" - - rvm: '2.0' - env: PUPPET_VERSION="~> 3.0.0" - - rvm: '2.0' - env: PUPPET_VERSION="~> 3.1.0" - # Puppet < 3.5.0 is broken under ruby 2.1 https://tickets.puppetlabs.com/browse/PUP-1243 - - rvm: '2.1' - env: PUPPET_VERSION="~> 2.7.0" - - rvm: '2.1' - env: PUPPET_VERSION="~> 3.0.0" - - rvm: '2.1' - env: PUPPET_VERSION="~> 3.1.0" - - rvm: '2.1' - env: PUPPET_VERSION="~> 3.2.0" - - rvm: '2.1' - env: PUPPET_VERSION="~> 3.3.0" - - rvm: '2.1' - env: PUPPET_VERSION="~> 3.4.0" - -deploy: - provider: puppetforge - user: maestrodev - password: - secure: "P0disPGZg4I9kuO98yZOPxpdJjBWV+3U9iFCfRKpCO4jzBiqkCaofnr79Iy+7aqyWAKdbp54JUIbKenvz+WixbVjxvJNiTV991B6anaDXOZfk5oudoxy+hMmkor881ZznWJgwaim4BA3qcTghpIhMSqFP5FF0CaJUfzTEaj73s8=" - on: - tags: true - # all_branches is required to use tags - all_branches: true - # Only publish if our main Ruby target builds - condition: "$PUPPET_VERSION = '~> 3.6.0'" + fast_finish: true + include: + - rvm: 2.4.4 + bundler_args: --without system_tests development release + env: PUPPET_VERSION="~> 5.0" CHECK=test + - rvm: 2.5.3 + bundler_args: --without system_tests development release + env: PUPPET_VERSION="~> 6.0" CHECK=test_with_coveralls +branches: + only: + - master + - /^v\d/ +notifications: + email: false + webhooks: https://voxpupu.li/incoming/travis + irc: + on_success: always + on_failure: always + channels: + - "chat.freenode.org#voxpupuli-notifications" diff --git a/Gemfile b/Gemfile index e65e84b0..8b4adb5c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,17 +1,86 @@ -# This file is managed centrally by modulesync -# https://github.com/maestrodev/puppet-modulesync +source ENV['GEM_SOURCE'] || "https://rubygems.org" -source 'https://rubygems.org' +def location_for(place, fake_version = nil) + if place =~ /^(git[:@][^#]*)#(.*)/ + [fake_version, { :git => $1, :branch => $2, :require => false }].compact + elsif place =~ /^file:\/\/(.*)/ + ['>= 0', { :path => File.expand_path($1), :require => false }] + else + [place, { :require => false }] + end +end -gem 'puppet', ENV['PUPPET_VERSION'] || '>= 3.0', :require => false +group :test do + gem 'puppetlabs_spec_helper', '>= 2.14.0', :require => false + gem 'rspec-puppet-facts', '>= 1.9.5', :require => false + gem 'rspec-puppet-utils', :require => false + gem 'puppet-lint-leading_zero-check', :require => false + gem 'puppet-lint-trailing_comma-check', :require => false + gem 'puppet-lint-version_comparison-check', :require => false + gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false + gem 'puppet-lint-unquoted_string-check', :require => false + gem 'puppet-lint-variable_contains_upcase', :require => false + gem 'puppet-lint-absolute_classname-check', '>= 2.0.0', :require => false + gem 'puppet-lint-topscope-variable-check', :require => false + gem 'puppet-lint-legacy_facts-check', :require => false + gem 'puppet-lint-anchor-check', :require => false + gem 'metadata-json-lint', :require => false + gem 'redcarpet', :require => false + gem 'rubocop', '~> 0.49.1', :require => false + gem 'rubocop-rspec', '~> 1.15.0', :require => false + gem 'mocha', '~> 1.4.0', :require => false + gem 'coveralls', :require => false + gem 'simplecov-console', :require => false + gem 'parallel_tests', :require => false +end -gem 'rake', :require => false -gem 'rspec-puppet', '>= 2.1.0', :require => false -gem 'puppetlabs_spec_helper', '>= 0.8.0', :require => false -gem 'puppet-lint', '>= 1.1.0', :require => false -gem 'simplecov', :require => false -gem 'puppet-blacksmith', '>= 3.3.1', :require => false -gem 'librarian-puppet', '>= 2.0.0', :require => false -gem 'beaker-rspec', '>= 3.0.0', :require => false +group :development do + gem 'travis', :require => false + gem 'travis-lint', :require => false + gem 'guard-rake', :require => false + gem 'overcommit', '>= 0.39.1', :require => false +end -# vim:ft=ruby +group :system_tests do + gem 'winrm', :require => false + if beaker_version = ENV['BEAKER_VERSION'] + gem 'beaker', *location_for(beaker_version) + else + gem 'beaker', '>= 4.2.0', :require => false + end + if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] + gem 'beaker-rspec', *location_for(beaker_rspec_version) + else + gem 'beaker-rspec', :require => false + end + gem 'serverspec', :require => false + gem 'beaker-hostgenerator', '>= 1.1.22', :require => false + gem 'beaker-docker', :require => false + gem 'beaker-puppet', :require => false + gem 'beaker-puppet_install_helper', :require => false + gem 'beaker-module_install_helper', :require => false + gem 'rbnacl', '>= 4', :require => false + gem 'rbnacl-libsodium', :require => false + gem 'bcrypt_pbkdf', :require => false + gem 'ed25519', :require => false +end + +group :release do + gem 'github_changelog_generator', :require => false, :git => 'https://github.com/voxpupuli/github-changelog-generator', :branch => 'voxpupuli_essential_fixes' + gem 'puppet-blacksmith', :require => false + gem 'voxpupuli-release', :require => false + gem 'puppet-strings', '>= 2.2', :require => false +end + + + +if facterversion = ENV['FACTER_GEM_VERSION'] + gem 'facter', facterversion.to_s, :require => false, :groups => [:test] +else + gem 'facter', :require => false, :groups => [:test] +end + +ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 6.0' : puppetversion = ENV['PUPPET_VERSION'].to_s +gem 'puppet', puppetversion, :require => false, :groups => [:test] + +# vim: syntax=ruby diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index b193e28d..00000000 --- a/Gemfile.lock +++ /dev/null @@ -1,275 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - CFPropertyList (2.2.8) - activemodel (4.2.0) - activesupport (= 4.2.0) - builder (~> 3.1) - activesupport (4.2.0) - i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - addressable (2.3.6) - archive-tar-minitar (0.5.2) - autoparse (0.3.3) - addressable (>= 2.3.1) - extlib (>= 0.9.15) - multi_json (>= 1.0.0) - aws-sdk (1.61.0) - aws-sdk-v1 (= 1.61.0) - aws-sdk-v1 (1.61.0) - json (~> 1.4) - nokogiri (>= 1.4.4) - beaker (2.2.0) - aws-sdk (~> 1.57) - docker-api - fission (~> 0.4) - fog (~> 1.25) - google-api-client (~> 0.7) - hocon (~> 0.0.4) - inifile (~> 2.0) - json (~> 1.8) - minitest (~> 5.4) - net-scp (~> 1.2) - net-ssh (~> 2.9) - rbvmomi (~> 1.8) - unf (~> 0.1) - beaker-rspec (5.0.0) - beaker (~> 2.0) - rspec - serverspec (~> 2) - specinfra (~> 2) - builder (3.2.2) - diff-lcs (1.2.5) - docile (1.1.5) - docker-api (1.17.0) - archive-tar-minitar - excon (>= 0.38.0) - json - domain_name (0.5.23) - unf (>= 0.0.5, < 1.0.0) - excon (0.43.0) - extlib (0.9.16) - facter (2.4.3) - CFPropertyList (~> 2.2.6) - faraday (0.9.1) - multipart-post (>= 1.2, < 3) - fission (0.5.0) - CFPropertyList (~> 2.2) - fog (1.27.0) - fog-atmos - fog-aws (~> 0.0) - fog-brightbox (~> 0.4) - fog-core (~> 1.27, >= 1.27.3) - fog-ecloud - fog-json - fog-profitbricks - fog-radosgw (>= 0.0.2) - fog-sakuracloud (>= 0.0.4) - fog-serverlove - fog-softlayer - fog-storm_on_demand - fog-terremark - fog-vmfusion - fog-voxel - fog-xml (~> 0.1.1) - ipaddress (~> 0.5) - nokogiri (~> 1.5, >= 1.5.11) - fog-atmos (0.1.0) - fog-core - fog-xml - fog-aws (0.0.6) - fog-core (~> 1.27) - fog-json (~> 1.0) - fog-xml (~> 0.1) - ipaddress (~> 0.8) - fog-brightbox (0.7.1) - fog-core (~> 1.22) - fog-json - inflecto (~> 0.0.2) - fog-core (1.27.3) - builder - excon (~> 0.38) - formatador (~> 0.2) - mime-types - net-scp (~> 1.1) - net-ssh (>= 2.1.3) - fog-ecloud (0.0.2) - fog-core - fog-xml - fog-json (1.0.0) - multi_json (~> 1.0) - fog-profitbricks (0.0.1) - fog-core - fog-xml - nokogiri - fog-radosgw (0.0.3) - fog-core (>= 1.21.0) - fog-json - fog-xml (>= 0.0.1) - fog-sakuracloud (0.1.1) - fog-core - fog-json - fog-serverlove (0.1.1) - fog-core - fog-json - fog-softlayer (0.3.30) - fog-core - fog-json - fog-storm_on_demand (0.1.0) - fog-core - fog-json - fog-terremark (0.0.3) - fog-core - fog-xml - fog-vmfusion (0.0.1) - fission - fog-core - fog-voxel (0.0.2) - fog-core - fog-xml - fog-xml (0.1.1) - fog-core - nokogiri (~> 1.5, >= 1.5.11) - formatador (0.2.5) - google-api-client (0.8.2) - activesupport (>= 3.2) - addressable (~> 2.3) - autoparse (~> 0.3) - extlib (~> 0.9) - faraday (~> 0.9) - launchy (~> 2.4) - multi_json (~> 1.10) - retriable (~> 1.4) - signet (~> 0.6) - her (0.7.3) - activemodel (>= 3.0.0, <= 4.2) - activesupport (>= 3.0.0, <= 4.2) - faraday (>= 0.8, < 1.0) - multi_json (~> 1.7) - hiera (2.0.0) - json_pure - highline (1.6.21) - hocon (0.0.6) - http-cookie (1.0.2) - domain_name (~> 0.5) - i18n (0.7.0) - inflecto (0.0.2) - inifile (2.0.2) - ipaddress (0.8.0) - json (1.8.2) - json_pure (1.8.2) - jwt (1.2.0) - launchy (2.4.3) - addressable (~> 2.3) - librarian (0.1.2) - highline - thor (~> 0.15) - librarian-puppet (2.0.1) - librarian (>= 0.1.2) - puppet_forge - rsync - metaclass (0.0.4) - mime-types (2.4.3) - mini_portile (0.6.2) - minitest (5.5.1) - mocha (1.1.0) - metaclass (~> 0.0.1) - multi_json (1.10.1) - multipart-post (2.0.0) - net-scp (1.2.1) - net-ssh (>= 2.6.5) - net-ssh (2.9.2) - netrc (0.10.3) - nokogiri (1.6.5) - mini_portile (~> 0.6.0) - puppet (4.0.0) - facter (> 2.0, < 4) - hiera (>= 2.0, < 3) - json_pure - puppet-blacksmith (3.3.1) - puppet (>= 2.7.16) - rest-client - puppet-lint (1.1.0) - puppet-syntax (2.0.0) - rake - puppet_forge (1.0.4) - her (~> 0.6) - puppetlabs_spec_helper (0.10.2) - mocha - puppet-lint - puppet-syntax - rake - rspec-puppet - rake (10.4.2) - rbvmomi (1.8.2) - builder - nokogiri (>= 1.4.1) - trollop - rest-client (1.8.0) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) - retriable (1.4.1) - rspec (3.2.0) - rspec-core (~> 3.2.0) - rspec-expectations (~> 3.2.0) - rspec-mocks (~> 3.2.0) - rspec-core (3.2.3) - rspec-support (~> 3.2.0) - rspec-expectations (3.2.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.2.0) - rspec-its (1.1.0) - rspec-core (>= 3.0.0) - rspec-expectations (>= 3.0.0) - rspec-mocks (3.2.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.2.0) - rspec-puppet (2.1.0) - rspec - rspec-support (3.2.2) - rsync (1.0.9) - serverspec (2.7.1) - multi_json - rspec (~> 3.0) - rspec-its - specinfra (~> 2.10) - signet (0.6.0) - addressable (~> 2.3) - extlib (~> 0.9) - faraday (~> 0.9) - jwt (~> 1.0) - multi_json (~> 1.10) - simplecov (0.9.1) - docile (~> 1.1.0) - multi_json (~> 1.0) - simplecov-html (~> 0.8.0) - simplecov-html (0.8.0) - specinfra (2.11.5) - net-scp - net-ssh - thor (0.19.1) - thread_safe (0.3.4) - trollop (2.1.1) - tzinfo (1.2.2) - thread_safe (~> 0.1) - unf (0.1.4) - unf_ext - unf_ext (0.0.6) - -PLATFORMS - ruby - -DEPENDENCIES - beaker-rspec (>= 3.0.0) - librarian-puppet (>= 2.0.0) - puppet (>= 3.0) - puppet-blacksmith (>= 3.3.1) - puppet-lint (>= 1.1.0) - puppetlabs_spec_helper (>= 0.8.0) - rake - rspec-puppet (>= 2.1.0) - simplecov diff --git a/Rakefile b/Rakefile index 466d7a1c..c844a789 100644 --- a/Rakefile +++ b/Rakefile @@ -1,31 +1,85 @@ -# This file is managed centrally by modulesync -# https://github.com/maestrodev/puppet-modulesync - -require 'rake/clean' require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' -require 'puppet_blacksmith/rake_tasks' -CLEAN.include('spec/fixtures/manifests/', 'spec/fixtures/modules/', 'doc', 'pkg') -CLOBBER.include('.tmp', '.librarian') +# load optional tasks for releases +# only available if gem group releases is installed +begin + require 'voxpupuli/release/rake_tasks' +rescue LoadError +end + +PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}' +desc 'Auto-correct puppet-lint offenses' +task 'lint:auto_correct' do + Rake::Task[:lint_fix].invoke +end -task :librarian_spec_prep do - sh "librarian-puppet install --path=spec/fixtures/modules/" +desc 'Run acceptance tests' +RSpec::Core::RakeTask.new(:acceptance) do |t| + t.pattern = 'spec/acceptance' end -task :spec_prep => :librarian_spec_prep - -Rake::Task[:lint].clear # workaround https://github.com/rodjek/puppet-lint/issues/331 -PuppetLint.configuration.relative = true # https://github.com/rodjek/puppet-lint/pull/334 -PuppetLint::RakeTask.new :lint do |config| - config.pattern = 'manifests/**/*.pp' - config.disable_checks = ["80chars", "class_inherits_from_params_class"] - config.fail_on_warnings = true - # config.relative = true + +desc 'Run tests' +task test: [:release_checks] + +namespace :check do + desc 'Check for trailing whitespace' + task :trailing_whitespace do + Dir.glob('**/*.md', File::FNM_DOTMATCH).sort.each do |filename| + next if filename =~ %r{^((modules|acceptance|\.?vendor|spec/fixtures|pkg)/|REFERENCE.md)} + File.foreach(filename).each_with_index do |line, index| + if line =~ %r{\s\n$} + puts "#{filename} has trailing whitespace on line #{index + 1}" + exit 1 + end + end + end + end end +Rake::Task[:release_checks].enhance ['check:trailing_whitespace'] -Blacksmith::RakeTask.new do |t| - t.build = false # do not build the module nor push it to the Forge, just do the tagging [:clean, :tag, :bump_commit] +desc "Run main 'test' task and report merged results to coveralls" +task test_with_coveralls: [:test] do + if Dir.exist?(File.expand_path('../lib', __FILE__)) + require 'coveralls/rake/task' + Coveralls::RakeTask.new + Rake::Task['coveralls:push'].invoke + else + puts 'Skipping reporting to coveralls. Module has no lib dir' + end end -task :default => [:clean, :validate, :lint, :spec] +desc 'Generate REFERENCE.md' +task :reference, [:debug, :backtrace] do |t, args| + patterns = 'lib/puppet/functions/extlib/*.rb functions/*.pp' + Rake::Task['strings:generate:reference'].invoke(patterns, args[:debug], args[:backtrace]) +end + +begin + require 'github_changelog_generator/task' + GitHubChangelogGenerator::RakeTask.new :changelog do |config| + version = (Blacksmith::Modulefile.new).version + config.future_release = "v#{version}" if version =~ /^\d+\.\d+.\d+$/ + config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module." + config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog} + config.user = 'voxpupuli' + metadata_json = File.join(File.dirname(__FILE__), 'metadata.json') + metadata = JSON.load(File.read(metadata_json)) + config.project = metadata['name'] + end + + # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715 + require 'rbconfig' + if RbConfig::CONFIG['host_os'] =~ /linux/ + task :changelog do + puts 'Fixing line endings...' + changelog_file = File.join(__dir__, 'CHANGELOG.md') + changelog_txt = File.read(changelog_file) + new_contents = changelog_txt.gsub(%r{\r\n}, "\n") + File.open(changelog_file, "w") {|file| file.puts new_contents } + end + end + +rescue LoadError +end +# vim: syntax=ruby From 45a207f713b6557ee79b2a82d2fcde9162512490 Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Sat, 8 Feb 2020 13:01:49 +0000 Subject: [PATCH 5/7] Drop Ubuntu 10.04 support --- metadata.json | 1 - 1 file changed, 1 deletion(-) diff --git a/metadata.json b/metadata.json index 0540561b..a4c555c7 100644 --- a/metadata.json +++ b/metadata.json @@ -71,7 +71,6 @@ { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "10.04", "12.04" ] }, From e21706a37fc38560ccc773ee6069e8a8ba8341dd Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Sat, 8 Feb 2020 13:12:36 +0000 Subject: [PATCH 6/7] Remove tests directory Nothing of interest in here worth moving to an examples directory. --- tests/init.pp | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 tests/init.pp diff --git a/tests/init.pp b/tests/init.pp deleted file mode 100644 index e1a19562..00000000 --- a/tests/init.pp +++ /dev/null @@ -1,7 +0,0 @@ -if $::osfamily == 'RedHat' { - class { 'epel': - before => Class['rvm'], - } -} - -class { 'rvm': } From e9c5eb1663490bb55ef815e7d687a3fd31416d59 Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Sat, 8 Feb 2020 13:18:34 +0000 Subject: [PATCH 7/7] Remove Puppetfile.lock --- Puppetfile.lock | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 Puppetfile.lock diff --git a/Puppetfile.lock b/Puppetfile.lock deleted file mode 100644 index 5125412a..00000000 --- a/Puppetfile.lock +++ /dev/null @@ -1,10 +0,0 @@ -FORGE - remote: https://forgeapi.puppetlabs.com - specs: - golja-gnupg (1.2.0) - puppetlabs-stdlib (4.5.1) - -DEPENDENCIES - golja-gnupg (>= 1.2.0) - puppetlabs-stdlib (>= 4.2.0) -