Showing with 224 additions and 91 deletions.
  1. +3 −0 .fixtures.yml
  2. +1 −1 .gitattributes
  3. +13 −0 .pdkignore
  4. 0 .puppet-lint.rc
  5. +8 −0 .sync.yml
  6. +10 −14 .travis.yml
  7. +13 −0 CHANGELOG.md
  8. +3 −0 Gemfile
  9. +4 −0 Rakefile
  10. +3 −0 appveyor.yml
  11. +28 −6 metadata.json
  12. +73 −30 spec/acceptance/init_spec.rb
  13. +38 −15 spec/acceptance/linux_spec.rb
  14. +0 −1 spec/default_facts.yml
  15. +14 −14 spec/spec_helper.rb
  16. +3 −7 spec/spec_helper_acceptance.rb
  17. +8 −3 tasks/init.json
  18. +1 −0 tasks/linux.json
  19. +1 −0 tasks/windows.json
3 changes: 3 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fixtures:
symlinks:
service: "#{source_dir}"
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#This file is generated by ModuleSync, do not edit.
*.rb eol=lf
*.erb eol=lf
*.pp eol=lf
*.sh eol=lf
*.epp eol=lf
13 changes: 13 additions & 0 deletions .pdkignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Empty file added .puppet-lint.rc
Empty file.
8 changes: 8 additions & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
- set: docker/ubuntu-14.04
docker_defaults:
bundler_args: ""
script: bundle exec rake task_acceptance
secure: ""
branches:
- release
remove_includes:
- env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec
rvm: 2.4.4
- env: PUPPET_GEM_VERSION="~> 4.0" CHECK=parallel_spec RUBYGEMS_VERSION=2.7.8
rvm: 2.1.9

Gemfile:
optional:
Expand All @@ -25,6 +31,8 @@ Gemfile:
- mswin
- mingw
- x64_mingw
- gem: 'bolt'
version: '~> 1.4'

.gitlab-ci.yml:
unmanaged: true
24 changes: 10 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,47 @@
---
sudo: false
dist: trusty
language: ruby
cache: bundler
before_install:
- if [ $BUNDLER_VERSION ]; then
gem install -v $BUNDLER_VERSION bundler --no-rdoc --no-ri;
fi
- 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.5.0
- 2.5.1
env:
global:
- BEAKER_PUPPET_COLLECTION=puppet6 PUPPET_GEM_VERSION="~> 6.0"
- BEAKER_PUPPET_COLLECTION=puppet6 PUPPET_GEM_VERSION="~> 6.0" GEM_BOLT=true
matrix:
fast_finish: true
include:
-
bundler_args:
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/centos-7 BEAKER_TESTMODE=apply
rvm: 2.5.0
script: bundle exec rake beaker
rvm: 2.5.1
script: bundle exec rake task_acceptance
services: docker
sudo: required
-
bundler_args:
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/ubuntu-14.04 BEAKER_TESTMODE=apply
rvm: 2.5.0
script: bundle exec rake beaker
rvm: 2.5.1
script: bundle exec rake task_acceptance
services: docker
sudo: required
-
env: CHECK="syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop"
-
env: CHECK=parallel_spec
-
env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec
rvm: 2.4.4
-
env: PUPPET_GEM_VERSION="~> 4.0" CHECK=parallel_spec
rvm: 2.1.9
branches:
only:
- master
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).

## [0.5.0](https://github.com/puppetlabs/puppetlabs-service/tree/0.5.0) (2019-01-08)

