Showing with 170 additions and 139 deletions.
  1. +3 −4 .github/CONTRIBUTING.md
  2. +6 −78 .github/workflows/ci.yml
  3. +10 −22 .github/workflows/release.yml
  4. +1 −1 .msync.yml
  5. +17 −1 CHANGELOG.md
  6. +1 −1 Dockerfile
  7. +2 −2 Gemfile
  8. +16 −5 REFERENCE.md
  9. +6 −4 manifests/udev/rule.pp
  10. +16 −3 manifests/unit_file.pp
  11. +1 −1 metadata.json
  12. +42 −14 spec/defines/{udev_rules.spec → udev_rules_spec.rb}
  13. +49 −3 spec/defines/unit_file_spec.rb
7 changes: 3 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

```sh
export PUPPET_VERSION="~> 5.5.6"
export PUPPET_GEM_VERSION="~> 5.5.6"
```

You can install all needed gems for spec tests into the modules directory by
Expand Down Expand Up @@ -232,17 +232,16 @@ simple tests against it after applying the module. You can run this
with:

```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.
The following strings are known to work:

* ubuntu1604
* ubuntu1804
* ubuntu2004
* debian9
* debian10
* debian11
* centos7
* centos8

Expand Down
84 changes: 6 additions & 78 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,84 +7,12 @@ name: CI
on: pull_request

concurrency:
group: ${{ github.head_ref }}
group: ${{ github.ref_name }}
cancel-in-progress: true

jobs:
setup_matrix:
name: 'Setup Test Matrix'
runs-on: ubuntu-latest
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

acceptance:
needs: setup_matrix
runs-on: ubuntu-latest
env:
BUNDLE_WITHOUT: development:test:release
strategy:
fail-fast: false
matrix:
include: ${{fromJson(needs.setup_matrix.outputs.github_action_test_matrix)}}
name: ${{ matrix.puppet.name }} - ${{ matrix.setfile.name }}
steps:
- uses: actions/checkout@v2
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: true
- name: Run tests
run: bundle exec rake beaker
env:
BEAKER_PUPPET_COLLECTION: ${{ matrix.puppet.collection }}
BEAKER_setfile: ${{ matrix.setfile.value }}

tests:
needs:
- unit
- acceptance
runs-on: ubuntu-latest
name: Test suite
steps:
- run: echo Test suite completed
puppet:
name: Puppet
uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v1
with:
pidfile_workaround: 'false'
32 changes: 10 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,14 @@ on:
tags:
- '*'

env:
BUNDLE_WITHOUT: development:test:system_tests

jobs:
deploy:
name: 'deploy to forge'
runs-on: ubuntu-latest
if: github.repository_owner == 'voxpupuli'
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true
- name: Build and Deploy
env:
# Configure secrets here:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets
BLACKSMITH_FORGE_USERNAME: '${{ secrets.PUPPET_FORGE_USERNAME }}'
BLACKSMITH_FORGE_API_KEY: '${{ secrets.PUPPET_FORGE_API_KEY }}'
run: bundle exec rake module:push
release:
name: Release
uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v1
with:
allowed_owner: 'voxpupuli'
secrets:
# Configure secrets here:
# https://docs.github.com/en/actions/security-guides/encrypted-secrets
username: ${{ secrets.PUPPET_FORGE_USERNAME }}
api_key: ${{ secrets.PUPPET_FORGE_API_KEY }}
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

modulesync_config_version: '5.1.0'
modulesync_config_version: '5.2.0'
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,23 @@ All notable changes to this project will be documented in this file.
Each new release typically also includes the latest modulesync defaults.
These should not affect the functionality of the module.

## [v3.7.0](https://github.com/voxpupuli/puppet-systemd/tree/v3.7.0) (2022-02-22)
## [v3.8.0](https://github.com/voxpupuli/puppet-systemd/tree/v3.8.0) (2022-03-02)

[Full Changelog](https://github.com/voxpupuli/puppet-systemd/compare/v3.7.0...v3.8.0)

**Implemented enhancements:**

- dropin\_file: Implement service\_parameters hash [\#259](https://github.com/voxpupuli/puppet-systemd/pull/259) ([bastelfreak](https://github.com/bastelfreak))

**Fixed bugs:**

- systemd::udev::rule: param rules now defaults to `[]` / fix broken tests [\#260](https://github.com/voxpupuli/puppet-systemd/pull/260) ([bastelfreak](https://github.com/bastelfreak))

**Merged pull requests:**

- unit\_file: deprecate hasrestart/hasstatus params [\#261](https://github.com/voxpupuli/puppet-systemd/pull/261) ([bastelfreak](https://github.com/bastelfreak))

## [v3.7.0](https://github.com/voxpupuli/puppet-systemd/tree/v3.7.0) (2022-02-23)

[Full Changelog](https://github.com/voxpupuli/puppet-systemd/compare/v3.6.0...v3.7.0)

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WORKDIR /opt/puppet
# https://github.com/puppetlabs/puppet/blob/06ad255754a38f22fb3a22c7c4f1e2ce453d01cb/lib/puppet/provider/service/runit.rb#L39
RUN mkdir -p /etc/sv

ARG PUPPET_VERSION="~> 6.0"
ARG PUPPET_GEM_VERSION="~> 6.0"
ARG PARALLEL_TEST_PROCESSORS=4

# Cache gems
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Managed by modulesync - DO NOT EDIT
# 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
gem 'voxpupuli-test', '~> 5.0', :require => false
Expand All @@ -28,7 +28,7 @@ end
gem 'rake', :require => false
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]

# vim: syntax=ruby
21 changes: 16 additions & 5 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ Data type: `Enum['present', 'absent', 'file']`

Whether to drop a file or remove it

Default value: `'present'`
Default value: `'file'`

##### <a name="path"></a>`path`

Expand Down Expand Up @@ -1185,6 +1185,8 @@ Data type: `Array`

The literal udev rules you want to deploy

Default value: `[]`

### <a name="systemdunit_file"></a>`systemd::unit_file`

Creates a systemd unit file
Expand Down Expand Up @@ -1224,6 +1226,7 @@ The following parameters are available in the `systemd::unit_file` defined type:
* [`hasrestart`](#hasrestart)
* [`hasstatus`](#hasstatus)
* [`selinux_ignore_defaults`](#selinux_ignore_defaults)
* [`service_parameters`](#service_parameters)

##### <a name="name"></a>`name`

Expand Down Expand Up @@ -1337,17 +1340,17 @@ Default value: ``undef``

Data type: `Optional[Boolean]`

maps to the same param on the service resource. Optional in the module because it's optional in the service resource type
maps to the same param on the service resource. Optional in the module because it's optional in the service resource type. This param is deprecated. Set it via $service_parameters.

Default value: ``undef``

##### <a name="hasstatus"></a>`hasstatus`

Data type: `Boolean`
Data type: `Optional[Boolean]`

maps to the same param on the service resource. true in the module because it's true in the service resource type
maps to the same param on the service resource. true in the module because it's true in the service resource type. This param is deprecated. Set it via $service_parameters.

Default value: ``true``
Default value: ``undef``

##### <a name="selinux_ignore_defaults"></a>`selinux_ignore_defaults`

Expand All @@ -1357,6 +1360,14 @@ maps to the same param on the file resource for the unit. false in the module be

Default value: ``false``

##### <a name="service_parameters"></a>`service_parameters`

Data type: `Hash[String[1], Any]`

hash that will be passed with the splat operator to the service resource

Default value: `{}`

## Resource types

### <a name="loginctl_user"></a>`loginctl_user`
Expand Down
10 changes: 6 additions & 4 deletions manifests/udev/rule.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
# The literal udev rules you want to deploy
#
define systemd::udev::rule (
Array $rules,
Enum['present', 'absent', 'file'] $ensure = 'present',
Array $rules = [],
Enum['present', 'absent', 'file'] $ensure = 'file',
Stdlib::Absolutepath $path = '/etc/udev/rules.d',
Variant[Array[String[1]], String[1]] $notify_services = [],
Boolean $selinux_ignore_defaults = false,
Expand All @@ -34,13 +34,15 @@
$filename = assert_type(Pattern['^.+\.rules$'], $name) |$expected, $actual| {
fail("The \$name should match \'${expected}\', you passed \'${actual}\'")
}
if $ensure in ['file', 'present'] and empty($rules) {
fail("systemd::udev::rule - ${name}: param rules is empty, you need to pass rules")
}

file { $filename:
file { join([$path, $name], '/'):
ensure => $ensure,
owner => 'root',
group => 'root',
mode => '0444',
path => join([$path, $name], '/'),
notify => $notify_services,
selinux_ignore_defaults => $selinux_ignore_defaults,
content => epp("${module_name}/udev_rule.epp", { 'rules' => $rules }),
Expand Down
19 changes: 16 additions & 3 deletions manifests/unit_file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,17 @@
# Specify a restart command manually. If left unspecified, a standard Puppet service restart happens.
#
# @param hasrestart
# maps to the same param on the service resource. Optional in the module because it's optional in the service resource type
# maps to the same param on the service resource. Optional in the module because it's optional in the service resource type. This param is deprecated. Set it via $service_parameters.
#
# @param hasstatus
# maps to the same param on the service resource. true in the module because it's true in the service resource type
# maps to the same param on the service resource. true in the module because it's true in the service resource type. This param is deprecated. Set it via $service_parameters.
#
# @param selinux_ignore_defaults
# maps to the same param on the file resource for the unit. false in the module because it's false in the file resource type
#
# @param service_parameters
# hash that will be passed with the splat operator to the service resource
#
# @example manage unit file + service
# systemd::unit_file { 'foo.service':
# content => file("${module_name}/foo.service"),
Expand All @@ -79,13 +82,22 @@
Optional[Boolean] $active = undef,
Optional[String] $restart = undef,
Optional[Boolean] $hasrestart = undef,
Boolean $hasstatus = true,
Optional[Boolean] $hasstatus = undef,
Boolean $selinux_ignore_defaults = false,
Hash[String[1], Any] $service_parameters = {},
) {
include systemd

assert_type(Systemd::Unit, $name)

if $hasrestart =~ NotUndef {
deprecation("systemd::unit_file - ${title}", 'hasrestart is deprecated and will be removed in Version 4 of the module')
}

if $hasstatus =~ NotUndef {
deprecation("systemd::unit_file - ${title}", 'hasstatus is deprecated and will be removed in Version 4 of the module')
}

if $enable == 'mask' {
$_target = '/dev/null'
} else {
Expand Down Expand Up @@ -121,6 +133,7 @@
provider => 'systemd',
hasrestart => $hasrestart,
hasstatus => $hasstatus,
* => $service_parameters,
}

if $ensure == 'absent' {
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppet-systemd",
"version": "3.7.0",
"version": "3.8.0",
"author": "Vox Pupuli",
"summary": "Puppet Systemd module",
"license": "Apache-2.0",
Expand Down
Loading