Skip to content

Commit

Permalink
Add service_{enable,ensure} (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsok committed Apr 11, 2018
1 parent 2192a37 commit ba7e95c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ Please see [The official documentation](https://www.vaultproject.io/docs/configu

* `service_name`: Customise the name of the system service

* `service_enable`: Tell the OS to enable or disable the service at system startup

* `service_ensure`: Tell the OS whether the service should be running or stopped

* `service_provider`: Customise the name of the system service provider; this also controls the init configuration files that are installed.

* `service_options`: Extra argument to pass to `vault server`, as per: `vault server --help`
Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
$download_url_base = $::vault::params::download_url_base,
$download_extension = $::vault::params::download_extension,
$service_name = $::vault::params::service_name,
$service_enable = $::vault::params::service_enable,
$service_ensure = $::vault::params::service_ensure,
$service_provider = $::vault::params::service_provider,
$manage_service = $::vault::params::manage_service,
$manage_service_file = $::vault::params::manage_service_file,
Expand Down
3 changes: 3 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@

$manage_service = true

$service_enable = true
$service_ensure = 'running'

$service_provider = $facts['service_provider']

case $facts['architecture'] {
Expand Down
4 changes: 2 additions & 2 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
class vault::service {
if $::vault::manage_service {
service { $::vault::service_name:
ensure => running,
enable => true,
ensure => $::vault::service_ensure,
enable => $::vault::service_enable,
provider => $::vault::service_provider,
}
}
Expand Down
15 changes: 15 additions & 0 deletions spec/classes/vault_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,21 @@
}
end

context 'when ensuring the service is disabled' do
let(:params) do
{
service_enable: false,
service_ensure: 'stopped'
}
end

it {
is_expected.to contain_service('vault').
with_ensure('stopped').
with_enable(false)
}
end

case facts[:os]['family']
when 'RedHat'
case facts[:os]['release']['major'].to_i
Expand Down

0 comments on commit ba7e95c

Please sign in to comment.