[Full Changelog](https://github.com/puppetlabs/puppetlabs-service/compare/0.4.0...0.5.0)

### Fixed

- pdksync - \(FM-7655\) Fix rubygems-update for ruby \< 2.3 [\#62](https://github.com/puppetlabs/puppetlabs-service/pull/62) ([tphoney](https://github.com/tphoney))

### Added

- \(MODULES-8420\) Move to GEM\_BOLT pattern [\#65](https://github.com/puppetlabs/puppetlabs-service/pull/65) ([donoghuc](https://github.com/donoghuc))
- \(MODULES-8391\) Enable implementations on the init task and hide others [\#61](https://github.com/puppetlabs/puppetlabs-service/pull/61) ([MikaelSmith](https://github.com/MikaelSmith))

## [0.4.0](https://github.com/puppetlabs/puppetlabs-service/tree/0.4.0) (2018-09-28)

[Full Changelog](https://github.com/puppetlabs/puppetlabs-service/compare/0.3.1...0.4.0)
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ end
group :system_tests do
gem "puppet-module-posix-system-r#{minor_version}", require: false, platforms: [:ruby]
gem "puppet-module-win-system-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
if ENV['GEM_BOLT']
gem 'bolt', '~> 1.4', require: false
end
end

puppet_version = ENV['PUPPET_GEM_VERSION']
Expand Down
4 changes: 4 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -73,3 +74,6 @@ EOM
end
end

task :task_acceptance => [:spec_prep, :beaker] do
# nothing to do
end
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
version: 1.1.x.{build}
branches:
only:
- master
skip_commits:
message: /^\(?doc\)?.*/
clone_depth: 10
Expand Down
34 changes: 28 additions & 6 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-service",
"version": "0.4.0",
"version": "0.5.0",
"author": "puppetlabs",
"summary": "Tasks that manipulate a service",
"license": "Apache-2.0",
Expand All @@ -16,23 +16,45 @@
"9"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"7.0"
"5",
"6",
"7"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"14.04",
"16.04",
"18.04"
]
},
{
"operatingsystem": "windows",
"operatingsystemrelease": [
"2012 R2"
"2008 R2",
"2012 R2",
"10",
"2016"
]
}
],
Expand All @@ -43,7 +65,7 @@
}
],
"description": "Tasks that manipulate a service",
"pdk-version": "1.7.0",
"template-url": "https://github.com/puppetlabs/pdk-templates",
"template-ref": "heads/master-0-g8fc95db"
"pdk-version": "1.7.1",
"template-url": "https://github.com/puppetlabs/pdk-templates/",
"template-ref": "heads/master-0-g9c815ea"
}
103 changes: 73 additions & 30 deletions spec/acceptance/init_spec.rb
Original file line number Diff line number Diff line change
@@ -1,67 +1,110 @@
# run a test task
require 'spec_helper_acceptance'
# bolt regexes
# expect_multiple_regexes(result: result, regexes: [%r{"status":"(stopped|in_sync)"}, %r{Ran on 1 node}])
# expect_multiple_regexes(result: result, regexes: [%r{"status":"stopped"}, %r{"enabled":"false"}, %r{Ran on 1 node}])

def run_and_expect(params, regex_hash)
expect_multiple_regexes(result: run_task(task_name: 'service', params: params), regexes: regex_hash)
end
require 'beaker-task_helper/inventory'
require 'bolt_spec/run'

describe 'service task' do
include Beaker::TaskHelper::Inventory
include BoltSpec::Run

def module_path
RSpec.configuration.module_path
end

def config
{ 'modulepath' => module_path }
end

def inventory
hosts_to_inventory.merge('features' => ['puppet-agent'])
end

def run(params)
run_task('service', 'default', params, config: config, inventory: inventory)
end

osfamily_fact = fact('osfamily')

