|
33 | 33 | $components_to_install = 'ALL',
|
34 | 34 | $components_to_remove = undef,
|
35 | 35 | ){
|
36 |
| - if $facts['vmtools_win_version'] { |
37 |
| - #Some version of VMware Tools must be installed... |
38 |
| - info ('An existing version of VMware Tools is currently installed, checking if it needs to be upgraded...') |
39 |
| - if $download_from_vmware { |
40 |
| - #Check if online facts are provisioned, which means this host's internet connection is working |
41 |
| - unless ($facts['vmtools_win_online_version']) and ($facts['vmtools_win_online_file']) { |
42 |
| - fail ('$download_from_vmware was set to true but this host is not able to access http://packages.vmware.com!') |
| 36 | + if $facts['virtual'] == 'vmware' { |
| 37 | + if $facts['vmtools_win_version'] { |
| 38 | + #Some version of VMware Tools must be installed... |
| 39 | + info ('An existing version of VMware Tools is currently installed, checking if it needs to be upgraded...') |
| 40 | + if $download_from_vmware { |
| 41 | + #Check if online facts are provisioned, which means this host's internet connection is working |
| 42 | + unless ($facts['vmtools_win_online_version']) and ($facts['vmtools_win_online_file']) { |
| 43 | + fail ('$download_from_vmware was set to true but this host is not able to access http://packages.vmware.com!') |
| 44 | + } |
| 45 | + #Check against online VMware Tools installation package |
| 46 | + $comparison = vmtools_win::compare_version($facts['vmtools_win_version'], $facts['vmtools_win_online_version']) |
43 | 47 | }
|
44 |
| - #Check against online VMware Tools installation package |
45 |
| - $comparison = vmtools_win::compare_version($facts['vmtools_win_version'], $facts['vmtools_win_online_version']) |
46 |
| - } |
47 |
| - else { |
48 |
| - #Perform validation of self provided package parameters |
49 |
| - unless ($selfprovided_install_file) and ($selfprovided_install_version) and ($selfprovided_file_source) { |
50 |
| - fail ('You have to provide values for the $selfprovided_file_source, $selfprovided_install_file and $selfprovided_install_version parameters when you set use_packages_vmware_com to false!') |
| 48 | + else { |
| 49 | + #Perform validation of self provided package parameters |
| 50 | + unless ($selfprovided_install_file) and ($selfprovided_install_version) and ($selfprovided_file_source) { |
| 51 | + fail ('You have to provide values for the $selfprovided_file_source, $selfprovided_install_file and $selfprovided_install_version parameters when you set use_packages_vmware_com to false!') |
| 52 | + } |
| 53 | + #Check against self-provided VMware Tools installation package |
| 54 | + $comparison = vmtools_win::compare_version($facts['vmtools_win_version'], $selfprovided_install_version) |
51 | 55 | }
|
52 |
| - #Check against self-provided VMware Tools installation package |
53 |
| - $comparison = vmtools_win::compare_version($facts['vmtools_win_version'], $selfprovided_install_version) |
54 |
| - } |
55 |
| - #Now let's check if we need to upgrade, based on the returned $comparison hash |
56 |
| - if has_key($comparison, 'Equal') { |
57 |
| - info ('Installed version is desired version -> no upgrade needed') |
58 |
| - $upgrade_needed = false |
59 |
| - } |
60 |
| - elsif has_key($comparison, 'Lower') { |
61 |
| - info ('Installed version is lower version, checking if its below or above the minimum_version_level...') |
62 |
| - if $comparison['Lower'] <= $minimum_version_level { |
63 |
| - notify {'Installed version is lower version at or below the minimum_version_level -> upgrade needed':} |
64 |
| - $upgrade_needed = true |
| 56 | + #Now let's check if we need to upgrade, based on the returned $comparison hash |
| 57 | + if has_key($comparison, 'Equal') { |
| 58 | + info ('Installed version is desired version -> no upgrade needed') |
| 59 | + $upgrade_needed = false |
| 60 | + } |
| 61 | + elsif has_key($comparison, 'Lower') { |
| 62 | + info ('Installed version is lower version, checking if its below or above the minimum_version_level...') |
| 63 | + if $comparison['Lower'] <= $minimum_version_level { |
| 64 | + notify {'Installed version is lower version at or below the minimum_version_level -> upgrade needed':} |
| 65 | + $upgrade_needed = true |
| 66 | + } |
| 67 | + if $comparison['Lower'] > $minimum_version_level { |
| 68 | + info ('Installed version is lower version but not at the minimum_version_level -> no upgrade needed') |
| 69 | + $upgrade_needed = false |
| 70 | + } |
65 | 71 | }
|
66 |
| - if $comparison['Lower'] > $minimum_version_level { |
67 |
| - info ('Installed version is lower version but not at the minimum_version_level -> no upgrade needed') |
| 72 | + elsif has_key($comparison, 'Higher') { |
| 73 | + info ('Installed version is higher version -> no upgrade needed') |
| 74 | + $upgrade_needed = false |
| 75 | + } |
| 76 | + else { |
| 77 | + info ('Unable to determine version comparison, skipping installation') |
68 | 78 | $upgrade_needed = false
|
69 | 79 | }
|
70 |
| - } |
71 |
| - elsif has_key($comparison, 'Higher') { |
72 |
| - info ('Installed version is higher version -> no upgrade needed') |
73 |
| - $upgrade_needed = false |
74 | 80 | }
|
75 | 81 | else {
|
76 |
| - info ('Unable to determine version comparison, skipping installation') |
77 |
| - $upgrade_needed = false |
| 82 | + notify {'There are currently no VMware Tools installed -> install needed':} |
| 83 | + $upgrade_needed = true |
78 | 84 | }
|
79 |
| - } |
80 |
| - else { |
81 |
| - notify {'There are currently no VMware Tools installed -> install needed':} |
82 |
| - $upgrade_needed = true |
83 |
| - } |
84 |
| - |
85 |
| - #Build values for installation or cleanup |
86 |
| - if $download_from_vmware { |
87 |
| - $file_source = 'http://packages.vmware.com/tools/releases/latest/windows/x64' |
88 |
| - $file_name = $facts['vmtools_win_online_file'] |
89 |
| - } |
90 |
| - else { |
91 |
| - $file_source = $selfprovided_file_source |
92 |
| - $file_name = $selfprovided_install_file |
93 |
| - } |
94 | 85 |
|
95 |
| - if $upgrade_needed { |
96 |
| - #Build installation parameters |
97 |
| - $install_options_base = ['/S', '/v"/qn'] |
98 |
| - |
99 |
| - if $logfile_location { |
100 |
| - $install_options_log1 = '/l*v' |
101 |
| - $install_options_log2 = "\"\"${logfile_location}\"\"" |
| 86 | + #Build values for installation or cleanup |
| 87 | + if $download_from_vmware { |
| 88 | + $file_source = 'http://packages.vmware.com/tools/releases/latest/windows/x64' |
| 89 | + $file_name = $facts['vmtools_win_online_file'] |
102 | 90 | }
|
103 | 91 | else {
|
104 |
| - $install_options_log1 = '' |
105 |
| - $install_options_log2 = '' |
| 92 | + $file_source = $selfprovided_file_source |
| 93 | + $file_name = $selfprovided_install_file |
106 | 94 | }
|
107 | 95 |
|
108 |
| - if $prevent_reboot { |
109 |
| - $install_options_reboot = 'REBOOT=ReallySuppress' |
110 |
| - } |
111 |
| - else { |
112 |
| - $install_options_reboot = 'REBOOT=Suppress' |
113 |
| - } |
| 96 | + if $upgrade_needed { |
| 97 | + #Build installation parameters |
| 98 | + $install_options_base = ['/S', '/v"/qn'] |
114 | 99 |
|
115 |
| - if $components_to_remove { |
116 |
| - $install_options_add = "ADDLOCAL=${components_to_install}" |
117 |
| - $install_options_remove = "REMOVE=${components_to_remove}\"" |
118 |
| - } |
119 |
| - else { |
120 |
| - $install_options_add = "ADDLOCAL=${components_to_install}\"" |
121 |
| - $install_options_remove = '' |
122 |
| - } |
| 100 | + if $logfile_location { |
| 101 | + $install_options_log1 = '/l*v' |
| 102 | + $install_options_log2 = "\"\"${logfile_location}\"\"" |
| 103 | + } |
| 104 | + else { |
| 105 | + $install_options_log1 = '' |
| 106 | + $install_options_log2 = '' |
| 107 | + } |
123 | 108 |
|
124 |
| - $install_options_extra = split("${install_options_log1} ${install_options_log2} ${install_options_reboot} ${install_options_add} ${install_options_remove}", '\s+') |
125 |
| - $install_options = concat($install_options_base, $install_options_extra) |
| 109 | + if $prevent_reboot { |
| 110 | + $install_options_reboot = 'REBOOT=ReallySuppress' |
| 111 | + } |
| 112 | + else { |
| 113 | + $install_options_reboot = 'REBOOT=Suppress' |
| 114 | + } |
126 | 115 |
|
127 |
| - #Install VMware Tools |
128 |
| - file { "${local_temp_folder}/${file_name}": |
129 |
| - ensure => present, |
130 |
| - source => "${file_source}/${file_name}", |
131 |
| - before => Package['VMwareTools_Windows'], |
132 |
| - } |
133 |
| - package { 'VMwareTools_Windows': |
134 |
| - ensure => present, |
135 |
| - provider => windows, |
136 |
| - source => "${local_temp_folder}/${file_name}", |
137 |
| - install_options => $install_options, |
| 116 | + if $components_to_remove { |
| 117 | + $install_options_add = "ADDLOCAL=${components_to_install}" |
| 118 | + $install_options_remove = "REMOVE=${components_to_remove}\"" |
| 119 | + } |
| 120 | + else { |
| 121 | + $install_options_add = "ADDLOCAL=${components_to_install}\"" |
| 122 | + $install_options_remove = '' |
| 123 | + } |
| 124 | + |
| 125 | + $install_options_extra = split("${install_options_log1} ${install_options_log2} ${install_options_reboot} ${install_options_add} ${install_options_remove}", '\s+') |
| 126 | + $install_options = concat($install_options_base, $install_options_extra) |
| 127 | + |
| 128 | + #Install VMware Tools |
| 129 | + file { "${local_temp_folder}/${file_name}": |
| 130 | + ensure => present, |
| 131 | + source => "${file_source}/${file_name}", |
| 132 | + before => Package['VMwareTools_Windows'], |
| 133 | + } |
| 134 | + package { 'VMwareTools_Windows': |
| 135 | + ensure => present, |
| 136 | + provider => windows, |
| 137 | + source => "${local_temp_folder}/${file_name}", |
| 138 | + install_options => $install_options, |
| 139 | + } |
138 | 140 | }
|
139 |
| - } |
140 |
| - else { |
141 |
| - #Cleanup installation file |
142 |
| - file { "${local_temp_folder}/${file_name}": |
143 |
| - ensure => absent, |
| 141 | + else { |
| 142 | + #Cleanup installation file |
| 143 | + file { "${local_temp_folder}/${file_name}": |
| 144 | + ensure => absent, |
| 145 | + } |
144 | 146 | }
|
145 | 147 | }
|
146 | 148 | }
|
0 commit comments