From 8078e8fd2e7c8313e494b132eeaff5caf236eaf9 Mon Sep 17 00:00:00 2001 From: Ken Maglio Date: Tue, 29 Nov 2016 17:07:26 -0600 Subject: [PATCH 01/15] updates gitignore --- .gitignore | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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/ From 3321b6755fce1ca194cb038451233234bebdefd1 Mon Sep 17 00:00:00 2001 From: Ken Maglio Date: Tue, 6 Dec 2016 18:55:56 -0600 Subject: [PATCH 02/15] Implements Service Account --- manifests/init.pp | 6 ++++++ manifests/install.pp | 3 +++ manifests/params.pp | 3 +++ templates/config.xml.epp | 8 ++++++++ 4 files changed, 20 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index b875ace..985de0b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -11,6 +11,9 @@ $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, ) inherits ::winsw::params { winsw::install { 'install_myservice': @@ -24,6 +27,9 @@ 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, } -> winsw::service { 'run_myservice': diff --git a/manifests/install.pp b/manifests/install.pp index add5a0f..079b1d5 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -12,6 +12,9 @@ $service_description = 'WinSW for Puppet', $service_env_variables = undef, $service_logmode = 'rotate', + $service_user = undef, + $service_pass = undef, + $service_domain = undef, ) { if (!$service_id) { diff --git a/manifests/params.pp b/manifests/params.pp index ae65489..1d200ac 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -11,4 +11,7 @@ $service_executable = 'powershell' $service_argument_string = '' $service_logmode = 'rotate' + $service_user = undef + $service_pass = undef + $service_domain = undef } \ No newline at end of file diff --git a/templates/config.xml.epp b/templates/config.xml.epp index 6fed5fe..99ec73c 100644 --- a/templates/config.xml.epp +++ b/templates/config.xml.epp @@ -10,4 +10,12 @@ <%= $winsw::service_executable %> <%= $winsw::service_argument_string %> <%= $winsw::service_logmode %> +<% if($winsw::service_user) { -%> + + <%= $winsw::service_domain %> + <%= $winsw::service_user %> + <%= $winsw::service_pass %> + true + +<% } -%> \ No newline at end of file From 3f811e4552a820207580b095389ecf2bde2a9d04 Mon Sep 17 00:00:00 2001 From: Ken Maglio Date: Tue, 6 Dec 2016 18:59:18 -0600 Subject: [PATCH 03/15] Impement Interactive --- manifests/init.pp | 1 + manifests/install.pp | 1 + manifests/params.pp | 1 + templates/config.xml.epp | 3 +++ 4 files changed, 6 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index 985de0b..9097b02 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -14,6 +14,7 @@ $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': diff --git a/manifests/install.pp b/manifests/install.pp index 079b1d5..4647167 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -15,6 +15,7 @@ $service_user = undef, $service_pass = undef, $service_domain = undef, + $service_interactive = false, ) { if (!$service_id) { diff --git a/manifests/params.pp b/manifests/params.pp index 1d200ac..4856dbf 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -14,4 +14,5 @@ $service_user = undef $service_pass = undef $service_domain = undef + $service_interactive = false } \ No newline at end of file diff --git a/templates/config.xml.epp b/templates/config.xml.epp index 99ec73c..672c5c0 100644 --- a/templates/config.xml.epp +++ b/templates/config.xml.epp @@ -18,4 +18,7 @@ true <% } -%> +<% if($winsw::service_interactive) { -%> + +<% } -%> \ No newline at end of file From 292d02f4a8b971bf6e8a25e76b268b6fa30e7d0b Mon Sep 17 00:00:00 2001 From: Ken Maglio Date: Tue, 6 Dec 2016 19:01:19 -0600 Subject: [PATCH 04/15] Updates NamespacesS --- templates/config.xml.epp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/templates/config.xml.epp b/templates/config.xml.epp index 672c5c0..1ec07ac 100644 --- a/templates/config.xml.epp +++ b/templates/config.xml.epp @@ -1,24 +1,24 @@ - <%= $winsw::service_id %> - <%= $winsw::service_name %> - <%= $winsw::service_description %> -<% if($winsw::service_env_variables) { -%> -<% each($winsw::service_env_variables) | $index, $var | { -%> + <%= $winsw::install::service_id %> + <%= $winsw::install::service_name %> + <%= $winsw::install::service_description %> +<% if($winsw::install::service_env_variables) { -%> +<% each($winsw::install::service_env_variables) | $index, $var | { -%> <% } -%> <% } -%> - <%= $winsw::service_executable %> - <%= $winsw::service_argument_string %> - <%= $winsw::service_logmode %> -<% if($winsw::service_user) { -%> + <%= $winsw::install::service_executable %> + <%= $winsw::install::service_argument_string %> + <%= $winsw::install::service_logmode %> +<% if($winsw::install::service_user) { -%> - <%= $winsw::service_domain %> - <%= $winsw::service_user %> - <%= $winsw::service_pass %> + <%= $winsw::install::service_domain %> + <%= $winsw::install::service_user %> + <%= $winsw::install::service_pass %> true <% } -%> -<% if($winsw::service_interactive) { -%> +<% if($winsw::install::service_interactive) { -%> <% } -%> \ No newline at end of file From 90a36e0eb0da2a85c52ec95129b812f73ca6b67a Mon Sep 17 00:00:00 2001 From: Ken Maglio Date: Tue, 6 Dec 2016 19:22:49 -0600 Subject: [PATCH 05/15] Namespace change not needed --- templates/config.xml.epp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/templates/config.xml.epp b/templates/config.xml.epp index 1ec07ac..672c5c0 100644 --- a/templates/config.xml.epp +++ b/templates/config.xml.epp @@ -1,24 +1,24 @@ - <%= $winsw::install::service_id %> - <%= $winsw::install::service_name %> - <%= $winsw::install::service_description %> -<% if($winsw::install::service_env_variables) { -%> -<% each($winsw::install::service_env_variables) | $index, $var | { -%> + <%= $winsw::service_id %> + <%= $winsw::service_name %> + <%= $winsw::service_description %> +<% if($winsw::service_env_variables) { -%> +<% each($winsw::service_env_variables) | $index, $var | { -%> <% } -%> <% } -%> - <%= $winsw::install::service_executable %> - <%= $winsw::install::service_argument_string %> - <%= $winsw::install::service_logmode %> -<% if($winsw::install::service_user) { -%> + <%= $winsw::service_executable %> + <%= $winsw::service_argument_string %> + <%= $winsw::service_logmode %> +<% if($winsw::service_user) { -%> - <%= $winsw::install::service_domain %> - <%= $winsw::install::service_user %> - <%= $winsw::install::service_pass %> + <%= $winsw::service_domain %> + <%= $winsw::service_user %> + <%= $winsw::service_pass %> true <% } -%> -<% if($winsw::install::service_interactive) { -%> +<% if($winsw::service_interactive) { -%> <% } -%> \ No newline at end of file From b7314ce1eb0fa7ee6fda260d22d5861c8feeacd3 Mon Sep 17 00:00:00 2001 From: Ken Maglio Date: Tue, 6 Dec 2016 19:23:05 -0600 Subject: [PATCH 06/15] Adds missing param --- manifests/init.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/init.pp b/manifests/init.pp index 9097b02..912d462 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -31,6 +31,7 @@ service_user => $service_user, service_pass => $service_pass, service_domain => $service_domain, + service_interactive => $service_interactive, } -> winsw::service { 'run_myservice': From 51801789910e318be85d48a24356055d6546cdd4 Mon Sep 17 00:00:00 2001 From: Ken Maglio Date: Tue, 6 Dec 2016 19:53:34 -0600 Subject: [PATCH 07/15] Refactors to use $title --- manifests/init.pp | 7 ++----- manifests/install.pp | 2 +- manifests/params.pp | 1 - manifests/service.pp | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 912d462..6fe1a86 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -4,7 +4,6 @@ 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, @@ -17,11 +16,10 @@ $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, @@ -34,9 +32,8 @@ 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 4647167..027f7d8 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, diff --git a/manifests/params.pp b/manifests/params.pp index 4856dbf..8328b01 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -4,7 +4,6 @@ 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 diff --git a/manifests/service.pp b/manifests/service.pp index 8c97285..621ca6f 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/', ) { From 5d85edb17dd4a1b53eb2006d79e324a048c444ef Mon Sep 17 00:00:00 2001 From: Ken Maglio Date: Wed, 7 Dec 2016 10:57:29 -0600 Subject: [PATCH 08/15] Moves to native service --- manifests/service.pp | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/manifests/service.pp b/manifests/service.pp index 621ca6f..5cf04df 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -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 From cd7b55cf155e1b307bd1e973aacbb1486ac8a757 Mon Sep 17 00:00:00 2001 From: Ken Maglio Date: Wed, 7 Dec 2016 11:07:58 -0600 Subject: [PATCH 09/15] Handles namespace issue in epp --- manifests/install.pp | 17 ++++++++++++++++- templates/config.xml.epp | 26 +++++++++++++------------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index 027f7d8..8503570 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -84,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/templates/config.xml.epp b/templates/config.xml.epp index 672c5c0..735ae3c 100644 --- a/templates/config.xml.epp +++ b/templates/config.xml.epp @@ -1,24 +1,24 @@ - <%= $winsw::service_id %> - <%= $winsw::service_name %> - <%= $winsw::service_description %> -<% if($winsw::service_env_variables) { -%> -<% each($winsw::service_env_variables) | $index, $var | { -%> + <%= $service_id %> + <%= $service_name %> + <%= $service_description %> +<% if($service_env_variables) { -%> +<% each($service_env_variables) | $index, $var | { -%> <% } -%> <% } -%> - <%= $winsw::service_executable %> - <%= $winsw::service_argument_string %> - <%= $winsw::service_logmode %> -<% if($winsw::service_user) { -%> + <%= $service_executable %> + <%= $service_argument_string %> + <%= $service_logmode %> +<% if($service_user) { -%> - <%= $winsw::service_domain %> - <%= $winsw::service_user %> - <%= $winsw::service_pass %> + <%= $service_domain %> + <%= $service_user %> + <%= $service_pass %> true <% } -%> -<% if($winsw::service_interactive) { -%> +<% if($service_interactive) { -%> <% } -%> \ No newline at end of file From d9bd563f4d80429ea8e36e56e957a7b2d7437874 Mon Sep 17 00:00:00 2001 From: Ken Maglio Date: Wed, 7 Dec 2016 11:13:56 -0600 Subject: [PATCH 10/15] Updates to include service changes --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a374b02..96d944b 100644 --- a/README.md +++ b/README.md @@ -50,12 +50,13 @@ 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,
@@ -63,17 +64,15 @@ Usage Pattern for Installing and Configuring
     service_env_variables   => $service_env_variables,
     service_logmode         => $service_logmode,
   } ->
-  winsw::service { 'run_myservice':
+  winsw::service { 'MyService':
     ensure     => running,
-    service_id => $service_id,
   }
 
Usage Pattern for Uninstalling

-  winsw::install { 'uninstall_myservice':
+  winsw::install { 'MyService':
     ensure     => absent,
-    service_id => $service_id,
   }
 
From 674f2ec9e716f4e27d8481dcca87d7284c72ea50 Mon Sep 17 00:00:00 2001 From: Ken Maglio Date: Wed, 7 Dec 2016 11:35:24 -0600 Subject: [PATCH 11/15] Updates readme information --- README.md | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 96d944b..ae80b85 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) @@ -55,27 +56,46 @@ Title = name of executable / service

   winsw::install { 'MyService':
     ensure                  => present,
-    winsw_binary_version    => $winsw_binary_version,
-    install_path            => $install_path,
     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,
   } ->
   winsw::service { 'MyService':
-    ensure     => running,
+    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,
+
+ Usage Pattern for Uninstalling

   winsw::install { 'MyService':
-    ensure     => absent,
+    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. @@ -104,8 +124,13 @@ 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. + -Then from D:\[your git root dir] in teminal: puppet apply .\winsw\ \ No newline at end of file From 4f800ff25bfd04915a17a32012340542aee241b9 Mon Sep 17 00:00:00 2001 From: Ken Maglio Date: Wed, 7 Dec 2016 11:39:44 -0600 Subject: [PATCH 12/15] Updates development infp --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index ae80b85..bc5ab0e 100644 --- a/README.md +++ b/README.md @@ -133,4 +133,12 @@ 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
+
From 35d8bd29c772dbf8e63ccc1a0c32fac6c1b9c7de Mon Sep 17 00:00:00 2001 From: Ken Maglio Date: Wed, 7 Dec 2016 12:55:45 -0600 Subject: [PATCH 13/15] Increment Version --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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", From bdeaa31a43637e0919a7f46523940a9fab81ea8f Mon Sep 17 00:00:00 2001 From: Ken Maglio Date: Wed, 7 Dec 2016 13:09:24 -0600 Subject: [PATCH 14/15] Changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..4fb8a80 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ + +## Version 1.0.0 +Initial Build \ No newline at end of file From a6e6dfeca3bceb01ad4a503191da719c097582c8 Mon Sep 17 00:00:00 2001 From: Ken Maglio Date: Wed, 7 Dec 2016 13:20:49 -0600 Subject: [PATCH 15/15] Updates ChangeLog --- CHANGELOG.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fb8a80..5d4e1ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ -## Version 1.0.0 -Initial Build \ No newline at end of file +## 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