Puppet Class: vulnerability::install::windows
- Defined in:
- manifests/install/windows.pp
Summary
This class takes care of installing `grype` on windows systems.Overview
vulnerability::install::windows
See the file “LICENSE” for the full license governing this code.
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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'manifests/install/windows.pp', line 25
class vulnerability::install::windows (
String[1] $base_url,
Stdlib::Absolutepath $root_dir,
Stdlib::Absolutepath $temp_dir,
String[1] $version
) {
unless defined(File[$temp_dir]) {
file { $temp_dir:
ensure => 'directory',
}
}
#
# First ensure all target directories exsit
#
$dirs = [
$root_dir,
"${root_dir}/bin",
"${root_dir}/etc",
]
file { $dirs:
ensure => 'directory',
owner => 'Administrator',
}
if $facts['grype_version'] != $version {
$source_file = "grype_${version}_windows_amd64.zip"
$extract_path = "${temp_dir}/grype_${version.regsubst('\.','_', 'G')}"
file { $extract_path:
ensure => 'directory',
}
-> archive { "${temp_dir}/${source_file}":
ensure => 'present',
source => "${base_url}/v${version}/${source_file}",
allow_insecure => true,
extract => true,
extract_path => $extract_path,
cleanup => true,
provider => 'ruby',
}
-> file { "${root_dir}/bin/grype.exe":
ensure => 'file',
source => "file:///${extract_path}/grype.exe",
owner => 'Administrator',
mode => '0755',
}
cleanup { 'Cleanup downloads':
file_name => $extract_path,
}
}
file { "${root_dir}/etc/grype_yaml.tpl":
ensure => 'file',
source => 'puppet:///modules/vulnerability/grype_yaml.tpl',
owner => 'Administrator',
mode => '0755',
}
}
|