diff --git a/README.md b/README.md index 38ea142..392dcbd 100644 --- a/README.md +++ b/README.md @@ -832,6 +832,17 @@ Optional. Sets the array of runmodes to apply to the AEM instance. Do not use th ##### `sample_content` Optional. Sets whether or not to include the sample content (e.g. Geometrixx). Valid options: `true` or `false`. Default: `true`. [AEM Documentation][AEM Sample Content]. +##### `service_options` +Optional. Hash. Sets the service options, pretty much only used for the systemd implementation. Default: + +``` +{ + 'TimeoutStopSec' => '4min', + 'KillSignal' => 'SIGCONT', + 'PrivateTmp' => true +} +``` + ##### `snooze` Optional. Sets the wait period between checks for installation completion. When monitoring the system for up state, this is the wait period between checks. Value is specified in seconds. Valid options: any number. Default: `10`. diff --git a/manifests/instance.pp b/manifests/instance.pp index cd9b107..25d9e90 100644 --- a/manifests/instance.pp +++ b/manifests/instance.pp @@ -4,28 +4,29 @@ # # define aem::instance ( - $ensure = 'present', - $context_root = undef, - $debug_port = undef, - $group = 'aem', - $home = undef, - $jvm_mem_opts = '-Xmx1024m', - $jvm_opts = undef, - $manage_group = true, - $manage_home = true, - $manage_user = true, - $osgi_configs = undef, - $crx_packages = undef, - $port = 4502, - $runmodes = [], - $sample_content = true, - $snooze = 10, - $source = undef, - $status = 'enabled', - $timeout = 600, - $type = author, - $user = 'aem', - $version = undef) { + $ensure = 'present', + $context_root = undef, + $debug_port = undef, + $group = 'aem', + $home = undef, + $jvm_mem_opts = '-Xmx1024m', + $jvm_opts = undef, + $manage_group = true, + $manage_home = true, + $manage_user = true, + $osgi_configs = undef, + $crx_packages = undef, + $port = 4502, + $runmodes = [], + $sample_content = true, + $service_options = undef, + $snooze = 10, + $source = undef, + $status = 'enabled', + $timeout = 600, + $type = author, + $user = 'aem', + $version = undef) { anchor { "aem::${name}::begin": } @@ -112,11 +113,12 @@ if $status != 'unmanaged' { aem::service { $name : - ensure => $ensure, - status => $status, - home => $_home, - user => $user, - group => $group, + ensure => $ensure, + status => $status, + home => $_home, + user => $user, + group => $group, + service_options => $service_options } } diff --git a/manifests/params.pp b/manifests/params.pp index b2c4650..ad157d6 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -9,5 +9,4 @@ $puppetgem = 'puppet_gem' $xmlsimple_ver = '>=1.1.5' - } \ No newline at end of file diff --git a/manifests/service.pp b/manifests/service.pp index e3e7d39..3beb6e6 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -5,11 +5,12 @@ # Based on Elastic Search service management. # define aem::service ( - $ensure = 'present', - $group = 'aem', - $home = undef, - $status = 'enabled', - $user = 'aem', + $ensure = 'present', + $group = 'aem', + $home = undef, + $status = 'enabled', + $user = 'aem', + $service_options = { 'TimeoutStopSec' => '4min', 'KillSignal' => 'SIGCONT', 'PrivateTmp' => true } ) { @@ -64,11 +65,12 @@ } 'systemd' : { aem::service::systemd { $name : - ensure => $ensure, - status => $status, - group => $group, - home => $home, - user => $user, + ensure => $ensure, + status => $status, + group => $group, + home => $home, + user => $user, + service_options => $service_options } } default : { diff --git a/manifests/service/systemd.pp b/manifests/service/systemd.pp index 360d383..368f10e 100644 --- a/manifests/service/systemd.pp +++ b/manifests/service/systemd.pp @@ -11,7 +11,8 @@ $status, $group, $home, - $user + $user, + $service_options ) { # Setup the system state. diff --git a/metadata.json b/metadata.json index bee1963..b345367 100644 --- a/metadata.json +++ b/metadata.json @@ -28,21 +28,21 @@ { "operatingsystem": "CentOS", "operatingsystemrelease": [ - "7.2" + "7.4", + "7.6" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "14.04", - "16.04" + "16.04", + "18.04" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ - "7", - "8" + "9" ] } ], diff --git a/spec/acceptance/aem/service_spec.rb b/spec/acceptance/aem/service_spec.rb new file mode 100644 index 0000000..4009d4d --- /dev/null +++ b/spec/acceptance/aem/service_spec.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require 'spec_helper_acceptance' + +describe 'systemctl service configs' do + + it 'should create systemctl service file' do + shell('test -f /lib/systemd/system/aem-author.service', acceptable_exit_codes: 0) + end + + it 'should specify the timeout' do + shell('grep TimeoutStopSec=4min /lib/systemd/system/aem-author.service', acceptable_exit_codes: 0) + end + + it 'should specify the kill signal' do + shell('grep KillSignal=SIGCONT /lib/systemd/system/aem-author.service', acceptable_exit_codes: 0) + end + + it 'should specify the private tmp' do + shell('grep PrivateTmp=true /lib/systemd/system/aem-author.service', acceptable_exit_codes: 0) + end +end diff --git a/spec/defines/service/systemd_spec.rb b/spec/defines/service/systemd_spec.rb index 184bdc9..56f8b41 100644 --- a/spec/defines/service/systemd_spec.rb +++ b/spec/defines/service/systemd_spec.rb @@ -24,7 +24,8 @@ status: 'enabled', home: '/opt/aem', user: 'aem', - group: 'aem' + group: 'aem', + service_options: { 'TimeoutStopSec' => '4min', 'KillSignal' => 'SIGCONT', 'PrivateTmp' => true } } end @@ -48,4 +49,106 @@ end + describe 'aem-author.service file' do + context 'default contents' do + let(:params) do + default_params + end + it do + is_expected.to contain_file( + '/lib/systemd/system/aem-aem.service' + ).with_content( + %r|PIDFile=/opt/aem/crx-quickstart/conf/cq.pid| + ) + end + it do + is_expected.to contain_file( + '/lib/systemd/system/aem-aem.service' + ).with_content( + /User=aem/ + ) + end + it do + is_expected.to contain_file( + '/lib/systemd/system/aem-aem.service' + ).with_content( + /Group=aem/ + ) + end + it do + is_expected.to contain_file( + '/lib/systemd/system/aem-aem.service' + ).with_content( + %r|ExecStart=/opt/aem/crx-quickstart/bin/start| + ) + end + it do + is_expected.to contain_file( + '/lib/systemd/system/aem-aem.service' + ).with_content( + %r|ExecStop=/opt/aem/crx-quickstart/bin/stop| + ) + end + it do + is_expected.to contain_file( + '/lib/systemd/system/aem-aem.service' + ).with_content( + /TimeoutStopSec=4min/ + ) + end + it do + is_expected.to contain_file( + '/lib/systemd/system/aem-aem.service' + ).with_content( + /KillSignal=SIGCONT/ + ) + end + it do + is_expected.to contain_file( + '/lib/systemd/system/aem-aem.service' + ).with_content( + /PrivateTmp=true/ + ) + end + end + + context 'custom properties' do + let(:params) do + { + ensure: 'present', + status: 'enabled', + home: '/opt/aem', + user: 'aem', + group: 'aem', + service_options: { + 'TimeoutStopSec' => '10min', + 'KillSignal' => 'SIGKILL', + 'PrivateTmp' => true + } + } + end + it do + is_expected.to contain_file( + '/lib/systemd/system/aem-aem.service' + ).with_content( + /TimeoutStopSec=10min/ + ) + end + it do + is_expected.to contain_file( + '/lib/systemd/system/aem-aem.service' + ).with_content( + /KillSignal=SIGKILL/ + ) + end + it do + is_expected.to contain_file( + '/lib/systemd/system/aem-aem.service' + ).with_content( + /PrivateTmp=true/ + ) + end + end + end + end diff --git a/spec/defines/service_spec.rb b/spec/defines/service_spec.rb index 1cd7795..8585baf 100644 --- a/spec/defines/service_spec.rb +++ b/spec/defines/service_spec.rb @@ -59,7 +59,8 @@ status: 'enabled', group: 'aem', home: '/opt/aem', - user: 'aem' + user: 'aem', + service_options: { 'TimeoutStopSec' => '4min', 'KillSignal' => 'SIGCONT', 'PrivateTmp' => true } ) end end @@ -125,7 +126,8 @@ status: 'enabled', group: 'aem', home: '/opt/aem', - user: 'aem' + user: 'aem', + service_options: { 'TimeoutStopSec' => '4min', 'KillSignal' => 'SIGCONT', 'PrivateTmp' => true } ) end end @@ -171,7 +173,8 @@ status: 'enabled', group: 'aem', home: '/opt/aem', - user: 'aem' + user: 'aem', + service_options: { 'TimeoutStopSec' => '4min', 'KillSignal' => 'SIGCONT', 'PrivateTmp' => true } ) end end diff --git a/templates/etc/init.d/systemd.erb b/templates/etc/init.d/systemd.erb index 2f7eef1..89baa90 100644 --- a/templates/etc/init.d/systemd.erb +++ b/templates/etc/init.d/systemd.erb @@ -11,7 +11,7 @@ Type=forking PIDFile=<%= @home %>/crx-quickstart/conf/cq.pid User=<%= @user %> Group=<%= @group %> -ExecStart=<%= @home %>/crx-quickstart/bin/start +ExecStart=<%= @home %>/crx-quickstart/bin/start ExecStop=<%= @home %>/crx-quickstart/bin/stop # We want systemd to give aem some time to finish gracefully, but still want # it to kill aem after TimeoutStopSec if something went wrong during the @@ -19,9 +19,10 @@ ExecStop=<%= @home %>/crx-quickstart/bin/stop # ExecStop, which would kill aem. We are sending useless SIGCONT here to give # aem time to finish. -TimeoutStopSec=4min -KillSignal=SIGCONT -PrivateTmp=true +<% @service_options.each do |key, value| -%> +<%= key %>=<%= value %> +<% end -%> + [Install] WantedBy=multi-user.target