Skip to content

Commit

Permalink
Merge pull request #735 from voxpupuli/modulesync
Browse files Browse the repository at this point in the history
modulesync 2.2.0 and allow puppet 6.x
  • Loading branch information
bastelfreak authored Oct 14, 2018
2 parents 6a87b0d + 3515948 commit c8947e3
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 85 deletions.
15 changes: 8 additions & 7 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
fixtures:
repositories:
"stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
"apt": "git://github.com/puppetlabs/puppetlabs-apt.git"
"archive": "https://github.com/voxpupuli/puppet-archive.git"
"erlang": "git://github.com/garethr/garethr-erlang.git"
"systemd": "https://github.com/camptocamp/puppet-systemd.git"
symlinks:
"rabbitmq": "#{source_dir}"
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib'
apt: 'https://github.com/puppetlabs/puppetlabs-apt'
archive: 'https://github.com/voxpupuli/puppet-archive'
erlang: 'https://github.com/garethr/garethr-erlang'
systemd: 'https://github.com/camptocamp/puppet-systemd'
yumrepo_core:
repo: 'https://github.com/puppetlabs/puppetlabs-yumrepo_core'
puppet_version: '>= 6.0.0'
5 changes: 3 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ By participating in this project you agree to abide by its terms.
runs the tests for us. You can also execute them locally. This is explained
in a later section.

