Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ verifier:
name: inspec

platforms:
- name: centos-7.4
- name: fedora-27
- name: centos-7
- name: centos-8
- name: fedora-35
run_list:
- recipe[yum::dnf_yum_compat]
- name: debian-9.3
- name: debian-11.1
run_list:
- recipe[debian::backports]
- recipe[apt]
- name: ubuntu-16.04
- name: ubuntu-20.04
run_list:
- recipe[apt]

Expand Down
4 changes: 2 additions & 2 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: systemd
# Cookbook:: systemd
# Attributes:: default
#
# Copyright 2015 - 2016, The Authors
# Copyright:: 2015 - 2016, The Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions libraries/data.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: systemd
# Cookbook:: systemd
# Library:: SystemdCookbook
#
# Copyright 2016 The Authors
# Copyright:: 2016 The Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
9 changes: 4 additions & 5 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: systemd
# Cookbook:: systemd
# Library:: SystemdCookbook::Helpers
#
# Copyright 2016 The Authors
# Copyright:: 2016 The Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -25,8 +25,7 @@ def module_loaded?(mod)
end

def systemd_is_pid_1?
File.exist?('/proc/1/comm') &&
File.read('/proc/1/comm').chomp == 'systemd'
systemd?
end

module_function :module_loaded?, :systemd_is_pid_1?
Expand Down Expand Up @@ -72,7 +71,7 @@ def camelcase

class Hash
def to_kv_pairs
reject { |_, v| v.nil? }
compact
.map { |k, v| "#{k}=#{v}" }
end
end
103 changes: 2 additions & 101 deletions libraries/matchers.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: systemd
# Cookbook:: systemd
# Library:: SystemdCookbook::Matchers
#
# Copyright 2016 The Authors
# Copyright:: 2016 The Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,102 +18,3 @@
#

require_relative 'data'

if defined?(ChefSpec)
SystemdCookbook::UNITS.each do |type|
# Define unit matchers
ChefSpec.define_matcher("systemd_#{type}".to_sym)
Chef::Resource::SystemdUnit.allowed_actions.each do |actn|
define_method("#{actn}_systemd_#{type}".to_sym) do |resource_name|
ChefSpec::Matchers::ResourceMatcher.new(
"systemd_#{type}".to_sym, actn.to_sym, resource_name
)
end
end

ChefSpec.define_matcher("systemd_#{type}_drop_in".to_sym)
%w(create delete).each do |actn|
define_method("#{actn}_systemd_#{type}_drop_in".to_sym) do |resource_name|
ChefSpec::Matchers::ResourceMatcher.new(
"systemd_#{type}_drop_in".to_sym, actn.to_sym, resource_name
)
end
end
end

SystemdCookbook::DAEMONS.each do |daemon|
ChefSpec.define_matcher("systemd_#{daemon}".to_sym)
%w(create delete).each do |actn|
define_method("#{actn}_systemd_#{daemon}".to_sym) do |resource_name|
ChefSpec::Matchers::ResourceMatcher.new(
"systemd_#{daemon}".to_sym, actn.to_sym, resource_name
)
end
end
end

SystemdCookbook::UTILS.each do |util|
ChefSpec.define_matcher("systemd_#{util}".to_sym)
%w(create delete).each do |actn|
define_method("#{actn}_systemd_#{util}".to_sym) do |resource_name|
ChefSpec::Matchers::ResourceMatcher.new(
"systemd_#{util}".to_sym, actn.to_sym, resource_name
)
end
end
end

%w(load unload).each do |actn|
define_method("#{actn}_systemd_modules".to_sym) do |resource_name|
ChefSpec::Matchers::ResourceMatcher.new(
:systemd_modules, actn.to_sym, resource_name
)
end
end

define_method(:apply_systemd_sysctl) do |resource_name|
ChefSpec::Matchers::ResourceMatcher.new(
:systemd_sysctl, :apply, resource_name
)
end

SystemdCookbook::NETS.each do |net|
ChefSpec.define_matcher("systemd_#{net}".to_sym)
%w(create delete).each do |actn|
define_method("#{actn}_systemd_#{net}".to_sym) do |resource_name|
ChefSpec::Matchers::ResourceMatcher.new(
"systemd_#{net}".to_sym, actn.to_sym, resource_name
)
end
end
end

%w(journal_remote journal_upload nspawn).each do |misc|
ChefSpec.define_matcher("systemd_#{misc}".to_sym)
%w(create delete).each do |actn|
define_method("#{actn}_systemd_#{misc}".to_sym) do |resource_name|
ChefSpec::Matchers::ResourceMatcher.new(
"systemd_#{misc}".to_sym, actn.to_sym, resource_name
)
end
end
end

ChefSpec.define_matcher(:systemd_machine)
%w(start poweroff reboot enable disable terminate kill copy_to copy_from).each do |actn|
define_method("#{actn}_systemd_machine".to_sym) do |resource_name|
ChefSpec::Matchers::ResourceMatcher.new(
:systemd_machine, actn.to_sym, resource_name
)
end
end

