Skip to content

Commit

Permalink
(MODULES-1479) Add package_manage parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
juniorsysadmin committed Jan 7, 2015
1 parent 15bd628 commit 16ec97e
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
14 changes: 13 additions & 1 deletion README.markdown
Expand Up @@ -88,6 +88,14 @@ class { '::ntp':
}
```

###I'd like to configure and run ntp, but I don't need to install it.

```puppet
class { '::ntp':
package_manage => false,
}
```

###Looks great! But I'd like a different template; we need to do something unique here.

```puppet
Expand Down Expand Up @@ -168,7 +176,11 @@ Array of trusted keys.

####`package_ensure`

Sets the ntp package to be installed. Can be set to 'present', 'latest', or a specific version.
Sets the ntp package to be installed. Can be set to 'present', 'latest', or a specific version.

####`package_manage`

Determines whether to manage the ntp package. Defaults to true.

####`package_name`

Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Expand Up @@ -12,6 +12,7 @@
$keys_requestkey = $ntp::params::keys_requestkey,
$keys_trusted = $ntp::params::keys_trusted,
$package_ensure = $ntp::params::package_ensure,
$package_manage = $ntp::params::package_manage,
$package_name = $ntp::params::package_name,
$panic = $ntp::params::panic,
$preferred_servers = $ntp::params::preferred_servers,
Expand Down
8 changes: 6 additions & 2 deletions manifests/install.pp
@@ -1,8 +1,12 @@
#
class ntp::install inherits ntp {

package { $package_name:
ensure => $package_ensure,
if $package_manage {

package { $package_name:
ensure => $package_ensure,
}

}

}
1 change: 1 addition & 0 deletions manifests/params.pp
Expand Up @@ -9,6 +9,7 @@
$keys_trusted = []
$logfile = undef
$package_ensure = 'present'
$package_manage = true
$preferred_servers = []
$service_enable = true
$service_ensure = 'running'
Expand Down
18 changes: 16 additions & 2 deletions spec/acceptance/ntp_install_spec.rb
@@ -1,5 +1,7 @@
require 'spec_helper_acceptance'

packagemanage = true

case fact('osfamily')
when 'FreeBSD'
packagename = 'net/ntp'
Expand Down Expand Up @@ -30,9 +32,9 @@
end

describe 'ntp::install class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
it 'installs the package' do
it 'installs the package when package_manage is set to true' do
apply_manifest(%{
class { 'ntp': }
class { 'ntp': package_manage => true }
}, :catch_failures => true)
end

Expand All @@ -41,4 +43,16 @@ class { 'ntp': }
it { should be_installed }
end
end

it 'does not install the package when package_manage is set to false' do
apply_manifest(%{
class { 'ntp': package_manage => false }
}, :catch_failures => true)
end

Array(packagename).each do |package|
describe package(package) do
it { should_not be_installed }
end
end
end
5 changes: 5 additions & 0 deletions spec/classes/ntp_spec.rb
Expand Up @@ -143,6 +143,11 @@
let(:params) {{ :package_ensure => 'present', :package_name => ['hambaby'] }}
it { should contain_package('hambaby') }
end

describe 'should allow the package to be unmanaged' do
let(:params) {{ :package_manage => false, :package_name => ['ntp'], }}
it { should_not contain_package('ntp') }
end
end

describe 'ntp::service' do
Expand Down

0 comments on commit 16ec97e

Please sign in to comment.