1. Checkout the docs we use to review a module. They provide some guidance for
new code that might help you before you submit a pull request.
1. Checkout [our docs](https://voxpupuli.org/docs/#reviewing-a-module-pr) we
use to review a module and the [official styleguide](https://puppet.com/docs/puppet/6.0/style_guide.html).
They provide some guidance for new code that might help you before you submit a pull request.

1. Add a test for your change. Only refactoring and documentation
changes require no new tests. If you are adding functionality
Expand Down
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
modulesync_config_version: '2.0.0-rc0'
modulesync_config_version: '2.2.0'
2 changes: 1 addition & 1 deletion .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ appveyor.yml:
spec/spec_helper.rb:
allow_deprecations: true
spec_overrides: "require 'spec_helper_local'"
mock_with: ':rspec'
mock_with: ':mocha'
44 changes: 40 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ matrix:
env: PUPPET_VERSION="~> 5.0" CHECK=test
- rvm: 2.5.1
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 5.0" CHECK=test_with_coveralls
- rvm: 2.4.4
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 5.0" CHECK=rubocop
env: PUPPET_VERSION="~> 6.0" CHECK=test_with_coveralls
- rvm: 2.5.1
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 6.0" CHECK=rubocop
- rvm: 2.4.4
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes
- rvm: 2.5.1
Expand All @@ -31,6 +31,12 @@ matrix:
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian8-64{hypervisor=docker} CHECK=beaker
services: docker
sudo: required
- rvm: 2.5.1
bundler_args: --without development release
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian8-64{hypervisor=docker} CHECK=beaker
services: docker
sudo: required
- rvm: 2.5.1
bundler_args: --without development release
dist: trusty
Expand All @@ -43,6 +49,12 @@ matrix:
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian9-64{hypervisor=docker} CHECK=beaker
services: docker
sudo: required
- rvm: 2.5.1
bundler_args: --without development release
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian9-64{hypervisor=docker} CHECK=beaker
services: docker
sudo: required
- rvm: 2.5.1
bundler_args: --without development release
dist: trusty
Expand All @@ -55,6 +67,12 @@ matrix:
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1404-64{hypervisor=docker} CHECK=beaker
services: docker
sudo: required
- rvm: 2.5.1
bundler_args: --without development release
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1404-64{hypervisor=docker} CHECK=beaker
services: docker
sudo: required
- rvm: 2.5.1
bundler_args: --without development release
dist: trusty
Expand All @@ -67,6 +85,12 @@ matrix:
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64{hypervisor=docker} CHECK=beaker
services: docker
sudo: required
- rvm: 2.5.1
bundler_args: --without development release
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64{hypervisor=docker} CHECK=beaker
services: docker
sudo: required
- rvm: 2.5.1
bundler_args: --without development release
dist: trusty
Expand All @@ -79,6 +103,12 @@ matrix:
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos6-64{hypervisor=docker} CHECK=beaker
services: docker
sudo: required
- rvm: 2.5.1
bundler_args: --without development release
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos6-64{hypervisor=docker} CHECK=beaker
services: docker
sudo: required
- rvm: 2.5.1
bundler_args: --without development release
dist: trusty
Expand All @@ -91,6 +121,12 @@ matrix:
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64{hypervisor=docker} CHECK=beaker
services: docker
sudo: required
- rvm: 2.5.1
bundler_args: --without development release
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos7-64{hypervisor=docker} CHECK=beaker
services: docker
sudo: required
- rvm: 2.5.1
bundler_args: --without development release
dist: trusty
Expand Down
5 changes: 2 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ def location_for(place, fake_version = nil)
end

group :test do
gem 'puppetlabs_spec_helper', '~> 2.6', :require => false
gem 'rspec-puppet', '~> 2.5', :require => false
gem 'rspec-puppet-facts', :require => false
gem 'puppetlabs_spec_helper', '>= 2.11.0', :require => false
gem 'rspec-puppet-facts', '>= 1.8.0', :require => false
gem 'rspec-puppet-utils', :require => false
gem 'puppet-lint-leading_zero-check', :require => false
gem 'puppet-lint-trailing_comma-check', :require => false
Expand Down
2 changes: 1 addition & 1 deletion manifests/repo/apt.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
key => {
'id' => $key,
'source' => $key_source,
'content' => $key_content,
'content' => $key_content,
},
architecture => $architecture,
}
Expand Down
16 changes: 14 additions & 2 deletions spec/classes/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,18 @@
context 'with no pin', if: facts[:os]['family'] == 'Debian' do
let(:params) { { repos_ensure: true, package_apt_pin: '' } }

if Puppet.version =~ %r{^6} # https://tickets.puppetlabs.com/browse/PUP-9112 and https://tickets.puppetlabs.com/browse/PUP-9180
let(:expected_key_apt_source_key_content) { 'nil' }
else
let(:expected_key_apt_source_key_content) { ':undef' }
end

describe 'it sets up an apt::source' do
it {
is_expected.to contain_apt__source('rabbitmq').with(
'location' => "https://packagecloud.io/rabbitmq/rabbitmq-server/#{facts[:os]['name'].downcase}",
'repos' => 'main',
'key' => '{"id"=>"418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB", "source"=>"https://packagecloud.io/gpg.key", "content"=>:undef}'
'key' => "{\"id\"=>\"418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB\", \"source\"=>\"https://packagecloud.io/gpg.key\", \"content\"=>#{expected_key_apt_source_key_content}}"
)
}
end
Expand All @@ -105,12 +111,18 @@
context 'with pin', if: facts[:os]['family'] == 'Debian' do
let(:params) { { repos_ensure: true, package_apt_pin: '700' } }

if Puppet.version =~ %r{^6} # https://tickets.puppetlabs.com/browse/PUP-9112 and https://tickets.puppetlabs.com/browse/PUP-9180
let(:expected_key_apt_source_key_content) { 'nil' }
else
let(:expected_key_apt_source_key_content) { ':undef' }
end

describe 'it sets up an apt::source and pin' do
it {
is_expected.to contain_apt__source('rabbitmq').with(
'location' => "https://packagecloud.io/rabbitmq/rabbitmq-server/#{facts[:os]['name'].downcase}",
'repos' => 'main',
'key' => '{"id"=>"418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB", "source"=>"https://packagecloud.io/gpg.key", "content"=>:undef}'
'key' => "{\"id\"=>\"418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB\", \"source\"=>\"https://packagecloud.io/gpg.key\", \"content\"=>#{expected_key_apt_source_key_content}}"
)
}

Expand Down
1 change: 0 additions & 1 deletion spec/default_facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# Hint if using with rspec-puppet-facts ("on_supported_os.each"):
# if a same named fact exists in facterdb it will be overridden.
---
concat_basedir: "/tmp"
ipaddress: "172.16.254.254"
is_pe: false
macaddress: "AA:AA:AA:AA:AA:AA"
23 changes: 13 additions & 10 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'
include RspecPuppetFacts

# This file is managed via modulesync
# https://github.com/voxpupuli/modulesync
# https://github.com/voxpupuli/modulesync_config
RSpec.configure do |c|
c.mock_with :mocha
end

require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'
include RspecPuppetFacts

if Dir.exist?(File.expand_path('../../lib', __FILE__))
require 'coveralls'
Expand All @@ -23,15 +26,15 @@
end

RSpec.configure do |c|
default_facts = {
puppetversion: Puppet.version,
facterversion: Facter.version
}
default_facts = {}
default_facts.merge!(YAML.load(File.read(File.expand_path('../default_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_facts.yml', __FILE__))
default_facts.merge!(YAML.load(File.read(File.expand_path('../default_module_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_module_facts.yml', __FILE__))
c.default_facts = default_facts
c.mock_with :rspec

# Coverage generation
c.after(:suite) do
RSpec::Puppet::Coverage.report!
end
end

require 'spec_helper_local'
# vim: syntax=ruby
19 changes: 5 additions & 14 deletions spec/unit/facter/util/fact_erl_ssl_path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,24 @@

describe 'erl_ssl_path' do
context 'with valid value' do
before do
allow(Facter::Util::Resolution).to receive(:which).with('erl') { true }
allow(Facter::Core::Execution).to receive(:execute).with("erl -eval 'io:format(\"~p\", [code:lib_dir(ssl, ebin)]),halt().' -noshell") { '"/usr/lib64/erlang/lib/ssl-5.3.3/ebin"' }
end

it do
Facter::Util::Resolution.expects(:which).with('erl').returns(true)
Facter::Core::Execution.expects(:execute).with("erl -eval 'io:format(\"~p\", [code:lib_dir(ssl, ebin)]),halt().' -noshell").returns('"/usr/lib64/erlang/lib/ssl-5.3.3/ebin"')
expect(Facter.fact(:erl_ssl_path).value).to eq('/usr/lib64/erlang/lib/ssl-5.3.3/ebin')
end
end

context 'with error message' do
before do
allow(Facter::Util::Resolution).to receive(:which).with('erl') { true }
allow(Facter::Core::Execution).to receive(:execute).with("erl -eval 'io:format(\"~p\", [code:lib_dir(ssl, ebin)]),halt().' -noshell") { '{error,bad_name}' }
end

it do
Facter::Util::Resolution.expects(:which).with('erl').returns(true)
Facter::Core::Execution.expects(:execute).with("erl -eval 'io:format(\"~p\", [code:lib_dir(ssl, ebin)]),halt().' -noshell").returns('{error,bad_name}')
expect(Facter.fact(:erl_ssl_path).value).to be_nil
end
end

context 'with erl not present' do
before do
allow(Facter::Util::Resolution).to receive(:which).with('erl') { false }
end

it do
Facter::Util::Resolution.expects(:which).with('erl').returns(false)
expect(Facter.fact(:erl_ssl_path).value).to be_nil
end
end
Expand Down
42 changes: 14 additions & 28 deletions spec/unit/facter/util/fact_rabbitmq_nodename_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,47 @@

describe 'rabbitmq_nodename' do
context 'with value' do
before do
allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl') { true }
allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1') { 'Status of node monty@rabbit1 ...' }
end
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node monty@rabbit1 ...')
expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit1')
end
end

context 'with dashes in hostname' do
before do
allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl') { true }
allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1') { 'Status of node monty@rabbit-1 ...' }
end
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node monty@rabbit-1 ...')
expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1')
end
end

context 'with dashes in nodename/hostname' do
before do
allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl') { true }
allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1') { 'Status of node monty-python@rabbit-1 ...' }
end
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node monty-python@rabbit-1 ...')
expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty-python@rabbit-1')
end
end

context 'with quotes around node name' do
before do
allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl') { true }
allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1') { 'Status of node \'monty@rabbit-1\' ...' }
end
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node \'monty@rabbit-1\' ...')
expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1')
end
end

context 'without trailing points' do
before do
allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl') { true }
allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1') { 'Status of node monty@rabbit-1' }
end
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node monty@rabbit-1')
expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1')
end
end

context 'rabbitmq is not running' do
before do
it do
error_string = <<-EOS
Status of node 'monty@rabbit-1' ...
Error: unable to connect to node 'monty@rabbit-1': nodedown
Expand All @@ -77,19 +67,15 @@
- cookie hash: 6WdP0nl6d3HYqA5vTKMkIg==
EOS
allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl') { true }
allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1') { error_string }
end
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns(error_string)
expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1')
end
end

context 'rabbitmqctl is not in path' do
before do
allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl') { false }
end
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(false)
expect(Facter.fact(:rabbitmq_nodename).value).to be_nil
end
end
Expand Down
Loading

0 comments on commit c8947e3

Please sign in to comment.