Merge pull request #33 from voxpupuli/modulesync

modulesync 5.2.0
This commit is contained in:
Tim Meusel 2022-03-11 23:26:19 +01:00 committed by GitHub
commit 9943e6457c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 52 additions and 109 deletions

View File

@ -124,7 +124,7 @@ If you have Ruby 2.x or want a specific version of Puppet,
you must set an environment variable such as: you must set an environment variable such as:
```sh ```sh
export PUPPET_VERSION="~> 5.5.6" export PUPPET_GEM_VERSION="~> 6.1.0"
``` ```
You can install all needed gems for spec tests into the modules directory by You can install all needed gems for spec tests into the modules directory by
@ -232,17 +232,16 @@ simple tests against it after applying the module. You can run this
with: with:
```sh ```sh
BEAKER_setfile=debian10-x64 bundle exec rake beaker BEAKER_setfile=debian11-64 bundle exec rake beaker
``` ```
You can replace the string `debian10` with any common operating system. You can replace the string `debian10` with any common operating system.
The following strings are known to work: The following strings are known to work:
* ubuntu1604
* ubuntu1804 * ubuntu1804
* ubuntu2004 * ubuntu2004
* debian9
* debian10 * debian10
* debian11
* centos7 * centos7
* centos8 * centos8

View File

@ -7,60 +7,10 @@ name: CI
on: pull_request on: pull_request
concurrency: concurrency:
group: ${{ github.head_ref }} group: ${{ github.ref_name }}
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
setup_matrix: puppet:
name: 'Setup Test Matrix' name: Puppet
runs-on: ubuntu-latest uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v1
timeout-minutes: 40
outputs:
puppet_unit_test_matrix: ${{ steps.get-outputs.outputs.puppet_unit_test_matrix }}
github_action_test_matrix: ${{ steps.get-outputs.outputs.github_action_test_matrix }}
env:
BUNDLE_WITHOUT: development:system_tests:release
steps:
- uses: actions/checkout@v2
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: true
- name: Run static validations
run: bundle exec rake validate lint check
- name: Run rake rubocop
run: bundle exec rake rubocop
- name: Setup Test Matrix
id: get-outputs
run: bundle exec metadata2gha --use-fqdn --pidfile-workaround false
unit:
needs: setup_matrix
runs-on: ubuntu-latest
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
include: ${{fromJson(needs.setup_matrix.outputs.puppet_unit_test_matrix)}}
env:
BUNDLE_WITHOUT: development:system_tests:release
PUPPET_VERSION: "~> ${{ matrix.puppet }}.0"
name: Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }})
steps:
- uses: actions/checkout@v2
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
run: bundle exec rake parallel_spec
tests:
needs:
- unit
runs-on: ubuntu-latest
name: Test suite
steps:
- run: echo Test suite completed

View File

@ -9,26 +9,14 @@ on:
tags: tags:
- '*' - '*'
env:
BUNDLE_WITHOUT: development:test:system_tests
jobs: jobs:
deploy: release:
name: 'deploy to forge' name: Release
runs-on: ubuntu-latest uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v1
if: github.repository_owner == 'voxpupuli'
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with: with:
ruby-version: '2.7' allowed_owner: 'voxpupuli'
bundler-cache: true secrets:
- name: Build and Deploy
env:
# Configure secrets here: # Configure secrets here:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets # https://docs.github.com/en/actions/security-guides/encrypted-secrets
BLACKSMITH_FORGE_USERNAME: '${{ secrets.PUPPET_FORGE_USERNAME }}' username: ${{ secrets.PUPPET_FORGE_USERNAME }}
BLACKSMITH_FORGE_API_KEY: '${{ secrets.PUPPET_FORGE_API_KEY }}' api_key: ${{ secrets.PUPPET_FORGE_API_KEY }}
run: bundle exec rake module:push

View File

@ -2,4 +2,4 @@
# Managed by modulesync - DO NOT EDIT # Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
modulesync_config_version: '4.2.0' modulesync_config_version: '5.2.0'

3
.puppet-lint.rc Normal file
View File

