diff --git a/README.md b/README.md index f1a139f..a2423d6 100644 --- a/README.md +++ b/README.md @@ -1,172 +1,174 @@ # Systemd [![Puppet Forge](http://img.shields.io/puppetforge/v/camptocamp/systemd.svg)](https://forge.puppetlabs.com/camptocamp/systemd) [![Build Status](https://travis-ci.org/camptocamp/puppet-systemd.png?branch=master)](https://travis-ci.org/camptocamp/puppet-systemd) ## Overview This module declares exec resources to create global sync points for reloading systemd. +**Version 2 and newer of the module don't work with Hiera 3! You need to migrate your existing Hiera setup to Hiera 5** + ## Usage and examples There are two ways to use this module. ### unit files Let this module handle file creation and systemd reloading. ```puppet systemd::unit_file { 'foo.service': source => "puppet:///modules/${module_name}/foo.service", } ~> service {'foo': ensure => 'running', } ``` Or handle file creation yourself and trigger systemd. ```puppet include systemd::systemctl::daemon_reload file { '/usr/lib/systemd/system/foo.service': ensure => file, owner => 'root', group => 'root', mode => '0644', source => "puppet:///modules/${module_name}/foo.service", } ~> Class['systemd::systemctl::daemon_reload'] service {'foo': ensure => 'running', subscribe => File['/usr/lib/systemd/system/foo.service'], } ``` ### drop-in files Drop-in files are used to add or alter settings of a unit without modifying the unit itself. As for the unit files, the module can handle the file and directory creation and systemd reloading: ```puppet systemd::dropin_file { 'foo.conf': unit => 'foo.service', source => "puppet:///modules/${module_name}/foo.conf", } ~> service {'foo': ensure => 'running', } ``` Or handle file and directory creation yourself and trigger systemd: ```puppet include systemd::systemctl::daemon_reload file { '/etc/systemd/system/foo.service.d': ensure => directory, owner => 'root', group => 'root', } file { '/etc/systemd/system/foo.service.d/foo.conf': ensure => file, owner => 'root', group => 'root', mode => '0644', source => "puppet:///modules/${module_name}/foo.conf", } ~> Class['systemd::systemctl::daemon_reload'] service {'foo': ensure => 'running', subscribe => File['/etc/systemd/system/foo.service.d/foo.conf'], } ``` ### tmpfiles Let this module handle file creation and systemd reloading ```puppet systemd::tmpfile { 'foo.conf': source => "puppet:///modules/${module_name}/foo.conf", } ``` Or handle file creation yourself and trigger systemd. ```puppet include systemd::tmpfiles file { '/etc/tmpfiles.d/foo.conf': ensure => file, owner => 'root', group => 'root', mode => '0644', source => "puppet:///modules/${module_name}/foo.conf", } ~> Class['systemd::tmpfiles'] ``` ### service limits Manage soft and hard limits on various resources for executed processes. ```puppet systemd::service_limits { 'foo.service': limits => { 'LimitNOFILE' => 8192, 'LimitNPROC' => 16384, } } ``` Or provide the configuration file yourself. Systemd reloading and restarting of the service are handled by the module. ```puppet systemd::service_limits { 'foo.service': source => "puppet:///modules/${module_name}/foo.conf", } ``` ### network systemd-networkd is able to manage your network configuration. We provide a defined resource which can write the interface configurations. systemd-networkd needs to be restarted to apply the configs. The defined resource can do this for you: ```puppet systemd::network{'eth0.network': source => "puppet:///modules/${module_name}/eth0.network", restart_service => true, } ``` ### Services Systemd provides multiple services. Currently you can manage `systemd-resolved`, `systemd-timesyncd` and `systemd-networkd` via the main class: ```puppet class{'systemd': manage_resolved => true, manage_networkd => true, manage_timesyncd => true, } ``` $manage_networkd is required if you want to reload it for new `systemd::network` resources. Setting $manage_resolved will also manage your `/etc/resolv.conf`. It is possible to configure the default ntp servers in /etc/systemd/timesyncd.conf: ```puppet class{'systemd': manage_timesyncd => true, ntp_server => ['0.pool.ntp.org', '1.pool.ntp.org'], fallback_ntp_server => ['2.pool.ntp.org', '3.pool.ntp.org'], } ``` This requires puppetlabs-inifile, which is only a soft dependency in this module (you need to explicitly install it). Both parameters accept a string or an array. diff --git a/data/common.yaml b/data/common.yaml new file mode 100644 index 0000000..6432a91 --- /dev/null +++ b/data/common.yaml @@ -0,0 +1,10 @@ +--- +systemd::service_limits: {} +systemd::manage_resolved: false +systemd::resolved_ensure: 'running' +systemd::manage_networkd: false +systemd::networkd_ensure: 'running' +systemd::manage_timesyncd: false +systemd::timesyncd_ensure: 'running' +systemd::ntp_server: ~ +systemd::fallback_ntp_server: ~ diff --git a/hiera.yaml b/hiera.yaml new file mode 100644 index 0000000..1688d2a --- /dev/null +++ b/hiera.yaml @@ -0,0 +1,12 @@ +--- +version: 5 +defaults: + datadir: 'data' + data_hash: 'yaml_data' +hierarchy: + - name: 'Major Version' + path: '%{facts.os.name}-%{facts.os.release.major}.yaml' + - name: 'Distribution Name' + path: '%{facts.os.name}.yaml' + - name: 'common' + path: 'common.yaml' diff --git a/manifests/init.pp b/manifests/init.pp index f90e6d1..2231a1e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,62 +1,62 @@ # This module allows triggering systemd commands once for all modules # # @api public # # @param service_limits # May be passed a resource hash suitable for passing directly into the # ``create_resources()`` function as called on ``systemd::service_limits`` # # @param manage_resolved # Manage the systemd resolver # # @param resolved_ensure # The state that the ``resolved`` service should be in # # @param manage_networkd # Manage the systemd network daemon # # @param networkd_ensure # The state that the ``networkd`` service should be in # # @param manage_timesyncd # Manage the systemd tiemsyncd daemon # # @param timesyncd_ensure # The state that the ``timesyncd`` service should be in # # @param ntp_server # comma separated list of ntp servers, will be combined with interface specific # addresses from systemd-networkd. requires puppetlabs-inifile # # @param fallback_ntp_server # A space-separated list of NTP server host names or IP addresses to be used # as the fallback NTP servers. Any per-interface NTP servers obtained from # systemd-networkd take precedence over this setting. requires puppetlabs-inifile class systemd ( - Hash[String, Hash[String, Any]] $service_limits = {}, - Boolean $manage_resolved = false, - Enum['stopped','running'] $resolved_ensure = 'running', - Boolean $manage_networkd = false, - Enum['stopped','running'] $networkd_ensure = 'running', - Boolean $manage_timesyncd = false, - Enum['stopped','running'] $timesyncd_ensure = 'running', - Optional[Variant[Array,String]] $ntp_server = undef, - Optional[Variant[Array,String]] $fallback_ntp_server = undef, + Hash[String, Hash[String, Any]] $service_limits, + Boolean $manage_resolved, + Enum['stopped','running'] $resolved_ensure, + Boolean $manage_networkd, + Enum['stopped','running'] $networkd_ensure, + Boolean $manage_timesyncd, + Enum['stopped','running'] $timesyncd_ensure, + Optional[Variant[Array,String]] $ntp_server, + Optional[Variant[Array,String]] $fallback_ntp_server, ){ contain systemd::systemctl::daemon_reload create_resources('systemd::service_limits', $service_limits) if $manage_resolved and $facts['systemd_internal_services'] and $facts['systemd_internal_services']['systemd-resolved.service'] { contain systemd::resolved } if $manage_networkd and $facts['systemd_internal_services'] and $facts['systemd_internal_services']['systemd-networkd.service'] { contain systemd::networkd } if $manage_timesyncd and $facts['systemd_internal_services'] and $facts['systemd_internal_services']['systemd-timesyncd.service'] { contain systemd::timesyncd } } diff --git a/metadata.json b/metadata.json index 116ddda..50b71c9 100644 --- a/metadata.json +++ b/metadata.json @@ -1,45 +1,45 @@ { "name": "camptocamp-systemd", "version": "1.1.1", "author": "camptocamp", "summary": "Puppet Systemd module", "license": "Apache-2.0", "source": "https://github.com/camptocamp/puppet-systemd", "project_page": "https://github.com/camptocamp/puppet-systemd", "issues_url": "https://github.com/camptocamp/puppet-systemd/issues", "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": ">= 4.13.1 < 5.0.0" } ], "requirements": [ { "name": "puppet", - "version_requirement": ">= 4.7.0 < 6.0.0" + "version_requirement": ">= 4.10.10 < 6.0.0" } ], "operatingsystem_support": [ { "operatingsystem": "Debian", "operatingsystemrelease": [ "8" ] }, { "operatingsystem": "RedHat", "operatingsystemrelease": [ "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "7" ] }, { "operatingsystem": "Archlinux" } ] }