diff --git a/manifests/config.pp b/manifests/config.pp index fce61b6a..c7096151 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -15,7 +15,7 @@ $purge = true, ) { - if $::consul::init_style { + if $::consul::init_style != 'unmanaged' { case $::consul::init_style { 'upstart': { diff --git a/manifests/init.pp b/manifests/init.pp index 0aeefd58..22856d31 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,132 +1,133 @@ # == Class: consul -# +# # Installs, configures and manages consul -# +# # === Parameters -# +# # [*acls*] # Hash of consul_acl resources to create. -# +# # [*arch*] # Architecture of consul binary to download. -# +# # [*archive_path*] # Path used when installing consul via the url. -# +# # [*bin_dir*] # Directory to create the symlink to the consul binary in. -# +# # [*checks*] # Hash of consul::check resources to create. -# +# # [*config_defaults*] # Configuration defaults hash. Gets merged with config_hash. -# +# # [*config_dir*] # Directory to place consul configuration files in. -# +# # [*config_hash*] # Use this to populate the JSON config file for consul. -# +# # [*config_mode*] # Use this to set the JSON config file mode for consul. -# +# # [*download_extension*] # The extension of the archive file containing the consul binary to download. -# +# # [*download_url*] # Fully qualified url to the location of the archive file containing the consul binary. -# +# # [*download_url_base*] # Base url to the location of the archive file containing the consul binary. -# +# # [*extra_groups*] # Extra groups to add the consul system user to. -# +# # [*extra_options*] # Extra arguments to be passed to the consul agent -# +# # [*group*] # Name of the group that should own the consul configuration files. -# +# # [*init_style*] -# What style of init system your system uses. -# +# What style of init system your system uses. Set to 'unmanaged' to disable +# managing init system files for the consul service entirely. +# # [*install_method*] # Valid strings: `package` - install via system package # `url` - download and extract from a url. Defaults to `url`. # `none` - disable install. -# +# # [*join_wan*] # Whether to join the wan on service start. -# +# # [*manage_group*] # Whether to create/manage the group that should own the consul configuration files. -# +# # [*manage_service*] # Whether to manage the consul service. -# +# # [*manage_user*] # Whether to create/manage the user that should own consul's configuration files. -# +# # [*os*] # OS component in the name of the archive file containing the consul binary. -# +# # [*package_ensure*] # Only valid when the install_method == package. Defaults to `latest`. -# +# # [*package_name*] # Only valid when the install_method == package. Defaults to `consul`. -# +# # [*pretty_config*] # Generates a human readable JSON config file. Defaults to `false`. -# +# # [*pretty_config_indent*] # Toggle indentation for human readable JSON file. Defaults to `4`. -# +# # [*purge_config_dir*] # Purge config files no longer generated by Puppet -# +# # [*restart_on_change*] # Determines whether to restart consul agent on $config_hash changes. # This will not affect reloads when service, check or watch configs change. # Defaults to `true`. -# +# # [*service_enable*] # Whether to enable the consul service to start at boot. -# +# # [*service_ensure*] # Whether the consul service should be running or not. -# +# # [*services*] # Hash of consul::service resources to create. -# +# # [*ui_download_extension*] # The extension of the archive file containing the consul ui to download. -# +# # [*ui_download_url*] # Fully qualified url to the location of the archive file containing the consul ui. -# +# # [*ui_download_url_base*] # Base url to the location of the archive file containing the consul ui. -# +# # [*ui_package_ensure*] # Only valid when the install_method == package. Defaults to `latest`. -# +# # [*ui_package_name*] # Only valid when the install_method == package. Defaults to `consul_ui`. -# +# # [*user*] # Name of the user that should own the consul configuration files. -# +# # [*version*] # Specify version of consul binary to download. -# +# # [*watches*] # Hash of consul::watch resources to create. -# +# # === Examples -# +# # @example # class { '::consul': # config_hash => { @@ -136,7 +137,7 @@ # 'retry-join' => ['172.16.0.1'], # }, # } -# +# class consul ( $acls = $::consul::params::acls, $arch = $::consul::params::arch, diff --git a/manifests/params.pp b/manifests/params.pp index b0cf905d..660914f3 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -93,9 +93,6 @@ } elsif $::operatingsystem == 'Amazon' { $init_style = 'init' } else { - $init_style = undef - } - if $init_style == undef { - fail('Unsupported OS') + fail('Cannot determine init_style, unsupported OS') } } diff --git a/manifests/run_service.pp b/manifests/run_service.pp index e1042763..4868c68c 100644 --- a/manifests/run_service.pp +++ b/manifests/run_service.pp @@ -5,17 +5,22 @@ # class consul::run_service { - $init_selector = $::consul::init_style ? { + $service_name = $::consul::init_style ? { 'launchd' => 'io.consul.daemon', default => 'consul', } - if $::consul::manage_service == true and $::consul::init_style { + $service_provider = $::consul::init_style ? { + 'unmanaged' => undef, + default => $::consul::init_style, + } + + if $::consul::manage_service == true { service { 'consul': ensure => $::consul::service_ensure, - name => $init_selector, + name => $service_name, enable => $::consul::service_enable, - provider => $::consul::init_style, + provider => $service_provider, } } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 8466b70d..e1c5a4ea 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -694,9 +694,9 @@ it { should contain_file('/lib/systemd/system/consul.service').with_content(/consul agent/) } end - context "When asked not to manage the init_style" do - let(:params) {{ :init_style => false }} - it { should contain_class('consul').with_init_style(false) } + context "When asked not to manage the init system" do + let(:params) {{ :init_style => 'unmanaged' }} + it { should contain_class('consul').with_init_style('unmanaged') } it { should_not contain_file("/etc/init.d/consul") } it { should_not contain_file("/lib/systemd/system/consul.service") } end