ChefSpec.define_matcher(:systemd_machine_image)
%w(pull set_properties clone rename remove import export).each do |actn|
define_method("#{actn}_systemd_machine_image".to_sym) do |resource_name|
ChefSpec::Matchers::ResourceMatcher.new(
:systemd_machine_image, actn.to_sym, resource_name
)
end
end
end
6 changes: 3 additions & 3 deletions libraries/mixin.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: systemd
# Cookbook:: systemd
# Library:: SystemdCookbook::Mixin
#
# Copyright 2016 The Authors
# Copyright:: 2016 The Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,7 +31,7 @@ module ClassMethods
def build_dsl
data_class = resource_type.to_s.tr('-', '_').camelcase.to_sym

SystemdCookbook.const_get(data_class)::OPTIONS.keys.each do |sect|
SystemdCookbook.const_get(data_class)::OPTIONS.each_key do |sect|
define_method(sect.underscore.to_sym) do |&block|
ctx = SystemdCookbook::OptionEvalContext.new(self, sect.underscore.to_sym)
ctx.instance_exec(&block)
Expand Down
10 changes: 5 additions & 5 deletions libraries/resource_factory.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: systemd
# Cookbook:: systemd
# Library:: SystemdCookbook::ResourceFactory
#
# Copyright 2016 The Authors
# Copyright:: 2016 The Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,7 +40,7 @@ def build_resource
include SystemdCookbook::Mixin::DSL

property :user, String, desired_state: false
property :verify, [TrueClass, FalseClass],
property :verify, [true, false],
default: true,
desired_state: false

Expand Down Expand Up @@ -96,8 +96,8 @@ def build_resource
}
property :precursor, Hash, default: {}
property :user, String, desired_state: false
property :drop_in_name, identity: true, desired_state: false,
default: lazy { "#{override}-#{name}" }
property :drop_in_name, String, identity: true, desired_state: false,
default: lazy { "#{override}-#{name}" }

%w(create delete).map(&:to_sym).each do |actn|
action actn do
Expand Down
4 changes: 2 additions & 2 deletions recipes/hostname.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: systemd
# Cookbook:: systemd
# Recipe:: hostname
#
# Copyright 2015 - 2016, The Authors
# Copyright:: 2015 - 2016, The Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions recipes/journal_extra.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: systemd
# Cookbook:: systemd
# Recipe:: journal_extra
#
# Copyright 2016, The Authors
# Copyright:: 2016, The Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions recipes/journal_gateway.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: systemd
# Cookbook:: systemd
# Recipe:: journal_gatewayd
#
# Copyright 2015 - 2016, The Authors
# Copyright:: 2015 - 2016, The Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions recipes/journal_remote.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: systemd
# Cookbook:: systemd
# Recipe:: journal_remote
#
# Copyright 2015 - 2016, The Authors
# Copyright:: 2015 - 2016, The Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions recipes/journal_upload.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: systemd
# Cookbook:: systemd
# Recipe:: journal_upload
#
# Copyright 2015 - 2016, The Authors
# Copyright:: 2015 - 2016, The Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions recipes/journald.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: systemd
# Cookbook:: systemd
# Recipe:: journald
#
# Copyright 2015 - 2016, The Authors
# Copyright:: 2015 - 2016, The Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions recipes/locale.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: systemd
# Cookbook:: systemd
# Recipe:: locale
#
# Copyright 2015 - 2016, The Authors
# Copyright:: 2015 - 2016, The Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions recipes/logind.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: systemd
# Cookbook:: systemd
# Recipe:: logind
#
# Copyright 2015 - 2016, The Authors
# Copyright:: 2015 - 2016, The Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
12 changes: 2 additions & 10 deletions recipes/machine.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: systemd
# Cookbook:: systemd
# Recipe:: machine
#
# Copyright 2015 - 2016, The Authors
# Copyright:: 2015 - 2016, The Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -19,14 +19,6 @@
# https://www.freedesktop.org/software/systemd/man/systemd-networkd.service.html
#

package 'btrfs-tools' do
only_if { platform_family?('debian') }
end

package 'btrfs-progs' do
not_if { platform_family?('debian') }
end

package 'systemd-container' do
not_if { platform_family?('rhel') || platform?('debian') }
end
Expand Down
4 changes: 2 additions & 2 deletions recipes/networkd.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: systemd
# Cookbook:: systemd
# Recipe:: networkd
#
# Copyright 2015 - 2016, The Authors
# Copyright:: 2015 - 2016, The Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions recipes/reload.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: systemd
# Cookbook:: systemd
# Recipe:: reload
#
# Copyright 2015 - 2016, The Authors
# Copyright:: 2015 - 2016, The Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
8 changes: 2 additions & 6 deletions recipes/resolved.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: systemd
# Cookbook:: systemd
# Recipe:: resolved
#
# Copyright 2015 - 2016, The Authors
# Copyright:: 2015 - 2016, The Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -19,10 +19,6 @@
# https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html
#

package 'systemd-resolved' do
only_if { platform_family?('rhel') }
end

service 'systemd-resolved' do
action [:enable, :start]
end
Loading