From 040f1acf02dc379e3fe577d900b96b47a38a714a Mon Sep 17 00:00:00 2001 From: Felix Bechstein Date: Wed, 27 Jan 2016 08:18:12 +0100 Subject: Shortcut for creating unit files / tmpfiles This change allows creating unit files and reloading systemd with just a single resource. It's fully compatible with the manual behavior. --- spec/defines/tmpfile_spec.rb | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 spec/defines/tmpfile_spec.rb (limited to 'spec/defines/tmpfile_spec.rb') diff --git a/spec/defines/tmpfile_spec.rb b/spec/defines/tmpfile_spec.rb new file mode 100644 index 0000000..4eb22ac --- /dev/null +++ b/spec/defines/tmpfile_spec.rb @@ -0,0 +1,48 @@ +require 'spec_helper' + +describe 'systemd::tmpfile' do + + let(:facts) { { + :path => '/usr/bin', + } } + + context 'default params' do + + let(:title) { 'fancy.conf' } + + it 'creates the tmpfile' do + should contain_file('/etc/tmpfiles.d/fancy.conf').with({ + 'ensure' => 'file', + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0444', + }) + end + + it 'triggers systemd daemon-reload' do + should contain_class('systemd') + should contain_file('/etc/tmpfiles.d/fancy.conf').with_notify("Exec[systemd-tmpfiles-create]") + end + end + + context 'with params' do + let(:title) { 'fancy.conf' } + + let(:params) { { + :ensure => 'absent', + :path => '/etc/tmpfiles.d/foo', + :content => 'some-content', + :source => 'some-source', + } } + + it 'creates the unit file' do + should contain_file('/etc/tmpfiles.d/foo/fancy.conf').with({ + 'ensure' => 'absent', + 'content' => 'some-content', + 'source' => 'some-source', + }) + end + + end + +end -- cgit v1.2.3