summaryrefslogtreecommitdiff
path: root/puppet/modules/systemd/spec
diff options
context:
space:
mode:
authorVarac <varac@leap.se>2017-01-18 17:40:25 +0000
committerVarac <varac@leap.se>2017-01-18 17:40:25 +0000
commit8cba23d7308af4ed018d42935adee442e2e53134 (patch)
tree96135e4aed98a2e366d5ba1c05b37e2cdeebf901 /puppet/modules/systemd/spec
parentdd189d2de941ec081261ced814a9c822e5ef02a1 (diff)
parent80e0ca380e92fe435622dbd35d1a5baedb6c3f92 (diff)
Merge branch 'apache-auto-restart' into 'master'
Add apache auto-restart extension file See merge request !66
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