Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honor package removal #67

Merged
merged 4 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ pup6.x-fips:
<<: *acceptance_base
script:
- 'BEAKER_fips=yes bundle exec rake beaker:suites[default,default]'
timeout: 2h

pup6.pe:
<<: *pup_6_pe
Expand All @@ -367,6 +368,7 @@ pup6.pe-fips:
<<: *acceptance_base
script:
- 'BEAKER_fips=yes bundle exec rake beaker:suites[default,default]'
timeout: 2h

pup7.x:
<<: *pup_7_x
Expand Down
170 changes: 170 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
---
require:
- rubocop-rspec
- rubocop-i18n
AllCops:
DisplayCopNames: true
TargetRubyVersion: '2.6'
Include:
- "**/*.rb"
Exclude:
- bin/*
- ".vendor/**/*"
- "**/Gemfile"
- "**/Rakefile"
- pkg/**/*
- spec/fixtures/**/*
- vendor/**/*
- "**/Puppetfile"
- "**/Vagrantfile"
- "**/Guardfile"
Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true
Layout/LineLength:
Description: People have wide screens, use them.
Max: 200
Layout/SpaceAroundMethodCallOperator:
Enabled: true
Lint/RaiseException:
Enabled: true
Lint/StructNewOverride:
Enabled: false
I18n/GetText:
Enabled: false
I18n/GetText/DecorateString:
Description: We don't want to decorate test output.
Exclude:
- spec/**/*
Enabled: false
Naming/AccessorMethodName:
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.
Exclude:
- spec/acceptance/**/*.rb
RSpec/ExpectInHook:
Exclude:
- spec/unit/**/*.rb
RSpec/HookArgument:
Description: Prefer explicit :each argument, matching existing module's style
EnforcedStyle: each
RSpec/NamedSubject:
Exclude:
- spec/classes/**/*
- spec/defines/**/*
Style/BlockDelimiters:
Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
be consistent then.
EnforcedStyle: braces_for_chaining
Style/ClassAndModuleChildren:
Description: Compact style reduces the required amount of indentation.
EnforcedStyle: compact
Style/EmptyElse:
Description: Enforce against empty else clauses, but allow `nil` for clarity.
EnforcedStyle: empty
Style/ExponentialNotation:
Enabled: true
Style/FormatString:
Description: Following the main puppet project's style, prefer the % format format.
EnforcedStyle: percent
Style/FormatStringToken:
Description: Following the main puppet project's style, prefer the simpler template
tokens over annotated ones.
EnforcedStyle: template
Style/HashEachMethods:
Enabled: true
Style/HashSyntax:
Enabled: false
Style/HashTransformKeys:
Enabled: false
Style/HashTransformValues:
Enabled: true
Style/Lambda:
Description: Prefer the keyword for easier discoverability.
EnforcedStyle: literal
Style/MixinUsage:
Exclude:
- spec/**/*
Style/RedundantBegin:
Enabled: false
Style/RegexpLiteral:
Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168
EnforcedStyle: percent_r
Style/TernaryParentheses:
Description: Checks for use of parentheses around ternary conditions. Enforce parentheses
on complex expressions for better readability, but seriously consider breaking
it up.
EnforcedStyle: require_parentheses_when_complex
Style/TrailingCommaInArguments:
Description: Prefer always trailing comma on multiline argument lists. This makes
diffs, and re-ordering nicer.
EnforcedStyleForMultiline: comma
Style/TrailingCommaInArrayLiteral:
Description: Prefer always trailing comma on multiline literals. This makes diffs,
and re-ordering nicer.
EnforcedStyleForMultiline: comma
Style/SlicingWithRange:
Enabled: true
Style/SymbolArray:
Description: Using percent style obscures symbolic intent of array's contents.
EnforcedStyle: brackets
RSpec/MessageSpies:
EnforcedStyle: receive
Style/Documentation:
Exclude:
- lib/puppet/parser/functions/**/*
- spec/**/*
Style/WordArray:
EnforcedStyle: brackets
Style/CollectionMethods:
Enabled: true
Style/MethodCalledOnDoEndBlock:
Enabled: true
Style/StringMethods:
Enabled: true
I18n/GetText/DecorateFunctionMessage:
Enabled: false
I18n/GetText/DecorateStringFormattingUsingInterpolation:
Enabled: false
I18n/GetText/DecorateStringFormattingUsingPercent:
Enabled: false
Layout/EndOfLine:
Enabled: false
Layout/HeredocIndentation:
Enabled: false
Metrics/AbcSize:
Enabled: false
Metrics/BlockLength:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/MethodLength:
Enabled: false
Metrics/ModuleLength:
Enabled: false
Metrics/ParameterLists:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
RSpec/DescribeClass:
Enabled: false
RSpec/ExampleLength:
Enabled: false
RSpec/MessageExpectation:
Enabled: false
RSpec/MultipleExpectations:
Enabled: false
RSpec/MultipleMemoizedHelpers:
Enabled: false
RSpec/NestedGroups:
Enabled: false
Style/AsciiComments:
Enabled: false
Style/IfUnlessModifier:
Enabled: false
Style/SymbolProc:
Enabled: false
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* Fri May 20 2022 Trevor Vaughan <[email protected]> - 4.3.1
- Ensure that the module does not manage files if the package is being removed

