From a2638b77c23d9b132805d2bedd2fd36f5550815d Mon Sep 17 00:00:00 2001 From: Artur Molchanov Date: Mon, 17 Feb 2020 14:37:08 +0300 Subject: [PATCH 1/2] Add a parameter wazuh_api::manage_nodejs_package Add a parameter wazuh::wazuh_api::manage_nodejs_package for controlling nodejs package installation. if manage_nodejs_package == true (by default) nodejs repo and package will be installed. Otherwise the repo and the package should be configured by the user. --- manifests/wazuh_api.pp | 53 +++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/manifests/wazuh_api.pp b/manifests/wazuh_api.pp index 67708a64..049fdada 100644 --- a/manifests/wazuh_api.pp +++ b/manifests/wazuh_api.pp @@ -1,37 +1,22 @@ # Wazuh App Copyright (C) 2019 Wazuh Inc. (License GPLv2) # Wazuh API installation class wazuh::wazuh_api ( - - $wazuh_api_package = 'wazuh-api', - $wazuh_api_service = 'wazuh-api', - $wazuh_api_version = '3.11.3-1', - $nodejs_package = 'nodejs' - + Boolean $manage_nodejs_package = true, + String[1] $nodejs_package = 'nodejs', + String[1] $wazuh_api_package = 'wazuh-api', + String[1] $wazuh_api_service = 'wazuh-api', + String[1] $wazuh_api_version = '3.11.3-1' ){ + if $manage_nodejs_package { + contain wazuh::wazuh_api::nodejs + } if $::osfamily == 'Debian' { - exec { 'Updating repositories...': - path => '/usr/bin', - command => 'curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -', - - } - package { $nodejs_package: - provider => 'apt', - } package { $wazuh_api_package: ensure => $wazuh_api_version, provider => 'apt', } - - }else{ - exec { 'Updating repositories...': - path => '/usr/bin', - command => 'curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -', - - } - package { $nodejs_package: - provider => 'yum', - } + } else { package { $wazuh_api_package: ensure => $wazuh_api_version, provider => 'yum', @@ -42,7 +27,27 @@ ensure => running, enable => true, provider => 'systemd', + require => Package[$wazuh_api_package], } +} +class wazuh::wazuh_api::nodejs { + if $::osfamily == 'Debian' { + exec { 'Updating repositories...': + path => '/usr/bin', + command => 'curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -', + } + package { $nodejs_package: + provider => 'apt', + } + } else { + exec { 'Updating repositories...': + path => '/usr/bin', + command => 'curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -', + } + package { $nodejs_package: + provider => 'yum', + } + } } From d1f4aa74dc134c40d99c695444e98732f70e408d Mon Sep 17 00:00:00 2001 From: rshad Date: Mon, 9 Mar 2020 18:43:01 +0000 Subject: [PATCH 2/2] move var: nodejs_package to nodejs class --- manifests/wazuh_api.pp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/wazuh_api.pp b/manifests/wazuh_api.pp index be905e7d..9e097a77 100644 --- a/manifests/wazuh_api.pp +++ b/manifests/wazuh_api.pp @@ -6,7 +6,6 @@ $wazuh_api_package = 'wazuh-api', $wazuh_api_service = 'wazuh-api', $wazuh_api_version = '3.11.4-1', - $nodejs_package = 'nodejs', ){ if $manage_nodejs_package { @@ -33,7 +32,9 @@ } } -class wazuh::wazuh_api::nodejs { +class wazuh::wazuh_api::nodejs ( + $nodejs_package = 'nodejs' +){ if $::osfamily == 'Debian' { exec { 'Updating repositories...': path => '/usr/bin',