@ -0,0 +1,3 @@
--fail-on-warnings
--no-parameter_documentation-check
--no-parameter_types-check

View File

@ -8,7 +8,7 @@ WORKDIR /opt/puppet
# https://github.com/puppetlabs/puppet/blob/06ad255754a38f22fb3a22c7c4f1e2ce453d01cb/lib/puppet/provider/service/runit.rb#L39 # https://github.com/puppetlabs/puppet/blob/06ad255754a38f22fb3a22c7c4f1e2ce453d01cb/lib/puppet/provider/service/runit.rb#L39
RUN mkdir -p /etc/sv RUN mkdir -p /etc/sv
ARG PUPPET_VERSION="~> 6.0" ARG PUPPET_GEM_VERSION="~> 6.0"
ARG PARALLEL_TEST_PROCESSORS=4 ARG PARALLEL_TEST_PROCESSORS=4
# Cache gems # Cache gems

View File

@ -1,10 +1,10 @@
# Managed by modulesync - DO NOT EDIT # Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
source ENV['GEM_SOURCE'] || "https://rubygems.org" source ENV['GEM_SOURCE'] || 'https://rubygems.org'
group :test do group :test do
gem 'voxpupuli-test', '~> 2.5', :require => false gem 'voxpupuli-test', '~> 5.0', :require => false
gem 'coveralls', :require => false gem 'coveralls', :require => false
gem 'simplecov-console', :require => false gem 'simplecov-console', :require => false
gem 'puppet_metadata', '~> 1.0', :require => false gem 'puppet_metadata', '~> 1.0', :require => false
@ -21,7 +21,7 @@ end
group :release do group :release do
gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5' gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5'
gem 'voxpupuli-release', '>= 1.0.2', :require => false gem 'voxpupuli-release', '>= 1.2.0', :require => false
gem 'puppet-strings', '>= 2.2', :require => false gem 'puppet-strings', '>= 2.2', :require => false
end end
@ -37,7 +37,7 @@ end
gem 'rake', :require => false gem 'rake', :require => false
gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test]
puppetversion = ENV['PUPPET_VERSION'] || '>= 6.0' puppetversion = ENV['PUPPET_GEM_VERSION'] || '>= 6.0'
gem 'puppet', puppetversion, :require => false, :groups => [:test] gem 'puppet', puppetversion, :require => false, :groups => [:test]
# vim: syntax=ruby # vim: syntax=ruby

View File