* Thu Jun 17 2021 Chris Tessmer <[email protected]> - 4.3.0
- Removed support for Puppet 5
- Ensured support for Puppet 7 in requirements and stdlib
Expand Down
66 changes: 34 additions & 32 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -58,42 +58,44 @@
String[1] $package_ensure = simplib::lookup('simp_options::package_ensure', { 'default_value' => 'installed' }),
) {

#TODO Fix the inconsistent use of strings versus arrays. Some of these
# config items are strings that contain a space-separated list of items.
xinetd::validate_log_type($log_type)
if $x_bind { simplib::validate_net_list($x_bind) }
if $no_access { simplib::validate_net_list($no_access) }
package { 'xinetd':
ensure => $package_ensure
}

$_only_from = simplib::nets2cidr($trusted_nets)
unless $package_ensure == 'absent' {
#TODO Fix the inconsistent use of strings versus arrays. Some of these
# config items are strings that contain a space-separated list of items.
op-ct marked this conversation as resolved.
Show resolved Hide resolved
xinetd::validate_log_type($log_type)
if $x_bind { simplib::validate_net_list($x_bind) }
if $no_access { simplib::validate_net_list($no_access) }

file { '/etc/xinetd.conf':
owner => 'root',
group => 'root',
mode => '0600',
content => template('xinetd/xinetd.conf.erb'),
notify => [ Service['xinetd'] ],
require => Package['xinetd']
}
$_only_from = simplib::nets2cidr($trusted_nets)

file { '/etc/xinetd.d':
ensure => 'directory',
owner => 'root',
group => 'root',
mode => '0640',
recurse => true,
purge => $purge,
require => Package['xinetd']
}
file { '/etc/xinetd.conf':
owner => 'root',
group => 'root',
mode => '0600',
content => template('xinetd/xinetd.conf.erb'),
notify => [ Service['xinetd'] ],
require => Package['xinetd']
}

package { 'xinetd':
ensure => $package_ensure
}
file { '/etc/xinetd.d':
ensure => 'directory',
owner => 'root',
group => 'root',
mode => '0640',
recurse => true,
purge => $purge,
require => Package['xinetd']
}

service { 'xinetd':
ensure => 'running',
enable => true,
hasstatus => true,
restart => '( /bin/ps -C xinetd && /sbin/service xinetd reload ) || /sbin/service xinetd start',
require => Package['xinetd']
service { 'xinetd':
ensure => 'running',
enable => true,
hasstatus => true,
restart => '( /bin/ps -C xinetd && /sbin/service xinetd reload ) || /sbin/service xinetd start',
require => Package['xinetd']
}
}
}
84 changes: 43 additions & 41 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -110,62 +110,64 @@
Boolean $firewall = simplib::lookup('simp_options::firewall', { 'default_value' => false }),
Boolean $tcpwrappers = simplib::lookup('simp_options::tcpwrappers', { 'default_value' => false })
) {
xinetd::validate_log_type($log_type)
include 'xinetd'

if ($redirect_ip and $redirect_port) { simplib::validate_net_list("${redirect_ip}:${redirect_port}") }
if $x_bind { simplib::validate_net_list($x_bind) }
unless $xinetd::package_ensure == 'absent' {

$_only_from = simplib::nets2cidr($trusted_nets)
xinetd::validate_log_type($log_type)

include 'xinetd'
if ($redirect_ip and $redirect_port) { simplib::validate_net_list("${redirect_ip}:${redirect_port}") }
if $x_bind { simplib::validate_net_list($x_bind) }

file { "/etc/xinetd.d/${name}":
owner => 'root',
group => 'root',
mode => '0640',
content => template('xinetd/xinetd.service.erb'),
notify => Service['xinetd']
}
$_only_from = simplib::nets2cidr($trusted_nets)

if $firewall {
simplib::assert_optional_dependency($module_name, 'simp/iptables')
file { "/etc/xinetd.d/${name}":
owner => 'root',
group => 'root',
mode => '0640',
content => template('xinetd/xinetd.service.erb'),
notify => Service['xinetd']
}

include 'iptables'
case $protocol {
'tcp': {
iptables::listen::tcp_stateful { "allow_${name}":
order => 11,
trusted_nets => $trusted_nets,
dports => $port
if $firewall {
simplib::assert_optional_dependency($module_name, 'simp/iptables')

include 'iptables'
case $protocol {
'tcp': {
iptables::listen::tcp_stateful { "allow_${name}":
order => 11,
trusted_nets => $trusted_nets,
dports => $port
}
}
}
'udp': {
iptables::listen::udp { "allow_${name}":
order => 11,
trusted_nets => $trusted_nets,
dports => $port
'udp': {
iptables::listen::udp { "allow_${name}":
order => 11,
trusted_nets => $trusted_nets,
dports => $port
}
}
default: {
}
}
default: {
}
}
}

if $tcpwrappers {
simplib::assert_optional_dependency($module_name, 'simp/tcpwrappers')
if $tcpwrappers {
simplib::assert_optional_dependency($module_name, 'simp/tcpwrappers')

include 'tcpwrappers'
include 'tcpwrappers'

if $libwrap_name {
tcpwrappers::allow { $libwrap_name:
pattern => $trusted_nets
if $libwrap_name {
tcpwrappers::allow { $libwrap_name:
pattern => $trusted_nets
}
}
}
else {
tcpwrappers::allow { $name:
pattern => $trusted_nets
else {
tcpwrappers::allow { $name:
pattern => $trusted_nets
}
}
}
}

}
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simp-xinetd",
"version": "4.3.0",
"version": "4.3.1",
"author": "SIMP Team",
"summary": "Manages xinetd",
"license": "Apache-2.0",
Expand Down
Loading