diff --git a/.gitignore b/.gitignore index df75934..f64b686 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,5 @@ # cache/options directory .vscode/ -# git -.git/ - # pkg -.pkg/ +pkg/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..5d4e1ab --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ + +## Versoin 1.1.0 +### Published: 2016.12.07 +#### Adds Enhancements +* Implements RunAs Capabilities +* Implements Interactive +* Refactors Service Defined Type to use Native Service Resource +* Refactors Service_ID to be Title of Resource for Install and Service Defined Types + +#### Resolves Bugs +* Variable Namespacing for EPP diff --git a/README.md b/README.md index a374b02..bc5ab0e 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ 1. [Setup - The basics of getting started with winsw](#setup) * [Beginning with winsw](#beginning-with-winsw) 1. [Usage - Configuration options and additional functionality](#usage) + * [Additional Configurations](#additional-configuration-parameters) 1. [Reference - An under-the-hood peek at what the module is doing and how](#reference) 1. [Limitations - OS compatibility, etc.](#limitations) 1. [Development - Guide for contributing to the module](#development) @@ -50,33 +51,51 @@ You can take two approaches: ## Usage Usage Pattern for Installing and Configuring +Title = name of executable / service +
- winsw::install { 'install_myservice':
+ winsw::install { 'MyService':
ensure => present,
- winsw_binary_version => $winsw_binary_version,
- install_path => $install_path,
- service_id => $service_id,
service_name => $service_name,
service_executable => $service_executable,
service_argument_string => $service_argument_string,
+ } ->
+ winsw::service { 'MyService':
+ ensure => running,
+ }
+
+
+Optional Parameters
+
+ winsw_binary_version => $winsw_binary_version,
+ install_path => $install_path,
service_description => $service_description,
service_env_variables => $service_env_variables,
service_logmode => $service_logmode,
- } ->
- winsw::service { 'run_myservice':
- ensure => running,
- service_id => $service_id,
- }
Usage Pattern for Uninstalling
- winsw::install { 'uninstall_myservice':
- ensure => absent,
- service_id => $service_id,
+ winsw::install { 'MyService':
+ ensure => absent,
}
+### Additional Configuration Parameters
+
+
+To Specify Service Account to run service as
+
+ service_user => 'your_serviceaccount',
+ service_pass => 'your_serviceaccount_password',
+ service_domain => 'your_serviceaccount_domain'
+
+
+To Run Interactively (not service account cannot be used - only local system)
+
+ service_interactive => $true
+
+
## Reference
The module includes embedded the winsw executable file, and provides a template for the configuration XML.
@@ -105,8 +124,21 @@ See: [https://github.com/kohsuke/winsw](https://github.com/kohsuke/winsw)
## Development
-While using --modulepath does work, this approach I found easier
-From directory C:\ProgramData\PuppetLabs\code\environments\production\modules
-mklink /D winsw D:\[your git root dir]\winsw
+#### Please fork and submit pull requests
+
+To setup local environment:
+
+puppet module install puppetlabs-powershell --version 2.1.0 --modulepath=[your path to modules here]
+puppet apply -v -e 'include winsw' --modulepath=[your path to modules here]
+
+You can include --noop if you don't want to apply, however service actions will fail as it won't actually install.
+
+If you run an elevated command prompt, you can navigate to the service executable directory.
+Then you can use these to test states of your service and the module. (note MyService is your servie name)
+
+MyService.exe stop
+MyService.exe uninstall
+MyService.exe start
+MyService.exe install
+
-Then from D:\[your git root dir] in teminal: puppet apply .\winsw\
\ No newline at end of file
diff --git a/manifests/init.pp b/manifests/init.pp
index b875ace..6fe1a86 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -4,31 +4,36 @@
class winsw (
$winsw_binary_version = $::winsw::params::winsw_binary_version,
$install_path = $::winsw::params::install_path,
- $service_id = $::winsw::params::service_id,
$service_name = $::winsw::params::service_name,
$service_description = $::winsw::params::service_description,
$service_env_variables = $::winsw::params::service_env_variables,
$service_executable = $::winsw::params::service_executable,
$service_argument_string = $::winsw::params::service_argument_string,
$service_logmode = $::winsw::params::service_logmode,
+ $service_user = $::winsw::params::service_user,
+ $service_pass = $::winsw::params::service_pass,
+ $service_domain = $::winsw::params::service_domain,
+ $service_interactive = $::winsw::params::service_interactive,
) inherits ::winsw::params {
- winsw::install { 'install_myservice':
+ winsw::install { 'MyService':
ensure => present,
winsw_binary_version => $winsw_binary_version,
install_path => $install_path,
- service_id => $service_id,
service_name => $service_name,
service_executable => $service_executable,
service_argument_string => $service_argument_string,
service_description => $service_description,
service_env_variables => $service_env_variables,
service_logmode => $service_logmode,
+ service_user => $service_user,
+ service_pass => $service_pass,
+ service_domain => $service_domain,
+ service_interactive => $service_interactive,
} ->
- winsw::service { 'run_myservice':
+ winsw::service { 'MyService':
ensure => running,
- service_id => $service_id,
}
}
\ No newline at end of file
diff --git a/manifests/install.pp b/manifests/install.pp
index add5a0f..8503570 100644
--- a/manifests/install.pp
+++ b/manifests/install.pp
@@ -3,7 +3,7 @@
#
define winsw::install (
$ensure = present,
- $service_id = undef,
+ $service_id = $title,
$service_name = undef,
$service_executable = undef,
$service_argument_string = undef,
@@ -12,6 +12,10 @@
$service_description = 'WinSW for Puppet',
$service_env_variables = undef,
$service_logmode = 'rotate',
+ $service_user = undef,
+ $service_pass = undef,
+ $service_domain = undef,
+ $service_interactive = false,
) {
if (!$service_id) {
@@ -80,7 +84,22 @@
# place the config file with the same name as the service - required for winsw
file { "config_xml_${service_id}":
ensure => $ensure,
- content => epp('winsw/config.xml.epp'),
+ content => epp('winsw/config.xml.epp',{
+ 'service_id' => $service_id,
+ 'service_name' => $service_name,
+ 'service_executable' => $service_executable,
+ 'service_argument_string' => $service_argument_string,
+ 'winsw_binary_version' => $winsw_binary_version,
+ 'install_path' => $install_path,
+ 'service_description' => $service_description,
+ 'service_env_variables' => $service_env_variables,
+ 'service_logmode' => $service_logmode,
+ 'service_user' => $service_user,
+ 'service_pass' => $service_pass,
+ 'service_domain' => $service_domain,
+ 'service_interactive' => $service_interactive
+ }
+ ),
path => "${install_path}${service_id}.xml",
notify => $notify_config_change,
}
diff --git a/manifests/params.pp b/manifests/params.pp
index ae65489..8328b01 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -4,11 +4,14 @@
class winsw::params {
$winsw_binary_version = 'winsw_1_19_1'
$install_path = 'C:/Program Files/WinSW/'
- $service_id = 'MyService'
$service_name = 'My Service'
$service_description = 'WinSW Service Wrapper'
$service_env_variables = undef
$service_executable = 'powershell'
$service_argument_string = ''
$service_logmode = 'rotate'
+ $service_user = undef
+ $service_pass = undef
+ $service_domain = undef
+ $service_interactive = false
}
\ No newline at end of file
diff --git a/manifests/service.pp b/manifests/service.pp
index 8c97285..5cf04df 100644
--- a/manifests/service.pp
+++ b/manifests/service.pp
@@ -2,7 +2,7 @@
#
#
define winsw::service (
- $service_id = undef,
+ $service_id = $title,
$ensure = undef,
$install_path = 'C:/Program Files/WinSW/',
) {
@@ -14,23 +14,12 @@
fail('Ensure must be provided')
}
- if ($ensure == running ) {
- exec { "start_service_${service_id}":
- command => "& '${install_path}${service_id}.exe' start",
- unless => "\$started = (& '${install_path}${service_id}.exe' status); \
- if (\$started -eq \"Started\") { exit 0 } else { exit 1 }",
- provider => powershell,
- }
- }
-
- if ($ensure == stopped ) {
- exec { "stop_service_${service_id}":
- command => "& '${install_path}${service_id}.exe' stop",
- unless => "\$started = (& '${install_path}${service_id}.exe' status); \
- if (\$installed -eq \"Stopped\") { exit 0 } else { exit 1 }",
- refreshonly => true,
- provider => powershell,
- }
+ service { $service_id:
+ ensure => $ensure,
+ start => "${install_path}${service_id}.exe' start",
+ stop => "${install_path}${service_id}.exe' stop",
+ restart => "${install_path}${service_id}.exe' restart!",
+ status => "${install_path}${service_id}.exe' status",
}
}
\ No newline at end of file
diff --git a/metadata.json b/metadata.json
index e569251..661f9a6 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,6 +1,6 @@
{
"name": "kenmaglio-winsw",
- "version": "1.0.1",
+ "version": "1.1.0",
"author": "Ken Maglio",
"summary": "WINSW Module. Service Wrapper for any process.",
"license": "MIT",
diff --git a/templates/config.xml.epp b/templates/config.xml.epp
index 6fed5fe..735ae3c 100644
--- a/templates/config.xml.epp
+++ b/templates/config.xml.epp
@@ -1,13 +1,24 @@