@ -1,7 +1,7 @@
# Managed by modulesync - DO NOT EDIT # Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
# Attempt to load voxupuli-test (which pulls in puppetlabs_spec_helper), # Attempt to load voxpupuli-test (which pulls in puppetlabs_spec_helper),
# otherwise attempt to load it directly. # otherwise attempt to load it directly.
begin begin
require 'voxpupuli/test/rake' require 'voxpupuli/test/rake'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Provides a query interface to an LDAP server # Provides a query interface to an LDAP server
# #
# @example simple query # @example simple query
@ -10,16 +12,13 @@ require_relative '../../../puppet_x/ldapquery'
begin begin
require 'net/ldap' require 'net/ldap'
rescue rescue StandardError
Puppet.warn('Missing net/ldap gem required for ldapquery() function') Puppet.warn('Missing net/ldap gem required for ldapquery() function')
end end
Puppet::Parser::Functions.newfunction(:ldapquery, Puppet::Parser::Functions.newfunction(:ldapquery,
type: :rvalue) do |args| type: :rvalue) do |args|
raise Puppet::ParseError, 'Too many arguments received in ldapquery()' if args.size > 3
if args.size > 3
raise Puppet::ParseError, 'Too many arguments received in ldapquery()'
end
filter, attributes, opts = args filter, attributes, opts = args

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Class: PuppetX::LDAPquery # Class: PuppetX::LDAPquery
# #
@ -19,11 +21,12 @@ module PuppetX
return unless scope return unless scope
if scope == 'sub' case scope
when 'sub'
@scope = Net::LDAP::SearchScope_WholeSubtree @scope = Net::LDAP::SearchScope_WholeSubtree
elsif scope == 'base' when 'base'
@scope = Net::LDAP::SearchScope_BaseObject @scope = Net::LDAP::SearchScope_BaseObject
elsif scope == 'single' when 'single'
@scope = Net::LDAP::SearchScope_SingleLevel @scope = Net::LDAP::SearchScope_SingleLevel
else else
raise Puppet::ParseError, 'Received param "scope" not one of ["sub","base","single"]' raise Puppet::ParseError, 'Received param "scope" not one of ["sub","base","single"]'
@ -32,15 +35,13 @@ module PuppetX
def ldap_config def ldap_config
# Load the configuration variables from Puppet # Load the configuration variables from Puppet
required_vars = [ required_vars = %i[
:ldapserver, ldapserver
:ldapport ldapport
] ]
required_vars.each do |r| required_vars.each do |r|
unless Puppet[r] raise Puppet::ParseError, "Missing required setting '#{r}' in puppet.conf" unless Puppet[r]
raise Puppet::ParseError, "Missing required setting '#{r}' in puppet.conf"
end
end end
port = Puppet[:ldapport] port = Puppet[:ldapport]
@ -112,11 +113,11 @@ module PuppetX
time_delta = format('%.3f', end_time - start_time) time_delta = format('%.3f', end_time - start_time)
Puppet.debug("ldapquery(): Searching #{@base} for #{@attributes} using #{@filter} took #{time_delta} seconds and returned #{entries.length} results") Puppet.debug("ldapquery(): Searching #{@base} for #{@attributes} using #{@filter} took #{time_delta} seconds and returned #{entries.length} results")
return entries entries
rescue Net::LDAP::LdapError => e rescue Net::LDAP::LdapError => e
Puppet.debug("There was an error searching LDAP #{e.message}") Puppet.debug("There was an error searching LDAP #{e.message}")
Puppet.debug('Returning false') Puppet.debug('Returning false')
return false false
end end
end end

View File

@ -1,17 +1,17 @@
# frozen_string_literal: true
# Managed by modulesync - DO NOT EDIT # Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
# puppetlabs_spec_helper will set up coverage if the env variable is set. # puppetlabs_spec_helper will set up coverage if the env variable is set.
# We want to do this if lib exists and it hasn't been explicitly set. # We want to do this if lib exists and it hasn't been explicitly set.
ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__)) ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../lib', __dir__))
require 'voxpupuli/test/spec_helper' require 'voxpupuli/test/spec_helper'
if File.exist?(File.join(__dir__, 'default_module_facts.yml')) if File.exist?(File.join(__dir__, 'default_module_facts.yml'))
facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml')))
if facts facts&.each do |name, value|
facts.each do |name, value|
add_custom_fact name.to_sym, value add_custom_fact name.to_sym, value
end end
end end
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
require 'puppet_x/ldapquery' require 'puppet_x/ldapquery'
require 'net/ldap' require 'net/ldap'
@ -20,7 +22,7 @@ describe 'PuppetX::LDAPquery' do
it 'fails with no filter' do it 'fails with no filter' do
filter = '' filter = ''
attributes = ['uid'] attributes = ['uid']
expect { PuppetX::LDAPquery.new(filter, attributes).results }.to raise_error expect { PuppetX::LDAPquery.new(filter, attributes).results }.to raise_error # rubocop:disable RSpec/UnspecifiedException
end end
it 'does not fail when using defaults in puppet.conf' do it 'does not fail when using defaults in puppet.conf' do
@ -56,6 +58,7 @@ describe 'PuppetX::LDAPquery' do
allow(l).to receive(:entries).and_return(entries) allow(l).to receive(:entries).and_return(entries)
expect(l.results).to eq(wanted) expect(l.results).to eq(wanted)
end end
it 'returns the attributes without new lines' do it 'returns the attributes without new lines' do
filter = '(uid=zach)' filter = '(uid=zach)'
attributes = ['sshPublicKey'] attributes = ['sshPublicKey']