Skip to content
Commits on Source (4)
......@@ -2,3 +2,4 @@
*.erb eol=lf
*.pp eol=lf
*.sh eol=lf
*.epp eol=lf
......@@ -10,7 +10,7 @@ cache:
before_script:
- bundle -v
- rm Gemfile.lock || true
- gem update --system
- gem update --system $RUBYGEMS_VERSION
- gem --version
- bundle -v
- bundle install --without system_tests --path vendor/bundle --jobs $(nproc)
......@@ -22,6 +22,7 @@ parallel_spec-Ruby 2.1.9-Puppet ~> 4.0:
- bundle exec rake parallel_spec
variables:
PUPPET_GEM_VERSION: '~> 4.0'
RUBYGEMS_VERSION: '2.7.8'
syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop-Ruby 2.4.4-Puppet ~> 5.5:
stage: syntax
......
......@@ -22,3 +22,16 @@
/convert_report.txt
/update_report.txt
.DS_Store
/appveyor.yml
/.fixtures.yml
/Gemfile
/.gitattributes
/.gitignore
/.gitlab-ci.yml
/.pdkignore
/Rakefile
/.rspec
/.rubocop.yml
/.travis.yml
/.yardopts
/spec/
......@@ -19,6 +19,10 @@ AllCops:
Metrics/LineLength:
Description: People have wide screens, use them.
Max: 200
GetText/DecorateString:
Description: We don't want to decorate test output.
Exclude:
- spec/*
RSpec/BeforeAfterAll:
Description: Beware of using after(:all) as it may cause state to leak between tests.
A necessary evil in acceptance testing.
......
---
sudo: false
dist: trusty
language: ruby
cache: bundler
before_install:
- bundle -v
- rm -f Gemfile.lock
- gem update --system
- gem update --system $RUBYGEMS_VERSION
- gem --version
- bundle -v
script:
- 'bundle exec rake $CHECK'
bundler_args: --without system_tests
rvm:
- 2.4.4
- 2.5.1
env:
global:
- BEAKER_PUPPET_COLLECTION=puppet5 PUPPET_GEM_VERSION="~> 5.0"
- BEAKER_PUPPET_COLLECTION=puppet6 PUPPET_GEM_VERSION="~> 6.0"
matrix:
fast_finish: true
include:
......@@ -25,8 +24,8 @@ matrix:
-
env: CHECK=parallel_spec
-
env: PUPPET_GEM_VERSION="~> 4.0" CHECK=parallel_spec
rvm: 2.1.9
env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec
rvm: 2.4.4
branches:
only:
- master
......
......@@ -2,6 +2,15 @@
All notable changes to this project will be documented in this file.
## Release 0.1.3
[Full Changelog](https://gitlab.com/arden-puppet/arden-account_management/compare/0.1.2...0.1.3#)
**Features**
* PDK 1.9.x config update
* Gentoo specific spec tests
* Correct compatibility with ensure_packages from puppet-stdlib
## Release 0.1.2
[Full Changelog](https://gitlab.com/arden-puppet/arden-account_management/compare/0.1.1...0.1.2#)
......
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
def location_for(place_or_version, fake_version = nil)
if place_or_version =~ %r{\A(git[:@][^#]*)#(.*)}
[fake_version, { git: Regexp.last_match(1), branch: Regexp.last_match(2), require: false }].compact
elsif place_or_version =~ %r{\Afile:\/\/(.*)}
['>= 0', { path: File.expand_path(Regexp.last_match(1)), require: false }]
else
[place_or_version, { require: false }]
end
end
git_url_regex = %r{\A(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?}
file_url_regex = %r{\Afile:\/\/(?<path>.*)}
def gem_type(place_or_version)
if place_or_version =~ %r{\Agit[:@]}
:git
elsif !place_or_version.nil? && place_or_version.start_with?('file:')
:file
if place_or_version && (git_url = place_or_version.match(git_url_regex))
[fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact
elsif place_or_version && (file_url = place_or_version.match(file_url_regex))
['>= 0', { path: File.expand_path(file_url[:path]), require: false }]
else
:gem
[place_or_version, { require: false }]
end
end
......@@ -28,7 +21,8 @@ group :development do
gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
gem "json", '<= 2.0.4', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.4.4')
gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby]
gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby]
gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
......@@ -36,7 +30,6 @@ group :development do
end
puppet_version = ENV['PUPPET_GEM_VERSION']
puppet_type = gem_type(puppet_version)
facter_version = ENV['FACTER_GEM_VERSION']
hiera_version = ENV['HIERA_GEM_VERSION']
......
......@@ -2,6 +2,7 @@ require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-syntax/tasks/puppet-syntax'
require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any?
require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any?
def changelog_user
return unless Rake.application.top_level_tasks.include? "changelog"
......
---
version: 1.1.x.{build}
branches:
only:
- master
skip_commits:
message: /^\(?doc\)?.*/
clone_depth: 10
......@@ -14,14 +17,6 @@ environment:
-
RUBY_VERSION: 24-x64
CHECK: syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop
-
PUPPET_GEM_VERSION: ~> 4.0
RUBY_VERSION: 21
CHECK: parallel_spec
-
PUPPET_GEM_VERSION: ~> 4.0
RUBY_VERSION: 21-x64
CHECK: parallel_spec
-
PUPPET_GEM_VERSION: ~> 5.0
RUBY_VERSION: 24
......@@ -30,6 +25,14 @@ environment:
PUPPET_GEM_VERSION: ~> 5.0
RUBY_VERSION: 24-x64
CHECK: parallel_spec
-
PUPPET_GEM_VERSION: ~> 6.0
RUBY_VERSION: 25
CHECK: parallel_spec
-
PUPPET_GEM_VERSION: ~> 6.0
RUBY_VERSION: 25-x64
CHECK: parallel_spec
matrix:
fast_finish: true
install:
......
......@@ -29,9 +29,8 @@ class account_management::shells {
$unique_shells.each | $shell_path | {
if $shell_path in $shell_package_map {
package { $shell_package_map[$shell_path]:
ensure => installed,
ensure => present,
}
} else {
}
}
}
{
"name": "arden-account_management",
"version": "0.1.2",
"version": "0.1.3",
"author": "Ben Royse",
"summary": "Creates users/groups and installs user's shell.",
"license": "MIT",
......@@ -55,7 +55,7 @@
"tags": [
"accounts"
],
"pdk-version": "1.7.0",
"pdk-version": "1.9.0",
"template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git",
"template-ref": "1.7.0-0-g57412ed"
"template-ref": "1.9.0-0-g7281db5"
}
......@@ -39,52 +39,52 @@ describe 'account_management' do
it { is_expected.to contain_class('account_management::users').that_requires('Class[account_management::shells]') }
# Make sure all user tasks are completed
describe 'account_management::users' do
it {
# Users required shell should be installed
is_expected.to contain_package('zsh').with(
'ensure' => 'installed',
)
it 'creates the correct users and groups' do
# User should be created with proper attributes
is_expected.to contain_user('rstallman').with(
'ensure' => 'present',
'comment' => 'Gnu/Linux',
'uid' => '1500',
'groups' => ['fsf', 'emacs'],
'shell' => '/bin/zsh',
)
# User should be created with proper attributes
is_expected.to contain_user('rstallman').with(
'ensure' => 'present',
'comment' => 'Gnu/Linux',
'uid' => '1500',
'groups' => ['fsf', 'emacs'],
'shell' => '/bin/zsh',
)
# User's primary group should be created with the
# proper gid
is_expected.to contain_group('rstallman').with(
'ensure' => 'present',
'gid' => '1500',
)
}
# User's primary group should be created with the
# proper gid
is_expected.to contain_group('rstallman').with(
'ensure' => 'present',
'gid' => '1500',
)
end
# Make sure the groups are created
describe 'account_management::groups' do
it {
is_expected.to contain_group('fsf').with(
'ensure' => 'present',
'gid' => '2000',
)
is_expected.to contain_group('emacs').with(
'ensure' => 'present',
'gid' => '2001',
)
}
it 'creates each additional group' do
is_expected.to contain_group('fsf').with(
'ensure' => 'present',
'gid' => '2000',
)
is_expected.to contain_group('emacs').with(
'ensure' => 'present',
'gid' => '2001',
)
end
# Test the shells
describe 'account_management::shells' do
it {
is_expected.to contain_package('zsh').with(
ensure: 'installed',
)
}
context 'deploys the correct shells' do
case os_facts[:osfamily]
when 'Gentoo'
it 'installs the Gentoo package' do
is_expected.to contain_package('app-shells/zsh').with(
ensure: 'present',
)
end
when 'RedHat'
it 'installs the RedHat package' do
is_expected.to contain_package('zsh').with(
ensure: 'present',
)
end
end
end
end
......
......@@ -2,7 +2,6 @@
#
# Facts specified here will override the values provided by rspec-puppet-facts.
---
concat_basedir: "/tmp"
ipaddress: "172.16.254.254"
is_pe: false
macaddress: "AA:AA:AA:AA:AA:AA"
require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'
begin
require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb'))
rescue LoadError => loaderror
warn "Could not require spec_helper_local: #{loaderror.message}"
end
require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb'))
include RspecPuppetFacts
......@@ -14,15 +10,19 @@ default_facts = {
facterversion: Facter.version,
}
default_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml'))
default_module_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml'))
default_fact_files = [
File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')),
File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')),
]
if File.exist?(default_facts_path) && File.readable?(default_facts_path)
default_facts.merge!(YAML.safe_load(File.read(default_facts_path)))
end
default_fact_files.each do |f|
next unless File.exist?(f) && File.readable?(f) && File.size?(f)
if File.exist?(default_module_facts_path) && File.readable?(default_module_facts_path)
default_facts.merge!(YAML.safe_load(File.read(default_module_facts_path)))
begin
default_facts.merge!(YAML.safe_load(File.read(f)))
rescue => e
RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}"
end
end
RSpec.configure do |c|
......@@ -32,12 +32,15 @@ RSpec.configure do |c|
# by default Puppet runs at warning level
Puppet.settings[:strict] = :warning
end
c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT']
c.after(:suite) do
end
end
def ensure_module_defined(module_name)
module_name.split('::').reduce(Object) do |last_module, next_module|
last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module)
last_module.const_get(next_module)
last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false)
last_module.const_get(next_module, false)
end
end
......