Skip to content

Commit

Permalink
add version for plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
cristifalcas authored and Dominic Cleal committed Jan 22, 2015
1 parent 56a30e6 commit 33054bc
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 21 deletions.
5 changes: 5 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
# $version:: foreman package version, it's passed to ensure parameter of package resource
# can be set to specific version number, 'latest', 'present' etc.
#
# $plugin_version:: foreman plugins version, it's passed to ensure parameter of plugins package resource
# can be set to 'latest', 'present', 'installed', 'absent'.
#
# $port:: Port on which will foreman proxy listen
# type:integer
#
Expand Down Expand Up @@ -215,6 +218,7 @@
$gpgcheck = $foreman_proxy::params::gpgcheck,
$custom_repo = $foreman_proxy::params::custom_repo,
$version = $foreman_proxy::params::version,
$plugin_version = $foreman_proxy::params::plugin_version,
$port = $foreman_proxy::params::port,
$dir = $foreman_proxy::params::dir,
$user = $foreman_proxy::params::user,
Expand Down Expand Up @@ -304,6 +308,7 @@
validate_bool($ssl, $manage_sudoersd, $use_sudoersd, $register_in_foreman)
validate_array($trusted_hosts)
validate_re($log_level, '^(UNKNOWN|FATAL|ERROR|WARN|INFO|DEBUG)$')
validate_re($plugin_version, '^(installed|present|latest|absent)$')

# Validate puppet params
validate_bool($puppetca, $puppetrun, $puppetssh_wait)
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# set it to some custom location.
$custom_repo = false
$version = 'present'
$plugin_version = 'installed'

# variables
$port = '8443'
Expand Down
3 changes: 2 additions & 1 deletion manifests/plugin.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Installs a smart proxy plugin package
define foreman_proxy::plugin(
$version = $foreman_proxy::plugin_version,
$package = "${foreman_proxy::plugin_prefix}${title}",
) {
# Debian gem2deb converts underscores to hyphens
Expand All @@ -12,6 +13,6 @@
}
}
package { $real_package:
ensure => installed,
ensure => $version,
}
}
22 changes: 12 additions & 10 deletions manifests/plugin/abrt.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#
# $group:: group owner of the configuration file
#
# $version:: plugin package version, it's passed to ensure parameter of package resource
# can be set to specific version number, 'latest', 'present' etc.
#
# $enabled:: enables/disables the plugin
# type:boolean
#
Expand All @@ -30,6 +33,7 @@
#
class foreman_proxy::plugin::abrt (
$enabled = $::foreman_proxy::plugin::abrt::params::enabled,
$version = undef,
$group = $::foreman_proxy::plugin::abrt::params::group,
$abrt_send_log_file = $::foreman_proxy::plugin::abrt::params::abrt_send_log_file,
$spooldir = $::foreman_proxy::plugin::abrt::params::spooldir,
Expand All @@ -39,21 +43,19 @@
$faf_server_ssl_noverify = $::foreman_proxy::plugin::abrt::params::faf_server_ssl_noverify,
$faf_server_ssl_cert = $::foreman_proxy::plugin::abrt::params::faf_server_ssl_cert,
$faf_server_ssl_key = $::foreman_proxy::plugin::abrt::params::faf_server_ssl_key,
) inherits foreman_proxy::plugin::abrt::params {
) inherits foreman_proxy::plugin::abrt::params {

validate_bool($enabled)
validate_absolute_path($abrt_send_log_file)
validate_absolute_path($spooldir)
validate_bool($aggregate_reports)
validate_bool($faf_server_ssl_noverify)
$group_real = pick($group, $::foreman_proxy::user)
validate_string($group_real)

foreman_proxy::plugin { 'abrt': } ->
file { '/etc/foreman-proxy/settings.d/abrt.yml':
ensure => file,
content => template('foreman_proxy/plugin/abrt.yml.erb'),
owner => 'root',
group => $group_real,
mode => '0640',
foreman_proxy::plugin { 'abrt':
version => $version,
} ->
foreman_proxy::settings_file { 'abrt':
template_path => 'foreman_proxy/plugin/abrt.yml.erb',
group => $group,
}
}
5 changes: 5 additions & 0 deletions manifests/plugin/pulp.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#
# $group:: group owner of the configuration file
#
# $version:: plugin package version, it's passed to ensure parameter of package resource
# can be set to specific version number, 'latest', 'present' etc.
#
# $enabled:: enables/disables the pulp plugin
# type:boolean
#
Expand All @@ -17,6 +20,7 @@
class foreman_proxy::plugin::pulp (
$enabled = $::foreman_proxy::plugin::pulp::params::enabled,
$pulpnode_enabled = $::foreman_proxy::plugin::pulp::params::pulpnode_enabled,
$version = undef,
$group = $::foreman_proxy::plugin::pulp::params::group,
$pulp_url = $::foreman_proxy::plugin::pulp::params::pulp_url,
) inherits foreman_proxy::plugin::pulp::params {
Expand All @@ -25,6 +29,7 @@
validate_bool($pulpnode_enabled)

foreman_proxy::plugin {'pulp':
version => $version,
} ->
foreman_proxy::settings_file { 'pulp':
template_path => 'foreman_proxy/plugin/pulp.yml.erb',
Expand Down
30 changes: 20 additions & 10 deletions spec/defines/foreman_proxy_plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
describe 'foreman_proxy::plugin' do
let :title do 'myplugin' end

context 'no parameters' do
let :pre_condition do
'include foreman_proxy'
end
let :pre_condition do
'include foreman_proxy'
end

let :facts do {
:concat_basedir => '/nonexistant',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6.4',
:osfamily => 'RedHat',
} end
let :facts do {
:concat_basedir => '/nonexistant',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6.4',
:osfamily => 'RedHat',
} end

context 'no parameters' do
it 'should install the correct package' do
should contain_package('rubygem-smart_proxy_myplugin').with_ensure('installed')
end
Expand All @@ -30,6 +30,16 @@
end
end

context 'with version parameter' do
let :params do {
:version => 'latest',
} end

it 'should install the correct package' do
should contain_package('rubygem-smart_proxy_myplugin').with_ensure('latest')
end
end

context 'when handling underscores on Red Hat' do
let :params do {
:package => 'my_fun_plugin',
Expand Down

0 comments on commit 33054bc

Please sign in to comment.