Skip to content

Commit

Permalink
Merge pull request voxpupuli#1 from voxpupuli/master
Browse files Browse the repository at this point in the history
pull from original source
  • Loading branch information
basti-nis authored May 5, 2020
2 parents edbfa09 + deaab21 commit e85b6e8
Show file tree
Hide file tree
Showing 27 changed files with 354 additions and 344 deletions.
5 changes: 4 additions & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fixtures:
repositories:
apt: 'https://github.com/puppetlabs/puppetlabs-apt.git'
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
epel: 'https://github.com/stahnma/puppet-module-epel.git'
epel: 'https://github.com/voxpupuli/puppet-epel.git'
augeasproviders_sysctl: 'https://github.com/hercules-team/augeasproviders_sysctl.git'
augeasproviders_core: 'https://github.com/hercules-team/augeasproviders_core.git'
augeas_core:
Expand All @@ -11,3 +11,6 @@ fixtures:
yumrepo_core:
repo: "https://github.com/puppetlabs/puppetlabs-yumrepo_core"
puppet_version: ">= 6.0.0"
systemd:
repo: 'https://github.com/camptocamp/puppet-systemd.git'
puppet_version: "< 6.1.0"
6 changes: 4 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,18 +256,20 @@ Beaker also supports docker containers. We also use that in our automated CI
pipeline at [travis-ci](http://travis-ci.org). To use that instead of Vagrant:

```sh
PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian9-64{hypervisor=docker} BEAKER_destroy=yes bundle exec rake beaker
PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian10-64{hypervisor=docker} BEAKER_destroy=yes bundle exec rake beaker
```

You can replace the string `debian9` with any common operating system.
You can replace the string `debian10` with any common operating system.
The following strings are known to work:

* ubuntu1604
* ubuntu1804
* debian8
* debian9
* debian10
* centos6
* centos7
* centos8

The easiest way to debug in a docker container is to open a shell:

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.9.0'
modulesync_config_version: '2.12.0'
3 changes: 2 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require: rubocop-rspec
AllCops:
TargetRubyVersion: 2.1
# Puppet Server 5 defaults to jruby 1.7 so TargetRubyVersion must stay at 1.9 until we drop support for puppet 5
TargetRubyVersion: 1.9
Include:
- ./**/*.rb
Exclude:
Expand Down
2 changes: 2 additions & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
- set: ubuntu1804-64m
- set: centos6-64m
- set: centos7-64m
- set: centos8-64m
- set: debian9-64m
- set: debian10-64m
Gemfile:
optional:
':test':
Expand Down
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ matrix:
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos7-64m BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
- rvm: 2.5.3
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos8-64m BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
- rvm: 2.5.3
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos8-64m BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
- rvm: 2.5.3
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian9-64m BEAKER_HYPERVISOR=docker CHECK=beaker
Expand All @@ -62,12 +70,21 @@ matrix:
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian9-64m BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
- rvm: 2.5.3
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian10-64m BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
- rvm: 2.5.3
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian10-64m BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
branches:
only:
- master
- /^v\d/
notifications:
email: false
webhooks: https://voxpupu.li/incoming/travis
irc:
on_success: always
on_failure: always
Expand Down
29 changes: 6 additions & 23 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,11 @@ def location_for(place, fake_version = nil)
end

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', :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
gem 'redis', :require => false
gem 'mock_redis', :require => false
gem 'voxpupuli-test', '>= 1.0.0', :require => false
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
gem 'redis', :require => false
gem 'mock_redis', :require => false
end

group :development do
Expand Down Expand Up @@ -64,6 +46,7 @@ group :system_tests do
gem 'rbnacl', '>= 4', :require => false
gem 'rbnacl-libsodium', :require => false
gem 'bcrypt_pbkdf', :require => false
gem 'ed25519', :require => false
end

group :release do
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,33 @@ class { '::redis':
}
```

### Multiple instances


```puppet
$listening_ports = [6379,6380,6381,6382]
class { '::redis':
default_install => false,
service_enable => false,
service_ensure => 'stopped',
}
$listening_ports.each |$port| {
$port_string = sprintf('%d',$port)
redis::instance { $port_string:
service_enable => true,
service_ensure => 'running',
port => $port,
bind => $facts['networking']['ip'],
dbfilename => "${port}-dump.rdb",
appendfilename => "${port}-appendonly.aof",
appendfsync => 'always',
require => Class['Redis'],
}
}
```

### Manage repositories

Disabled by default but if you really want the module to manage the required
Expand Down Expand Up @@ -104,6 +131,10 @@ class { '::redis::sentinel':
}
```

### Soft dependency

This module requires `camptocamp/systemd` on Puppet versions older than 6.1.0.

## `redis::get()` function

This function is used to get data from redis.
Expand Down
43 changes: 1 addition & 42 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'voxpupuli/test/rake'

# load optional tasks for releases
# only available if gem group releases is installed
Expand All @@ -7,47 +7,6 @@ begin
rescue LoadError
end

PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}'
PuppetLint.configuration.absolute_classname_reverse = true

