Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
$virtualbox_build = '112440'
$virtualbox_url = "http://download.virtualbox.org/virtualbox/${virtualbox_version}/VirtualBox-${virtualbox_version}-${virtualbox_build}-OSX.dmg"
$virtualbox_key = undef
$vmware_version = undef
$vmware_urlbase = undef
$vmware_package = undef


# ### webstack ####
Expand Down Expand Up @@ -167,6 +170,10 @@
'source' => 'https://www.virtualbox.org/download/oracle_vbox.asc',
}
}
$vmware_version = '14.0.0-6661328'
$vmware_urlbase = 'https://download3.vmware.com/software/player/file'
$vmware_package = "VMware-Player-${vmware_version}.x86_64.bundle"

} elsif ($::operatingsystem == 'windows') and (versioncmp($::operatingsystemrelease, '7') >= 0) {
# ### init ####
include '::chocolatey'
Expand Down Expand Up @@ -202,6 +209,10 @@
$virtualbox_build = undef
$virtualbox_url = undef
$virtualbox_key = undef
$vmware_version = undef
$vmware_urlbase = undef
$vmware_package = undef

} else {
fail("The ${module_name} module is not supported on ${::operatingsystem} with version ${::operatingsystemrelease}.")
}
Expand Down
42 changes: 42 additions & 0 deletions manifests/virtualization/vmware.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# vmware.pp
# Install VMware Workstation Player for OS X, Ubuntu, or Windows
# https://www.vmware.com/products/workstation-player.html
#
#

class software::virtualization::vmware (
$ensure = $software::params::software_ensure,
$version = $software::params::vmware_version,
$urlbase = $software::params::vmware_urlbase,
$package = $software::params::vmware_package,
) inherits software::params {

validate_string($ensure)

case $::operatingsystem {
'Debian', 'Ubuntu': {
validate_string($version, $urlbase, $package)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we switch to puppet 4 type validations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would that look like? (Sorry!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, type hinting, okay. That's the somewhat

class software::virtualization::vmware (
  Enum['present', 'absent'] $ensure = $software::params::software_ensure,
  String $version = $software::params::vmware_version,
  String $url = $software::params::vmware_urlbase,
  String $package = $software::params::vmware_package,
) inherits software::params {

There may be some types better suited for (semantic) version and URL than String, and Optional[] probably needs to be wrapped around some. What's your preference?

Hmmm ... (I'm trying to avoid the "I'm away from Puppet, currently" argument) 😏 🤐 😳

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stdlib has some types, but other than that I usually stick with the built in ones.
https://github.com/puppetlabs/puppetlabs-stdlib/tree/master/types


$vmware_installer = "/tmp/${package}"
$vmware_install_cmd = "${vmware_installer} --console --eulas-agreed --required"
$vmware_uninstall_cmd = "${vmware_installer} --uninstall-product=vmware-player --required"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IS this variable ever used? If you want it around for reference, use a comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should ideally run this when ensure is absent.


file { $vmware_installer:
source => "${urlbase}/${package}",
owner => 'root',
group => 'root',
mode => '0755',
}
-> exec { $vmware_install_cmd:
path => ['/usr/sbin', '/usr/bin', '/sbin', '/bin'],
# NOTE: This will make it difficult to upgrade to a newer version
# (VMware-Player will need to be uninstalled prior to upgrade)
creates => '/usr/bin/vmplayer',
}
}
default: {
fail("The ${name} class is not supported on ${::operatingsystem}.")
}
}

}
19 changes: 19 additions & 0 deletions spec/classes/software_virtualization_vmware_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'spec_helper'

describe 'software::virtualization::vmware' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end

context 'with defaults' do
if facts[:operatingsystem] =~ %r{^(Debian|Ubuntu)$}
it { is_expected.to compile.with_all_deps }
else
it { is_expected.to compile.and_raise_error(%r{is not supported on }) }
end
end
end
end
end