-
-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #403 from iwagnerclgx/master
Added experimental Windows support
- Loading branch information
Showing
8 changed files
with
149 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# == Class consul::windows_service | ||
# | ||
# Installs consul windows server | ||
# == Parameters | ||
# | ||
# [*nssm_version*] | ||
# nssm version to download | ||
# | ||
# [*nssm_download_url*] | ||
# nssm version to download | ||
# | ||
# [*nssm_download_url_base*] | ||
# nssm version to download | ||
# | ||
class consul::windows_service { | ||
|
||
$app_dir = regsubst($consul::bin_dir, '\/', '\\', 'G') | ||
$app_exec = "${app_dir}\\consul.exe" | ||
$agent_args = regsubst($consul::config_dir, '\/', '\\', 'G') | ||
$app_args = "agent -config-dir=${agent_args}" | ||
$app_log_path = "${app_dir}\\logs" | ||
$app_log_file = 'consul.log' | ||
$app_log = "${app_log_path}//${app_log_file}" | ||
|
||
include '::archive' | ||
|
||
file { $app_log_path: | ||
ensure => 'directory', | ||
owner => 'Administrator', | ||
group => 'Administrators', | ||
mode => '0755', | ||
} | ||
-> exec { 'consul_service_install': | ||
cwd => $consul::bin_dir, | ||
command => "&'${consul::nssm_exec}' install Consul ${app_exec}", | ||
unless => 'if((get-service -name consul -ErrorAction SilentlyContinue).count -ne 1){exit 1}', | ||
logoutput => true, | ||
provider => 'powershell', | ||
notify => Exec['consul_service_set_parameters'] | ||
} | ||
file { "${consul::bin_dir}/set_service_parameters.ps1": | ||
ensure => 'present', | ||
content => template('consul/set_service_parameters.ps1.erb'), | ||
notify => Exec['consul_service_set_parameters'] | ||
} | ||
-> exec { 'consul_service_set_parameters': | ||
cwd => $consul::bin_dir, | ||
command => "${consul::bin_dir}/set_service_parameters.ps1", | ||
refreshonly => true, | ||
logoutput => true, | ||
provider => 'powershell', | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
& '<%= scope['consul::nssm_exec'] %>' set Consul AppParameters "<%= @app_args %>" | ||
& '<%= scope['consul::nssm_exec'] %>' set Consul AppDirectory "<%= @app_dir %>" | ||
& '<%= scope['consul::nssm_exec'] %>' set Consul AppStopMethodConsole 15000 | ||
& '<%= scope['consul::nssm_exec'] %>' set Consul AppStopMethodSkip 2 | ||
& '<%= scope['consul::nssm_exec'] %>' set Consul AppStopMethodSkip 4 | ||
& '<%= scope['consul::nssm_exec'] %>' set Consul AppStderr "<%= @app_log %>" | ||
& '<%= scope['consul::nssm_exec'] %>' set Consul AppStdout "<%= @app_log %>" | ||
& '<%= scope['consul::nssm_exec'] %>' set Consul AppRotateFiles 1 | ||
& '<%= scope['consul::nssm_exec'] %>' set Consul AppRotateOnline 0 | ||
& '<%= scope['consul::nssm_exec'] %>' set Consul AppRotateBytes 1024000 | ||
& '<%= scope['consul::nssm_exec'] %>' set Consul AppRestartDelay 0 | ||
& '<%= scope['consul::nssm_exec'] %>' set Consul AppExit Default Exit | ||
& '<%= scope['consul::nssm_exec'] %>' set Consul Start SERVICE_AUTO_START | ||
exit 0 |