exclude_paths = %w(
pkg/**/*
vendor/**/*
.vendor/**/*
spec/**/*
)
PuppetLint.configuration.ignore_paths = exclude_paths
PuppetSyntax.exclude_paths = exclude_paths

desc 'Auto-correct puppet-lint offenses'
task 'lint:auto_correct' do
Rake::Task[:lint_fix].invoke
end

desc 'Run acceptance tests'
RSpec::Core::RakeTask.new(:acceptance) do |t|
t.pattern = 'spec/acceptance'
end

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']

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__))
Expand Down
6 changes: 0 additions & 6 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,4 @@
~> Class['redis::service']
}

exec { 'systemd-reload-redis':
command => 'systemctl daemon-reload',
refreshonly => true,
path => '/bin:/usr/bin:/usr/local/bin',
}

}
9 changes: 7 additions & 2 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@
Variant[Stdlib::Absolutepath, Enum['']] $unixsocket = "/var/run/redis/redis-server-${name}.sock",
Stdlib::Absolutepath $workdir = "${redis::workdir}/redis-server-${name}",
) {

if $title == 'default' {
$redis_file_name_orig = $config_file_orig
$redis_file_name = $config_file
Expand Down Expand Up @@ -330,7 +329,13 @@
mode => '0644',
content => template('redis/service_templates/redis.service.erb'),
}
~> Exec['systemd-reload-redis']

# Only necessary for Puppet < 6.1.0,
# See https://github.com/puppetlabs/puppet/commit/f8d5c60ddb130c6429ff12736bfdb4ae669a9fd4
if versioncmp($facts['puppetversion'],'6.1.0') < 0 {
include systemd::systemctl::daemon_reload
File["/etc/systemd/system/${service_name}.service"] ~> Class['systemd::systemctl::daemon_reload']
}

if $title != 'default' {
service { $service_name:
Expand Down
10 changes: 9 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
$sentinel_daemonize = true
$sentinel_init_script = '/etc/init.d/redis-sentinel'
$sentinel_package_name = 'redis-sentinel'
$sentinel_pid_file = '/var/run/redis/redis-sentinel.pid'
$sentinel_log_file = '/var/log/redis/redis-sentinel.log'
$sentinel_working_dir = '/var/lib/redis'

Expand All @@ -34,10 +33,19 @@
'16.04' => '3.0.5',
default => '4.0.9',
}
$sentinel_pid_file = $facts['os']['release']['major'] ? {
'16.04' => '/var/run/redis/redis-sentinel.pid',
default => '/var/run/sentinel/redis-sentinel.pid',
}
}
default: {
$config_group = 'root'
$minimum_version = '3.2.5'
if versioncmp($facts['os']['release']['major'], '10') >= 0 {
$sentinel_pid_file = '/run/sentinel/redis-sentinel.pid'
} else {
$sentinel_pid_file = '/var/run/redis/redis-sentinel.pid'
}
}
}

Expand Down
9 changes: 6 additions & 3 deletions manifests/ulimit.pp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@
"defnode nofile Service/LimitNOFILE \"\"",
"set \$nofile/value \"${redis::ulimit}\"",
],
notify => [
Exec['systemd-reload-redis'],
],
}
# Only necessary for Puppet < 6.1.0,
# See https://github.com/puppetlabs/puppet/commit/f8d5c60ddb130c6429ff12736bfdb4ae669a9fd4
if versioncmp($facts['puppetversion'],'6.1.0') < 0 {
include systemd::systemctl::daemon_reload
Augeas['Systemd redis ulimit'] ~> Class['systemd::systemctl::daemon_reload']
}
} else {
case $facts['os']['family'] {
Expand Down
13 changes: 8 additions & 5 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"version_requirement": ">= 4.25.0 < 7.0.0"
},
{
"name": "stahnma/epel",
"version_requirement": ">= 1.2.2 < 2.0.0"
"name": "puppet/epel",
"version_requirement": ">= 3.0.0 < 4.0.0"
},
{
"name": "herculesteam/augeasproviders_sysctl",
Expand Down Expand Up @@ -47,7 +47,8 @@
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"9"
"9",
"10"
]
},
{
Expand All @@ -61,14 +62,16 @@
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"6",
"7"
"7",
"8"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"6",
"7"
"7",
"8"
]
},
{
Expand Down
Loading

0 comments on commit e85b6e8

Please sign in to comment.