-
Notifications
You must be signed in to change notification settings - Fork 15
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 #27 from axelrtgs/master
Convert default recipe to custom resource with idempotence and make service parameters match exactly
- Loading branch information
Showing
8 changed files
with
86 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
if platform?('windows') | ||
src = node['nssm']['src'] | ||
basename = src.slice(src.rindex('/') + 1, src.rindex('.') - src.rindex('/') - 1) | ||
system = node['kernel']['machine'] == 'x86_64' ? 'win64' : 'win32' | ||
system_file = "#{Chef::Config[:file_cache_path]}/#{basename}/#{system}/nssm.exe" | ||
|
||
windows_zipfile 'download nssm' do | ||
path Chef::Config[:file_cache_path] | ||
source src | ||
overwrite true | ||
checksum node['nssm']['sha256'] | ||
action :unzip | ||
notifies :create, 'remote_file[install nssm]', :immediately | ||
end | ||
|
||
remote_file 'install nssm' do | ||
path ::NSSM.binary_path node | ||
source "file:///#{system_file}" | ||
end | ||
else | ||
Chef::Log.warn('NSSM can only be installed on Windows platforms!') | ||
nssm_install 'Install NSSM' do | ||
source node['nssm']['src'] | ||
sha256 node['nssm']['sha256'] | ||
end |
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,34 @@ | ||
provides :nssm_install, platform: 'windows' | ||
|
||
property :source, identity: true, name_attribute: true | ||
property :sha256, kind_of: String, required: true | ||
|
||
default_action :install | ||
|
||
action :install do | ||
src = new_resource.source | ||
basename = src.slice(src.rindex('/') + 1, src.rindex('.') - src.rindex('/') - 1) | ||
system = node['kernel']['machine'] == 'x86_64' ? 'win64' : 'win32' | ||
system_file = "#{Chef::Config[:file_cache_path]}/#{basename}/#{system}/nssm.exe" | ||
|
||
windows_zipfile 'download nssm' do | ||
path Chef::Config[:file_cache_path] | ||
source src | ||
overwrite true | ||
checksum new_resource.sha256 | ||
action :unzip | ||
notifies :create, 'remote_file[install nssm]', :immediately | ||
not_if { Digest::SHA256.file("#{Chef::Config[:file_cache_path]}/#{basename}.zip").hexdigest == new_resource.sha256 } if ::File.exist?("#{Chef::Config[:file_cache_path]}/#{basename}.zip") | ||
end | ||
|
||
remote_file 'install nssm' do | ||
path ::NSSM.binary_path node | ||
source "file:///#{system_file}" | ||
end | ||
end | ||
|
||
action_class do | ||
def whyrun_supported? | ||
true | ||
end | ||
end |
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,16 @@ | ||
provides :nssm_install | ||
|
||
property :source, identity: true, name_attribute: true | ||
property :sha256, kind_of: String, required: true | ||
|
||
default_action :install | ||
|
||
action :install do | ||
::Chef::Log.warn('NSSM service can only be installed on Windows platforms!') | ||
end | ||
|
||
action_class do | ||
def whyrun_supported? | ||
true | ||
end | ||
end |
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