This repository was archived by the owner on Nov 7, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpackage.pp
59 lines (54 loc) · 2.36 KB
/
package.pp
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
# @summary
# Installs Virtualstudio. This private definition is meant to be called from `visualstudio`. It sets variables according to platform.
#
define visualstudio::package (
Pattern['^(2012)'] $version,
$edition,
Pattern['^([A-Z1-9]{5})-([A-Z1-9]{5})-([A-Z1-9]{5})-([A-Z1-9]{5})-([A-Z1-9]{5})$'] $license_key,
$deployment_root,
Array $components = [],
Enum['present','absent'] $ensure = 'present'
) {
include visualstudio::params
#For now we might want to ignore this, this cannot be easily rewritten as a datatype
#$edition_regex = join($visualstudio::params::vs_versions[$version]['editions'], '|')
#validate_re($edition,"^${edition_regex}$", 'The edition argument does not match a valid edition for the specified version of visual studio')
case $version {
'2012': {
$vs_root = "${deployment_root}\\VS2012\\${edition}"
$vs_reg_key = 'HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{17c2e197-cf26-443b-8beb-53151940df3f}'
}
default: {
if $ensure == 'present' {
notify { "visual studio does not have a version: ${version}": }
}
}
}
if size($components) == 0 {
$compnents = $visualstudio::params::component_list
}
if $ensure == 'present' {
file { "${visualstudio::params::temp_dir}\\visualstudio_config.xml":
content => template('visualstudio/AdminDeployment.xml.erb'),
mode => '0755',
owner => 'Administrator',
group => 'Administrators',
}
exec { 'install-visualstudio':
command => "& \"${vs_root}\\vs_${edition}.exe\" /adminfile \"${visualstudio::params::temp_dir}\\visualstudio_config.xml\" /quiet /norestart",
provider => powershell,
logoutput => true,
unless => "if ((Get-Item -LiteralPath \'\\${vs_reg_key}\' -ErrorAction SilentlyContinue).GetValue(\'DisplayVersion\')) { exit 1 }",
require => File["${visualstudio::params::temp_dir}\\visualstudio_config.xml"],
}
} elsif $ensure == 'absent' {
exec { 'uninstall-visualstudio':
command => "& \"${vs_root}\\vs_${edition}.exe\" /uninstall /quiet /norestart",
provider => powershell,
logoutput => true,
onlyif => "if ((Get-Item -LiteralPath \'\\${vs_reg_key}\' -ErrorAction SilentlyContinue).GetValue(\'DisplayVersion\')) { exit 1 }",
}
} else {
notify { "do not understand ensure agrument: ${ensure}": }
}
}