summaryrefslogtreecommitdiff
path: root/puppet/modules/systemd/spec
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2017-01-16 14:39:14 +0100
committervarac <varacanero@zeromail.org>2017-01-18 18:44:21 +0100
commit0117808a130c36f14f5b86879b52ed7ce2fa6d57 (patch)
treee26d0aec9b57eb3dd2b3544534e0d2c0a11cdf93 /puppet/modules/systemd/spec
parentb4df96ee1d654b4f56fe901e548e4a80207b60d9 (diff)
git subrepo clone --force https://leap.se/git/puppet_systemd puppet/modules/systemd
subrepo: subdir: "puppet/modules/systemd" merged: "f3c4059" upstream: origin: "https://leap.se/git/puppet_systemd" branch: "master" commit: "f3c4059" git-subrepo: version: "0.3.0" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "841aa43"
Diffstat (limited to 'puppet/modules/systemd/spec')
-rw-r--r--puppet/modules/systemd/spec/acceptance/nodesets/centos-5.yml16
-rw-r--r--puppet/modules/systemd/spec/acceptance/nodesets/centos-6.yml17
-rw-r--r--puppet/modules/systemd/spec/acceptance/nodesets/centos-7.yml15
-rw-r--r--puppet/modules/systemd/spec/acceptance/nodesets/debian-6.yml15
-rw-r--r--puppet/modules/systemd/spec/acceptance/nodesets/debian-7.yml15
-rw-r--r--puppet/modules/systemd/spec/acceptance/nodesets/debian-8.yml16
-rw-r--r--puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-12.04.yml16
-rw-r--r--puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-14.04.yml18
-rw-r--r--puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-14.10.yml18
-rw-r--r--puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-15.04.yml16
-rw-r--r--puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-15.10.yml16
-rw-r--r--puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-16.04.yml16
-rw-r--r--puppet/modules/systemd/spec/defines/tmpfile_spec.rb48
-rw-r--r--puppet/modules/systemd/spec/defines/unit_file_spec.rb50
-rw-r--r--puppet/modules/systemd/spec/unit/facter/systemd_spec.rb41
-rw-r--r--puppet/modules/systemd/spec/unit/facter/systemd_version_spec.rb31
16 files changed, 364 insertions, 0 deletions
diff --git a/puppet/modules/systemd/spec/acceptance/nodesets/centos-5.yml b/puppet/modules/systemd/spec/acceptance/nodesets/centos-5.yml
new file mode 100644
index 00000000..a26f27fc
--- /dev/null
+++ b/puppet/modules/systemd/spec/acceptance/nodesets/centos-5.yml
@@ -0,0 +1,16 @@
+HOSTS:
+ centos-5-x64:
+ default_apply_opts:
+ order: random
+ strict_variables:
+ platform: el-5-x86_64
+ hypervisor : docker
+ image: tianon/centos:5.10
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'yum install -y crontabs tar wget which'
+ - 'sed -i -e "/mingetty/d" /etc/inittab'
+CONFIG:
+ type: aio
+ log_level: debug
diff --git a/puppet/modules/systemd/spec/acceptance/nodesets/centos-6.yml b/puppet/modules/systemd/spec/acceptance/nodesets/centos-6.yml
new file mode 100644
index 00000000..71e23cd8
--- /dev/null
+++ b/puppet/modules/systemd/spec/acceptance/nodesets/centos-6.yml
@@ -0,0 +1,17 @@
+HOSTS:
+ centos-6-x64:
+ default_apply_opts:
+ order: random
+ strict_variables:
+ platform: el-6-x86_64
+ hypervisor : docker
+ image: centos:6
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'rm -rf /var/run/network/*'
+ - 'yum install -y crontabs tar wget'
+ - 'rm /etc/init/tty.conf'
+CONFIG:
+ type: aio
+ log_level: debug
diff --git a/puppet/modules/systemd/spec/acceptance/nodesets/centos-7.yml b/puppet/modules/systemd/spec/acceptance/nodesets/centos-7.yml
new file mode 100644
index 00000000..a8fa4686
--- /dev/null
+++ b/puppet/modules/systemd/spec/acceptance/nodesets/centos-7.yml
@@ -0,0 +1,15 @@
+HOSTS:
+ centos-7-x64:
+ default_apply_opts:
+ order: random
+ strict_variables:
+ platform: el-7-x86_64
+ hypervisor : docker
+ image: centos:7
+ docker_preserve_image: true
+ docker_cmd: '["/usr/sbin/init"]'
+ docker_image_commands:
+ - 'yum install -y crontabs tar wget iproute'
+CONFIG:
+ type: aio
+ log_level: debug
diff --git a/puppet/modules/systemd/spec/acceptance/nodesets/debian-6.yml b/puppet/modules/systemd/spec/acceptance/nodesets/debian-6.yml
new file mode 100644
index 00000000..d7b02756
--- /dev/null
+++ b/puppet/modules/systemd/spec/acceptance/nodesets/debian-6.yml
@@ -0,0 +1,15 @@
+HOSTS:
+ debian-6-x64:
+ default_apply_opts:
+ order: random
+ strict_variables:
+ platform: debian-6-amd64
+ hypervisor : docker
+ image: debian/eol:squeeze
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'apt-get install -y cron locales-all net-tools wget'
+CONFIG:
+ type: aio
+ log_level: debug
diff --git a/puppet/modules/systemd/spec/acceptance/nodesets/debian-7.yml b/puppet/modules/systemd/spec/acceptance/nodesets/debian-7.yml
new file mode 100644
index 00000000..9591ea77
--- /dev/null
+++ b/puppet/modules/systemd/spec/acceptance/nodesets/debian-7.yml
@@ -0,0 +1,15 @@
+HOSTS:
+ debian-7-x64:
+ default_apply_opts:
+ order: random
+ strict_variables:
+ platform: debian-7-amd64
+ hypervisor : docker
+ image: debian:7
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'apt-get install -y cron locales-all net-tools wget'
+CONFIG:
+ type: aio
+ log_level: debug
diff --git a/puppet/modules/systemd/spec/acceptance/nodesets/debian-8.yml b/puppet/modules/systemd/spec/acceptance/nodesets/debian-8.yml
new file mode 100644
index 00000000..5fb24c61
--- /dev/null
+++ b/puppet/modules/systemd/spec/acceptance/nodesets/debian-8.yml
@@ -0,0 +1,16 @@
+HOSTS:
+ debian-8-x64:
+ default_apply_opts:
+ order: random
+ strict_variables:
+ platform: debian-8-amd64
+ hypervisor : docker
+ image: debian:8
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'apt-get install -y cron locales-all net-tools wget'
+ - 'rm -f /usr/sbin/policy-rc.d'
+CONFIG:
+ type: aio
+ log_level: debug
diff --git a/puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-12.04.yml b/puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-12.04.yml
new file mode 100644
index 00000000..594e1771
--- /dev/null
+++ b/puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-12.04.yml
@@ -0,0 +1,16 @@
+HOSTS:
+ ubuntu-1204-x64:
+ default_apply_opts:
+ order: random
+ strict_variables:
+ platform: ubuntu-12.04-amd64
+ hypervisor : docker
+ image: ubuntu:12.04
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'apt-get install -y net-tools wget'
+ - 'locale-gen en_US.UTF-8'
+CONFIG:
+ type: aio
+ log_level: debug
diff --git a/puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-14.04.yml b/puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-14.04.yml
new file mode 100644
index 00000000..2b293c99
--- /dev/null
+++ b/puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-14.04.yml
@@ -0,0 +1,18 @@
+HOSTS:
+ ubuntu-1404-x64:
+ default_apply_opts:
+ order: random
+ strict_variables:
+ platform: ubuntu-14.04-amd64
+ hypervisor : docker
+ image: ubuntu:14.04
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'rm /usr/sbin/policy-rc.d'
+ - 'rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl'
+ - 'apt-get install -y net-tools wget'
+ - 'locale-gen en_US.UTF-8'
+CONFIG:
+ type: aio
+ log_level: debug
diff --git a/puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-14.10.yml b/puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-14.10.yml
new file mode 100644
index 00000000..7ce09b2a
--- /dev/null
+++ b/puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-14.10.yml
@@ -0,0 +1,18 @@
+HOSTS:
+ ubuntu-1410-x64:
+ default_apply_opts:
+ order: random
+ strict_variables:
+ platform: ubuntu-14.10-amd64
+ hypervisor : docker
+ image: ubuntu:14.10
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'rm /usr/sbin/policy-rc.d'
+ - 'rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl'
+ - 'apt-get install -y net-tools wget'
+ - 'locale-gen en_US.UTF-8'
+CONFIG:
+ type: aio
+ log_level: debug
diff --git a/puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-15.04.yml b/puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-15.04.yml
new file mode 100644
index 00000000..329f3319
--- /dev/null
+++ b/puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-15.04.yml
@@ -0,0 +1,16 @@
+HOSTS:
+ ubuntu-1504-x64:
+ default_apply_opts:
+ order: random
+ strict_variables:
+ platform: ubuntu-15.04-amd64
+ hypervisor : docker
+ image: ubuntu:15.04
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'apt-get install -y net-tools wget'
+ - 'locale-gen en_US.UTF-8'
+CONFIG:
+ type: aio
+ log_level: debug
diff --git a/puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-15.10.yml b/puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-15.10.yml
new file mode 100644
index 00000000..487795a3
--- /dev/null
+++ b/puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-15.10.yml
@@ -0,0 +1,16 @@
+HOSTS:
+ ubuntu-1510-x64:
+ default_apply_opts:
+ order: random
+ strict_variables:
+ platform: ubuntu-15.10-amd64
+ hypervisor : docker
+ image: ubuntu:15.10
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'apt-get install -y net-tools wget'
+ - 'locale-gen en_US.UTF-8'
+CONFIG:
+ type: aio
+ log_level: debug
diff --git a/puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-16.04.yml b/puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-16.04.yml
new file mode 100644
index 00000000..6c32b96d
--- /dev/null
+++ b/puppet/modules/systemd/spec/acceptance/nodesets/ubuntu-16.04.yml
@@ -0,0 +1,16 @@
+HOSTS:
+ ubuntu-1604-x64:
+ default_apply_opts:
+ order: random
+ strict_variables:
+ platform: ubuntu-16.04-amd64
+ hypervisor : docker
+ image: ubuntu:16.04
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'apt-get install -y net-tools wget'
+ - 'locale-gen en_US.UTF-8'
+CONFIG:
+ type: aio
+ log_level: debug
diff --git a/puppet/modules/systemd/spec/defines/tmpfile_spec.rb b/puppet/modules/systemd/spec/defines/tmpfile_spec.rb
new file mode 100644
index 00000000..4eb22acd
--- /dev/null
+++ b/puppet/modules/systemd/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
diff --git a/puppet/modules/systemd/spec/defines/unit_file_spec.rb b/puppet/modules/systemd/spec/defines/unit_file_spec.rb
new file mode 100644
index 00000000..88a0122c
--- /dev/null
+++ b/puppet/modules/systemd/spec/defines/unit_file_spec.rb
@@ -0,0 +1,50 @@
+require 'spec_helper'
+
+describe 'systemd::unit_file' do
+
+ let(:facts) { {
+ :path => '/usr/bin',
+ } }
+
+ context 'default params' do
+
+ let(:title) { 'fancy.service' }
+
+ it 'creates the unit file' do
+ should contain_file('/etc/systemd/system/fancy.service').with({
+ 'ensure' => 'file',
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => '0444',
+ })
+ end
+
+ it 'triggers systemd daemon-reload' do
+ should contain_class('systemd')
+ should contain_file('/etc/systemd/system/fancy.service').with_notify("Exec[systemctl-daemon-reload]")
+ end
+ end
+
+ context 'with params' do
+ let(:title) { 'fancy.service' }
+
+ let(:params) { {
+ :ensure => 'absent',
+ :path => '/usr/lib/systemd/system',
+ :content => 'some-content',
+ :source => 'some-source',
+ :target => 'some-target',
+ } }
+
+ it 'creates the unit file' do
+ should contain_file('/usr/lib/systemd/system/fancy.service').with({
+ 'ensure' => 'absent',
+ 'content' => 'some-content',
+ 'source' => 'some-source',
+ 'target' => 'some-target',
+ })
+ end
+
+ end
+
+end
diff --git a/puppet/modules/systemd/spec/unit/facter/systemd_spec.rb b/puppet/modules/systemd/spec/unit/facter/systemd_spec.rb
new file mode 100644
index 00000000..a7b62410
--- /dev/null
+++ b/puppet/modules/systemd/spec/unit/facter/systemd_spec.rb
@@ -0,0 +1,41 @@
+require "spec_helper"
+
+describe Facter::Util::Fact do
+ before {
+ Facter.clear
+ }
+
+ describe "systemd" do
+ context 'returns true when systemd present' do
+ before do
+ Facter.fact(:kernel).stubs(:value).returns(:linux)
+ end
+ let(:facts) { {:kernel => :linux} }
+ it do
+ Facter::Util::Resolution.expects(:exec).with('ps -p 1 -o comm=').returns('systemd')
+ expect(Facter.value(:systemd)).to eq(true)
+ end
+ end
+ context 'returns false when systemd not present' do
+ before do
+ Facter.fact(:kernel).stubs(:value).returns(:linux)
+ end
+ let(:facts) { {:kernel => :linux} }
+ it do
+ Facter::Util::Resolution.expects(:exec).with('ps -p 1 -o comm=').returns('init')
+ expect(Facter.value(:systemd)).to eq(false)
+ end
+ end
+
+ context 'returns nil when kernel is not linux' do
+ before do
+ Facter.fact(:kernel).stubs(:value).returns(:windows)
+ end
+ let(:facts) { {:kernel => :windows} }
+ it do
+ Facter::Util::Resolution.expects(:exec).with('ps -p 1 -o comm=').never
+ expect(Facter.value(:systemd)).to be_nil
+ end
+ end
+ end
+end
diff --git a/puppet/modules/systemd/spec/unit/facter/systemd_version_spec.rb b/puppet/modules/systemd/spec/unit/facter/systemd_version_spec.rb
new file mode 100644
index 00000000..5007dc69
--- /dev/null
+++ b/puppet/modules/systemd/spec/unit/facter/systemd_version_spec.rb
@@ -0,0 +1,31 @@
+require "spec_helper"
+
+describe Facter::Util::Fact do
+ before {
+ Facter.clear
+ }
+
+ describe "systemd_version" do
+ context 'returns version when systemd fact present' do
+ before do
+ Facter.fact(:systemd).stubs(:value).returns(true)
+ end
+ let(:facts) { {:systemd => true} }
+ it do
+ Facter::Util::Resolution.expects(:exec).with("systemctl --version | awk '/systemd/{ print $2 }'").returns('229')
+ expect(Facter.value(:systemd_version)).to eq('229')
+ end
+ end
+ context 'returns nil when systemd fact not present' do
+ before do
+ Facter.fact(:systemd).stubs(:value).returns(false)
+ end
+ let(:facts) { {:systemd => false } }
+ it do
+ Facter::Util::Resolution.stubs(:exec)
+ Facter::Util::Resolution.expects(:exec).with("systemctl --version | awk '/systemd/{ print $2 }'").never
+ expect(Facter.value(:systemd_version)).to eq(nil)
+ end
+ end
+ end
+end