1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'manifests/agent/windows.pp', line 1
class distelli::agent::windows (
$version = '3.66.33',
$tempdir = 'C:/Users/distelli/AppData/Local/Temp/1',
){
if $::facts['os']['hardware'] == 'x86_64' {
$archive = "distelli.Windows-AMD64-${version}.gz"
$url = "https://s3.amazonaws.com/download.distelli.com/distelli.Windows-AMD64/${archive}"
}
else {
$archive = "distelli.Windows-x86-${version}.gz"
$url = "https://s3.amazonaws.com/download.distelli.com/distelli.Windows-x86/${archive}"
}
$workdir = 'C:/Program Files/Distelli'
archive { "${tempdir}/${archive}" :
source => $url,
# cleanup => false,
creates => "${tempdir}/distelli",
extract => true,
extract_path => $tempdir,
require => User['distelli'],
}
file { $workdir :
ensure => directory,
owner => 'distelli',
group => 'Administrators',
require => User['distelli'],
}
# Requires fqdn_rand_string function from puppetlabs/stdlib
$distelli_exec = "distelli-${fqdn_rand_string(5)}.exe"
exec { 'Copy executable' :
command => "Copy-Item ${tempdir}/distelli \$ENV:ProgramFiles/Distelli/${distelli_exec}",
unless => "If (Test-Path -Path \$ENV:ProgramFiles/Distelli/${distelli_exec}) { exit 0 } else { exit 1}",
provider => powershell,
require => File[$workdir],
logoutput => true,
}
file { ["${workdir}/distelli.exe", "${workdir}/dagent.exe", "${workdir}/dtk.exe"] :
ensure => link,
target => "${workdir}/${distelli_exec}",
require => Exec['Copy executable'],
}
exec { 'Test distelli.exe execution' :
command => "& \$ENV:ProgramFiles/Distelli/distelli.exe version",
provider => powershell,
subscribe => File["${workdir}/distelli.exe"],
logoutput => true,
refreshonly => true,
}
file { 'C:/distelli.yml' :
ensure => file,
owner => 'distelli',
group => 'Administrators',
mode => '0644',
content => epp('distelli/distelli.yml.epp'),
require => Exec['Test distelli.exe execution'],
}
exec { 'Start distelli' :
command => 'C:/Progra~1/Distelli/distelli.exe agent install',
subscribe => [ File['C:/distelli.yml'], Exec['Test distelli.exe execution'] ],
refreshonly => true,
}
}
|