package_to_use = ''
before(:all) do
if fact_on(default, 'osfamily') != 'windows'
if fact_on(default, 'osfamily') == 'RedHat' && fact_on(default, 'operatingsystemrelease') < '6'
run_task(task_name: 'service', params: 'action=stop name=syslog')
if osfamily_fact != 'windows'
if osfamily_fact == 'RedHat' && fact('operatingsystemrelease') < '6'
run('action' => 'stop', 'name' => 'syslog')
end
package_to_use = 'rsyslog'
apply_manifest("package { \"#{package_to_use}\": ensure => present, }")
apply_manifest_on(default, "package { \"#{package_to_use}\": ensure => present, }")
else
package_to_use = 'W32Time'
run_and_expect("action=start name=#{package_to_use}", [%r{status.*(in_sync|started)}, %r{#{task_summary_line}}])
run('action' => 'start', 'name' => package_to_use)
end
end

describe 'enable action' do
it 'enable/status a service' do
run_and_expect("action=enable name=#{package_to_use}",
[%r{status.*(in_sync|enabled)}, %r{#{task_summary_line}}])
run_and_expect("action=status name=#{package_to_use}",
[%r{enabled.*true}, %r{#{task_summary_line}}])
result = run('action' => 'enable', 'name' => package_to_use)
expect(result[0]['status']).to eq('success')
expect(result[0]['result']['status']).to match(%r{in_sync|enabled})

result = run('action' => 'status', 'name' => package_to_use)
expect(result[0]['status']).to eq('success')
expect(result[0]['result']['enabled']).to eq('true')
end
end

describe 'restart action' do
it 'restart/status a service' do
run_and_expect("action=restart name=#{package_to_use}",
[%r{status.*restarted}, %r{#{task_summary_line}}])
run_and_expect("action=status name=#{package_to_use}",
[%r{status.*running}, %r{enabled.*true}, %r{#{task_summary_line}}])
result = run('action' => 'restart', 'name' => package_to_use)
expect(result[0]['status']).to eq('success')
expect(result[0]['result']['status']).to eq('restarted')

result = run('action' => 'status', 'name' => package_to_use)
expect(result[0]['status']).to eq('success')
expect(result[0]['result']['status']).to eq('running')
expect(result[0]['result']['enabled']).to eq('true')
end
end

describe 'stop action' do
it 'stop/status a service' do
run_and_expect("action=stop name=#{package_to_use}", [%r{status.*(in_sync|stopped)}, %r{#{task_summary_line}}])
result = run('action' => 'stop', 'name' => package_to_use)
expect(result[0]['status']).to eq('success')
expect(result[0]['result']['status']).to match(%r{in_sync|stopped})

# Debian can give incorrect status
if fact_on(default, 'osfamily') != 'Debian'
run_and_expect("action=status name=#{package_to_use}", [%r{status.*stopped}, %r{enabled.*true}, %r{#{task_summary_line}}])
if osfamily_fact != 'Debian'
result = run('action' => 'status', 'name' => package_to_use)
expect(result[0]['status']).to eq('success')
expect(result[0]['result']['status']).to eq('stopped')
expect(result[0]['result']['enabled']).to eq('true')
end
end
end

describe 'start action' do
it 'start/status a service' do
run_and_expect("action=start name=#{package_to_use}", [%r{status.*(in_sync|started)}, %r{#{task_summary_line}}])
result = run('action' => 'start', 'name' => package_to_use)
expect(result[0]['status']).to eq('success')
expect(result[0]['result']['status']).to match(%r{in_sync|started})

# Debian can give incorrect status
if fact_on(default, 'osfamily') != 'Debian'
run_and_expect("action=status name=#{package_to_use}", [%r{status.*running}, %r{enabled.*true}, %r{#{task_summary_line}}])
if osfamily_fact != 'Debian'
result = run('action' => 'status', 'name' => package_to_use)
expect(result[0]['status']).to eq('success')
expect(result[0]['result']['status']).to eq('running')
expect(result[0]['result']['enabled']).to eq('true')
end
end
end

describe 'disable action' do
it 'disable/status a service' do
run_and_expect("action=disable name=#{package_to_use}",
[%r{status.*disabled}, %r{#{task_summary_line}}])
run_and_expect("action=status name=#{package_to_use}",
[%r{enabled.*false}, %r{#{task_summary_line}}])
result = run('action' => 'disable', 'name' => package_to_use)
expect(result[0]['status']).to eq('success')
expect(result[0]['result']['status']).to eq('disabled')

result = run('action' => 'status', 'name' => package_to_use)
expect(result[0]['status']).to eq('success')
expect(result[0]['result']['enabled']).to eq('false')
end
end
end
Loading