File tree Expand file tree Collapse file tree 6 files changed +166
-4
lines changed
Expand file tree Collapse file tree 6 files changed +166
-4
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ fixtures :
3+ symlinks :
4+ systemd : " #{source_dir}"
Original file line number Diff line number Diff line change 55
66## Overview
77
8- This module declares exec resources that you can use when you change systemd units or configuration files .
8+ This module declares exec resources to create global sync points for reloading systemd.
99
10- ## Examples
10+ ## Usage and examples
1111
12- ### systemctl --daemon-reload
12+ There are two ways to use this module.
13+
14+ ### unit files
15+
16+ Let this module handle file creation and systemd reloading.
17+
18+ ``` puppet
19+ ::systemd::unit_file { 'foo.service':
20+ source => "puppet:///modules/${module_name}/foo.service",
21+ }
22+ ```
23+
24+ Or handle file creation yourself and trigger systemd.
1325
1426``` puppet
1527include ::systemd
@@ -23,7 +35,17 @@ file { '/usr/lib/systemd/system/foo.service':
2335Exec['systemctl-daemon-reload']
2436```
2537
26- ### systemd-tmpfiles --create
38+ ### tmpfiles
39+
40+ Let this module handle file creation and systemd reloading
41+
42+ ``` puppet
43+ ::systemd::tmpfile { 'foo.conf':
44+ source => "puppet:///modules/${module_name}/foo.conf",
45+ }
46+ ```
47+
48+ Or handle file creation yourself and trigger systemd.
2749
2850``` puppet
2951include ::systemd
Original file line number Diff line number Diff line change 1+ # -- Define: systemd::tmpfile
2+ # Creates a tmpfile and reloads systemd
3+ define systemd::tmpfile (
4+ $ensure = file ,
5+ $path = ' /etc/tmpfiles.d' ,
6+ $content = undef ,
7+ $source = undef ,
8+ ) {
9+ include ::systemd
10+
11+ file { "${path}/${title}" :
12+ ensure => $ensure ,
13+ content => $content ,
14+ source => $source ,
15+ owner => ' root' ,
16+ group => ' root' ,
17+ mode => ' 0444' ,
18+ notify => Exec[' systemd-tmpfiles-create' ],
19+ }
20+ }
Original file line number Diff line number Diff line change 1+ # -- Define: systemd::unit_file
2+ # Creates a unit file and reloads systemd
3+ define systemd::unit_file (
4+ $ensure = file ,
5+ $path = ' /etc/systemd/system' ,
6+ $content = undef ,
7+ $source = undef ,
8+ ) {
9+ include ::systemd
10+
11+ file { "${path}/${title}" :
12+ ensure => $ensure ,
13+ content => $content ,
14+ source => $source ,
15+ owner => ' root' ,
16+ group => ' root' ,
17+ mode => ' 0444' ,
18+ notify => Exec[' systemctl-daemon-reload' ],
19+ }
20+ }
Original file line number Diff line number Diff line change 1+ require 'spec_helper'
2+
3+ describe 'systemd::tmpfile' do
4+
5+ let ( :facts ) { {
6+ :path => '/usr/bin' ,
7+ } }
8+
9+ context 'default params' do
10+
11+ let ( :title ) { 'fancy.conf' }
12+
13+ it 'creates the tmpfile' do
14+ should contain_file ( '/etc/tmpfiles.d/fancy.conf' ) . with ( {
15+ 'ensure' => 'file' ,
16+ 'owner' => 'root' ,
17+ 'group' => 'root' ,
18+ 'mode' => '0444' ,
19+ } )
20+ end
21+
22+ it 'triggers systemd daemon-reload' do
23+ should contain_class ( 'systemd' )
24+ should contain_file ( '/etc/tmpfiles.d/fancy.conf' ) . with_notify ( "Exec[systemd-tmpfiles-create]" )
25+ end
26+ end
27+
28+ context 'with params' do
29+ let ( :title ) { 'fancy.conf' }
30+
31+ let ( :params ) { {
32+ :ensure => 'absent' ,
33+ :path => '/etc/tmpfiles.d/foo' ,
34+ :content => 'some-content' ,
35+ :source => 'some-source' ,
36+ } }
37+
38+ it 'creates the unit file' do
39+ should contain_file ( '/etc/tmpfiles.d/foo/fancy.conf' ) . with ( {
40+ 'ensure' => 'absent' ,
41+ 'content' => 'some-content' ,
42+ 'source' => 'some-source' ,
43+ } )
44+ end
45+
46+ end
47+
48+ end
Original file line number Diff line number Diff line change 1+ require 'spec_helper'
2+
3+ describe 'systemd::unit_file' do
4+
5+ let ( :facts ) { {
6+ :path => '/usr/bin' ,
7+ } }
8+
9+ context 'default params' do
10+
11+ let ( :title ) { 'fancy.service' }
12+
13+ it 'creates the unit file' do
14+ should contain_file ( '/etc/systemd/system/fancy.service' ) . with ( {
15+ 'ensure' => 'file' ,
16+ 'owner' => 'root' ,
17+ 'group' => 'root' ,
18+ 'mode' => '0444' ,
19+ } )
20+ end
21+
22+ it 'triggers systemd daemon-reload' do
23+ should contain_class ( 'systemd' )
24+ should contain_file ( '/etc/systemd/system/fancy.service' ) . with_notify ( "Exec[systemctl-daemon-reload]" )
25+ end
26+ end
27+
28+ context 'with params' do
29+ let ( :title ) { 'fancy.service' }
30+
31+ let ( :params ) { {
32+ :ensure => 'absent' ,
33+ :path => '/usr/lib/systemd/system' ,
34+ :content => 'some-content' ,
35+ :source => 'some-source' ,
36+ } }
37+
38+ it 'creates the unit file' do
39+ should contain_file ( '/usr/lib/systemd/system/fancy.service' ) . with ( {
40+ 'ensure' => 'absent' ,
41+ 'content' => 'some-content' ,
42+ 'source' => 'some-source' ,
43+ } )
44+ end
45+
46+ end
47+
48+ end
You can’t perform that action at this time.
0 commit comments