Showing with 33 additions and 22 deletions.
  1. +7 −1 CHANGELOG.md
  2. +11 −4 README.md
  3. +2 −2 metadata.json
  4. +10 −10 spec/acceptance/init_spec.rb
  5. +1 −3 tasks/init.json
  6. +2 −2 tasks/init.rb
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Release 0.1.3

### Fixed
- Readme updates.
- Service attribute is now name.

## Release 0.1.2

### Fixed
Expand All @@ -7,6 +13,6 @@
## Release 0.1.1
This is the initial release of the service task.

**Features
## Features
- Provides the following actions start, stop, restart, enable, disable, status.
- Provider can optionally be specified.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,23 @@
This module provides the service task. This task allows you to manage and inspect the state of services, including starting, stopping, enabling, and disabling services.

## Requirements
This module is compatible with Puppet Enterprise and Puppet Bolt.

This module requires Puppet Enterprise 2017.3 or later to be installed on the machine from which you are running task commands (the controller node). Machines receiving task requests must be Puppet agents.
* To run tasks with Puppet Enterprise, PE 2017.3 or later must be installed on the machine from which you are running task commands. Machines receiving task requests must be Puppet agents.

* To run tasks with Puppet Bolt, Bolt 0.5 or later must be installed on the machine from which you are running task commands. Machines receiving task requests must have SSH or WinRM services enabled.

## Usage

To run a service task, use the task command, specifying the action and the name of the service.

1. On the command line, run `puppet task service <ACTION> <SERVICE_NAME>`.
* With PE on the command line, run `puppet task run service action=<ACTION> name=<SERVICE_NAME>`.
* With Bolt on the command line, run `bolt task run service action=<ACTION> name=<SERVICE_NAME>`.

For example, to check the status of the Apache httpd service, run:

For example, to check the status of the Apache httpd service, run `puppet task service status httpd`
* With PE, run `puppet task run service action=status name=httpd --nodes neptune`
* With Bolt, run `bolt task run service action=status name=httpd --nodes neptune --modules ~/modules`

You can also run tasks in the PE console. See PE task documentation for complete information.

Expand All @@ -37,5 +44,5 @@ For a complete list of services that are supported see the Puppet [services](htt

To display help for the service task, run `puppet task show service`

To show help for the task CLI, run `puppet task run --help`
To show help for the task CLI, run `puppet task run --help` or `bolt task run --help`

4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "puppetlabs-service",
"version": "0.1.2",
"version": "0.1.3",
"author": "puppet",
"summary": "Tasks that manipulate a service",
"description": "Tasks that manipulate a service",
"license": "Apache-2.0",
"source": "",
"source": "https://github.com/puppetlabs/puppetlabs-service",
"dependencies": [],
"operatingsystem_support": [
{
Expand Down
20 changes: 10 additions & 10 deletions spec/acceptance/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,41 @@
end
describe 'stop action' do
it 'stop/status a service' do
result = run_task(task_name: 'service', params: 'action=stop service=ntpd')
result = run_task(task_name: 'service', params: 'action=stop name=ntpd')
expect_multiple_regexes(result: result, regexes: [%r{status : (in_sync|stopped)}, %r{Job completed. 1/1 nodes succeeded}])
result = run_task(task_name: 'service', params: 'action=status service=ntpd')
result = run_task(task_name: 'service', params: 'action=status name=ntpd')
expect_multiple_regexes(result: result, regexes: [%r{status : stopped}, %r{enabled : false}, %r{Job completed. 1/1 nodes succeeded}])
end
end
describe 'start action' do
it 'start/status a service' do
result = run_task(task_name: 'service', params: 'action=start service=ntpd')
result = run_task(task_name: 'service', params: 'action=start name=ntpd')
expect_multiple_regexes(result: result, regexes: [%r{status : started}, %r{Job completed. 1/1 nodes succeeded}])
result = run_task(task_name: 'service', params: 'action=status service=ntpd')
result = run_task(task_name: 'service', params: 'action=status name=ntpd')
expect_multiple_regexes(result: result, regexes: [%r{status : running}, %r{enabled : false}, %r{Job completed. 1/1 nodes succeeded}])
end
end
describe 'restart action' do
it 'restart/status a service' do
result = run_task(task_name: 'service', params: 'action=restart service=ntpd')
result = run_task(task_name: 'service', params: 'action=restart name=ntpd')
expect_multiple_regexes(result: result, regexes: [%r{status : restarted}, %r{Job completed. 1/1 nodes succeeded}])
result = run_task(task_name: 'service', params: 'action=status service=ntpd')
result = run_task(task_name: 'service', params: 'action=status name=ntpd')
expect_multiple_regexes(result: result, regexes: [%r{status : running}, %r{enabled : false}, %r{Job completed. 1/1 nodes succeeded}])
end
end
describe 'enable action' do
it 'enable/status a service' do
result = run_task(task_name: 'service', params: 'action=enable service=ntpd')
result = run_task(task_name: 'service', params: 'action=enable name=ntpd')
expect_multiple_regexes(result: result, regexes: [%r{status : enabled}, %r{Job completed. 1/1 nodes succeeded}])
result = run_task(task_name: 'service', params: 'action=status service=ntpd')
result = run_task(task_name: 'service', params: 'action=status name=ntpd')
expect_multiple_regexes(result: result, regexes: [%r{status : running}, %r{enabled : true}, %r{Job completed. 1/1 nodes succeeded}])
end
end
describe 'disable action' do
it 'enable/status a service' do
result = run_task(task_name: 'service', params: 'action=disable service=ntpd')
result = run_task(task_name: 'service', params: 'action=disable name=ntpd')
expect_multiple_regexes(result: result, regexes: [%r{status : disabled}, %r{Job completed. 1/1 nodes succeeded}])
result = run_task(task_name: 'service', params: 'action=status service=ntpd')
result = run_task(task_name: 'service', params: 'action=status name=ntpd')
expect_multiple_regexes(result: result, regexes: [%r{status : running}, %r{enabled : false}, %r{Job completed. 1/1 nodes succeeded}])
end
end
Expand Down
4 changes: 1 addition & 3 deletions tasks/init.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{
"summary": "Manage and inspect the state of services",
"description": "Manage and inspect the state of services",
"supports_noop": true,
"input_method": "stdin",
"parameters": {
"action": {
"description": "The operation (start, stop, restart, enable, disable, status) to perform on the service",
"type": "Enum[start, stop, restart, enable, disable, status]"
},
"service": {
"name": {
"description": "The name of the service to operate on.",
"type": "String[1]"
},
Expand Down
4 changes: 2 additions & 2 deletions tasks/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ def disable(provider)
end

params = JSON.parse(STDIN.read)
service = params['service']
name = params['name']
provider = params['provider']
action = params['action']

opts = { name: service }
opts = { name: name }
opts[:provider] = provider if provider

begin
Expand Down