From cfd1f9ee35f7b80b17c460b77709d3d5dc880638 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Mon, 16 Jan 2017 15:15:41 -0200 Subject: Add apache auto-restart extension file --- puppet/modules/site_apache/files/auto_restart.conf | 2 ++ puppet/modules/site_apache/manifests/common.pp | 1 + puppet/modules/site_apache/manifests/common/extensions.pp | 14 ++++++++++++++ puppet/modules/site_apache/spec/classes/extensions.rb | 7 +++++++ puppet/modules/site_apache/spec/spec_helper.rb | 6 ++++++ 5 files changed, 30 insertions(+) create mode 100644 puppet/modules/site_apache/files/auto_restart.conf create mode 100644 puppet/modules/site_apache/manifests/common/extensions.pp create mode 100644 puppet/modules/site_apache/spec/classes/extensions.rb create mode 100644 puppet/modules/site_apache/spec/spec_helper.rb (limited to 'puppet/modules/site_apache') diff --git a/puppet/modules/site_apache/files/auto_restart.conf b/puppet/modules/site_apache/files/auto_restart.conf new file mode 100644 index 00000000..8a764e34 --- /dev/null +++ b/puppet/modules/site_apache/files/auto_restart.conf @@ -0,0 +1,2 @@ +[Service] +Restart=always diff --git a/puppet/modules/site_apache/manifests/common.pp b/puppet/modules/site_apache/manifests/common.pp index 208c15d5..c96932dd 100644 --- a/puppet/modules/site_apache/manifests/common.pp +++ b/puppet/modules/site_apache/manifests/common.pp @@ -28,5 +28,6 @@ class site_apache::common { include site_apache::common::tls include site_apache::common::acme + include site_apache::common::extensions } diff --git a/puppet/modules/site_apache/manifests/common/extensions.pp b/puppet/modules/site_apache/manifests/common/extensions.pp new file mode 100644 index 00000000..ddeafae0 --- /dev/null +++ b/puppet/modules/site_apache/manifests/common/extensions.pp @@ -0,0 +1,14 @@ +class site_apache::common::extensions { + + include ::systemd + file { '/etc/systemd/system/apache2.service.d/auto_restart.conf': + source => 'puppet:///modules/site_apache/auto_restart.conf', + owner => 'root', + group => 'root', + mode => '0644', + require => [ + Service['apache'] + ] + }~> + Exec['systemctl-daemon-reload'] +} diff --git a/puppet/modules/site_apache/spec/classes/extensions.rb b/puppet/modules/site_apache/spec/classes/extensions.rb new file mode 100644 index 00000000..164034c2 --- /dev/null +++ b/puppet/modules/site_apache/spec/classes/extensions.rb @@ -0,0 +1,7 @@ +require File.expand_path(File.join(File.dirname(__FILE__),'../spec_helper')) + +describe 'site_apache::common::extensions' do + it "should include apache autostart" do + should contain_file('/etc/systemd/system/apache2.service.d/auto_restart.conf').with_source('puppet:///modules/site_apache/apache_auto_restart.conf') + end +end diff --git a/puppet/modules/site_apache/spec/spec_helper.rb b/puppet/modules/site_apache/spec/spec_helper.rb new file mode 100644 index 00000000..dea9e892 --- /dev/null +++ b/puppet/modules/site_apache/spec/spec_helper.rb @@ -0,0 +1,6 @@ +require 'rspec-puppet' + +RSpec.configure do |c| + c.module_path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')) + c.color = true +end -- cgit v1.2.3 From 6748ba91d4d5fb77bb9034f8fc39e6735e2ef375 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Mon, 16 Jan 2017 17:24:50 -0200 Subject: Update how exec is run --- puppet/modules/site_apache/manifests/common/extensions.pp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'puppet/modules/site_apache') diff --git a/puppet/modules/site_apache/manifests/common/extensions.pp b/puppet/modules/site_apache/manifests/common/extensions.pp index ddeafae0..6e489ce8 100644 --- a/puppet/modules/site_apache/manifests/common/extensions.pp +++ b/puppet/modules/site_apache/manifests/common/extensions.pp @@ -6,9 +6,7 @@ class site_apache::common::extensions { owner => 'root', group => 'root', mode => '0644', - require => [ - Service['apache'] - ] - }~> - Exec['systemctl-daemon-reload'] + require => Service['apache'], + notify => Exec['systemctl-daemon-reload'] + } } -- cgit v1.2.3 From 65604b35e96c4ca6e83c2d90b1c512dfa7ff31e7 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Mon, 16 Jan 2017 17:25:15 -0200 Subject: Remove spec_helper --- puppet/modules/site_apache/spec/classes/extensions.rb | 2 +- puppet/modules/site_apache/spec/spec_helper.rb | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 puppet/modules/site_apache/spec/spec_helper.rb (limited to 'puppet/modules/site_apache') diff --git a/puppet/modules/site_apache/spec/classes/extensions.rb b/puppet/modules/site_apache/spec/classes/extensions.rb index 164034c2..632b2d72 100644 --- a/puppet/modules/site_apache/spec/classes/extensions.rb +++ b/puppet/modules/site_apache/spec/classes/extensions.rb @@ -1,4 +1,4 @@ -require File.expand_path(File.join(File.dirname(__FILE__),'../spec_helper')) +require 'spec_helper' describe 'site_apache::common::extensions' do it "should include apache autostart" do diff --git a/puppet/modules/site_apache/spec/spec_helper.rb b/puppet/modules/site_apache/spec/spec_helper.rb deleted file mode 100644 index dea9e892..00000000 --- a/puppet/modules/site_apache/spec/spec_helper.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'rspec-puppet' - -RSpec.configure do |c| - c.module_path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')) - c.color = true -end -- cgit v1.2.3 From 810df8983e3ada8ad4b0ebbc7e0e3cf01219e33c Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Tue, 17 Jan 2017 11:03:14 -0200 Subject: Rename extensions module to autorestart --- puppet/modules/site_apache/files/auto_restart.conf | 2 -- puppet/modules/site_apache/files/autorestart.conf | 2 ++ puppet/modules/site_apache/manifests/common.pp | 2 +- .../modules/site_apache/manifests/common/autorestart.pp | 15 +++++++++++++++ puppet/modules/site_apache/manifests/common/extensions.pp | 12 ------------ puppet/modules/site_apache/spec/classes/autorestart.rb | 7 +++++++ puppet/modules/site_apache/spec/classes/extensions.rb | 7 ------- 7 files changed, 25 insertions(+), 22 deletions(-) delete mode 100644 puppet/modules/site_apache/files/auto_restart.conf create mode 100644 puppet/modules/site_apache/files/autorestart.conf create mode 100644 puppet/modules/site_apache/manifests/common/autorestart.pp delete mode 100644 puppet/modules/site_apache/manifests/common/extensions.pp create mode 100644 puppet/modules/site_apache/spec/classes/autorestart.rb delete mode 100644 puppet/modules/site_apache/spec/classes/extensions.rb (limited to 'puppet/modules/site_apache') diff --git a/puppet/modules/site_apache/files/auto_restart.conf b/puppet/modules/site_apache/files/auto_restart.conf deleted file mode 100644 index 8a764e34..00000000 --- a/puppet/modules/site_apache/files/auto_restart.conf +++ /dev/null @@ -1,2 +0,0 @@ -[Service] -Restart=always diff --git a/puppet/modules/site_apache/files/autorestart.conf b/puppet/modules/site_apache/files/autorestart.conf new file mode 100644 index 00000000..8a764e34 --- /dev/null +++ b/puppet/modules/site_apache/files/autorestart.conf @@ -0,0 +1,2 @@ +[Service] +Restart=always diff --git a/puppet/modules/site_apache/manifests/common.pp b/puppet/modules/site_apache/manifests/common.pp index c96932dd..4847cbe3 100644 --- a/puppet/modules/site_apache/manifests/common.pp +++ b/puppet/modules/site_apache/manifests/common.pp @@ -28,6 +28,6 @@ class site_apache::common { include site_apache::common::tls include site_apache::common::acme - include site_apache::common::extensions + include site_apache::common::autorestart } diff --git a/puppet/modules/site_apache/manifests/common/autorestart.pp b/puppet/modules/site_apache/manifests/common/autorestart.pp new file mode 100644 index 00000000..aa13d4ef --- /dev/null +++ b/puppet/modules/site_apache/manifests/common/autorestart.pp @@ -0,0 +1,15 @@ +# +# Adds autorestart extension to apache on crash +# +class site_apache::common::autorestart { + + include ::systemd + file { '/etc/systemd/system/apache2.service.d/autorestart.conf': + source => 'puppet:///modules/site_apache/autorestart.conf', + owner => 'root', + group => 'root', + mode => '0644', + require => Service['apache'], + notify => Exec['systemctl-daemon-reload'] + } +} diff --git a/puppet/modules/site_apache/manifests/common/extensions.pp b/puppet/modules/site_apache/manifests/common/extensions.pp deleted file mode 100644 index 6e489ce8..00000000 --- a/puppet/modules/site_apache/manifests/common/extensions.pp +++ /dev/null @@ -1,12 +0,0 @@ -class site_apache::common::extensions { - - include ::systemd - file { '/etc/systemd/system/apache2.service.d/auto_restart.conf': - source => 'puppet:///modules/site_apache/auto_restart.conf', - owner => 'root', - group => 'root', - mode => '0644', - require => Service['apache'], - notify => Exec['systemctl-daemon-reload'] - } -} diff --git a/puppet/modules/site_apache/spec/classes/autorestart.rb b/puppet/modules/site_apache/spec/classes/autorestart.rb new file mode 100644 index 00000000..afa02ec9 --- /dev/null +++ b/puppet/modules/site_apache/spec/classes/autorestart.rb @@ -0,0 +1,7 @@ +require 'spec_helper' + +describe 'site_apache::common::autorestart' do + it "should include apache autorestart" do + should contain_file('/etc/systemd/system/apache2.service.d/autorestart.conf').with_source('puppet:///modules/site_apache/autorestart.conf') + end +end diff --git a/puppet/modules/site_apache/spec/classes/extensions.rb b/puppet/modules/site_apache/spec/classes/extensions.rb deleted file mode 100644 index 632b2d72..00000000 --- a/puppet/modules/site_apache/spec/classes/extensions.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'spec_helper' - -describe 'site_apache::common::extensions' do - it "should include apache autostart" do - should contain_file('/etc/systemd/system/apache2.service.d/auto_restart.conf').with_source('puppet:///modules/site_apache/apache_auto_restart.conf') - end -end -- cgit v1.2.3 From b6e19e290eb6395ce0a12bf2307282b00e7456ea Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Tue, 17 Jan 2017 14:26:27 -0200 Subject: Change autorestart to use systemd::unit_file --- puppet/modules/site_apache/manifests/common/autorestart.pp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'puppet/modules/site_apache') diff --git a/puppet/modules/site_apache/manifests/common/autorestart.pp b/puppet/modules/site_apache/manifests/common/autorestart.pp index aa13d4ef..f8213439 100644 --- a/puppet/modules/site_apache/manifests/common/autorestart.pp +++ b/puppet/modules/site_apache/manifests/common/autorestart.pp @@ -3,13 +3,8 @@ # class site_apache::common::autorestart { - include ::systemd - file { '/etc/systemd/system/apache2.service.d/autorestart.conf': + ::systemd::unit_file { '/etc/systemd/system/apache2.service.d/autorestart.conf': source => 'puppet:///modules/site_apache/autorestart.conf', - owner => 'root', - group => 'root', - mode => '0644', require => Service['apache'], - notify => Exec['systemctl-daemon-reload'] } } -- cgit v1.2.3 From 80e0ca380e92fe435622dbd35d1a5baedb6c3f92 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Tue, 17 Jan 2017 15:18:30 -0200 Subject: Ensure the directory exists before creating the file with @aarni --- puppet/modules/site_apache/manifests/common/autorestart.pp | 12 ++++++++++-- puppet/modules/site_apache/spec/classes/autorestart.rb | 7 ------- puppet/modules/site_apache/spec/classes/autorestart_spec.rb | 7 +++++++ 3 files changed, 17 insertions(+), 9 deletions(-) delete mode 100644 puppet/modules/site_apache/spec/classes/autorestart.rb create mode 100644 puppet/modules/site_apache/spec/classes/autorestart_spec.rb (limited to 'puppet/modules/site_apache') diff --git a/puppet/modules/site_apache/manifests/common/autorestart.pp b/puppet/modules/site_apache/manifests/common/autorestart.pp index f8213439..0273f272 100644 --- a/puppet/modules/site_apache/manifests/common/autorestart.pp +++ b/puppet/modules/site_apache/manifests/common/autorestart.pp @@ -3,8 +3,16 @@ # class site_apache::common::autorestart { - ::systemd::unit_file { '/etc/systemd/system/apache2.service.d/autorestart.conf': + file { '/etc/systemd/system/apache2.service.d': + ensure => directory, + mode => '0755', + } + + ::systemd::unit_file { 'apache2.service.d/autorestart.conf': source => 'puppet:///modules/site_apache/autorestart.conf', - require => Service['apache'], + require => [ + File['/etc/systemd/system/apache2.service.d'], + Service['apache'], + ] } } diff --git a/puppet/modules/site_apache/spec/classes/autorestart.rb b/puppet/modules/site_apache/spec/classes/autorestart.rb deleted file mode 100644 index afa02ec9..00000000 --- a/puppet/modules/site_apache/spec/classes/autorestart.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'spec_helper' - -describe 'site_apache::common::autorestart' do - it "should include apache autorestart" do - should contain_file('/etc/systemd/system/apache2.service.d/autorestart.conf').with_source('puppet:///modules/site_apache/autorestart.conf') - end -end diff --git a/puppet/modules/site_apache/spec/classes/autorestart_spec.rb b/puppet/modules/site_apache/spec/classes/autorestart_spec.rb new file mode 100644 index 00000000..ad9c9f2e --- /dev/null +++ b/puppet/modules/site_apache/spec/classes/autorestart_spec.rb @@ -0,0 +1,7 @@ +require 'spec_helper' + +describe 'site_apache::common::autorestart' do + it "should include apache autorestart" do + should contain_file('apache2.service.d/autorestart.conf').with_source('puppet:///modules/site_apache/autorestart.conf') + end +end -- cgit v1.2.3