Skip to content

Autodetect supported instead of using Hiera #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2021
Merged
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
3 changes: 0 additions & 3 deletions data/Debian.Debian.10.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/Debian.Debian.7.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/Debian.Debian.8.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/Debian.Debian.9.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/Debian.Ubuntu.14.04.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/Debian.Ubuntu.16.04.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/Debian.Ubuntu.18.04.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/FreeBSD.FreeBSD.10.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/FreeBSD.FreeBSD.11.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/FreeBSD.FreeBSD.12.yaml

This file was deleted.

1 change: 0 additions & 1 deletion data/RedHat.CentOS.6.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---

openvmtools::manage_epel: true
openvmtools::supported: true
3 changes: 0 additions & 3 deletions data/RedHat.CentOS.7.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/RedHat.CentOS.8.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/RedHat.Fedora.19.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/RedHat.Fedora.20.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/RedHat.Fedora.21.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/RedHat.Fedora.22.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/RedHat.Fedora.23.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/RedHat.Fedora.24.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/RedHat.Fedora.25.yaml

This file was deleted.

1 change: 0 additions & 1 deletion data/RedHat.OracleLinux.6.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---

openvmtools::manage_epel: true
openvmtools::supported: true
3 changes: 0 additions & 3 deletions data/RedHat.OracleLinux.7.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/RedHat.OracleLinux.8.yaml

This file was deleted.

1 change: 0 additions & 1 deletion data/RedHat.RedHat.6.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---

openvmtools::manage_epel: true
openvmtools::supported: true
3 changes: 0 additions & 3 deletions data/RedHat.RedHat.7.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/RedHat.RedHat.8.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/Suse.OpenSUSE.11.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/Suse.OpenSUSE.12.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/Suse.OpenSUSE.13.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/Suse.OpenSUSE.15.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/Suse.OpenSUSE.42.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/Suse.SLES.12.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/Suse.SLES.13.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/Suse.SLES.14.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/Suse.SLES.15.yaml

This file was deleted.

18 changes: 18 additions & 0 deletions functions/supported.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# @summary Returns whether the currently loaded OS is supported by the module
#
# This function uses the current facts to check if the current Operating System
# and its release or major release is supported.
#
# @param mod
# The module name to check.
#
# @return Whether the current OS is supported for the given module
#
# @example Using the Puppet built in global $module_name
# openvmtools::supported($module_name)
function openvmtools::supported(String[1] $mod) >> Boolean {
$metadata = load_module_metadata($mod)
$metadata['operatingsystem_support'].any |$os| {
$os['operatingsystem'] == $facts['os']['name'] and $facts['os']['release']['major'] in $os['operatingsystemrelease']
}
}
4 changes: 2 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@
Boolean $service_hasstatus = true,
Variant[String[1],Array[String[1]]] $service_name = ['vgauthd', 'vmtoolsd'],
Optional[String[1]] $service_pattern = undef,
Boolean $supported = false,
Optional[Boolean] $supported = undef,
Boolean $uninstall_vmware_tools = false,
Boolean $with_desktop = false,
) {
if $facts['virtual'] == 'vmware' {
if $supported {
if pick($supported, openvmtools::supported($module_name)) {
if $ensure == 'present' {
$package_ensure = $autoupgrade ? {
true => 'latest',
Expand Down
20 changes: 20 additions & 0 deletions spec/functions/supported_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'spec_helper'

describe 'openvmtools::supported' do
context 'On Debian 10' do
let(:facts) do
{
os: {
name: 'Debian',
release: {
major: '10',
}
}
}
end

it 'returns true' do
is_expected.to run.with_params('openvmtools').and_return(true)
end
end
end