Skip to content
Snippets Groups Projects
Select Git revision
  • 31999d1567fd04bf994ecb332391a2bc8880c249
  • master default protected
  • 9.0
  • marcus/wix3
  • 8.0
  • nt-tools
  • 7.8
  • 7.6
  • 7.4
  • 7.2
  • 7.0
  • 0.6
  • rosuav/latex-markdown-renderer
  • rxnpatch/rxnpatch
  • marcus/gobject-introspection
  • rxnpatch/8.0
  • rosuav/pre-listening-ports
  • rosuav/async-annotations
  • rosuav/pgsql-ssl
  • rxnpatch/rxnpatch-broken/2023-10-06T094250
  • grubba/fdlib
  • v8.0.2020
  • v8.0.2018
  • v8.0.2016
  • v8.0.2014
  • v8.0.2012
  • v8.0.2008
  • v8.0.2006
  • v8.0.2004
  • v8.0.2002
  • v8.0.2000
  • v8.0.1998
  • v8.0.1996
  • v8.0.1994
  • v8.0.1992
  • v8.0.1990
  • v8.0.1988
  • v8.0.1986
  • rxnpatch/clusters/8.0/2025-04-29T124414
  • rxnpatch/2025-04-29T124414
  • v8.0.1984
41 results

fdlib.h

  • tmpfiles.pp 2.90 KiB
    # Copyright © 2024        Thomas Bellman, Linköping, Sweden
    # Licensed under the GNU LGPL v3+; see the README file for more information.
    
    
    /*
     * Manage a systemd-tmpfiles(8) config file.
     *
     * You want to read the tmpfiles.d(5) manual page to understand what most
     * of the parameters actually do in the end.
     *
     * systemd-tmpfiles is automatically run as part of managing the tmpfiles.d
     * config file, so e.g. any directory the config file says should be created,
     * will be.
     *
     * Note that there is basically no verification that the parameter values
     * are syntactically correct, so it is possible to create config files
     * that are not valid.
     */
    define systemd::tmpfiles(
    	# Path(s) to manage.  Can be a single path, or a (possibly nested)
    	# list of paths.  If more than one path is given, the same type,
    	# permissions, and maxage is applied to them all.
    	#
    	# If specified, then at least $type must also be specified.
    	#
    	$paths = [],
    
    	# The entry type for the paths in $paths.  All path entries will
    	# share the same type.
    	#
    	$type = undef,
    
    	# The mode, uid, gid, age, and argument fields, respectively, of the
    	# tmpfiles.d config entries for $paths.  All entries will share the
    	# same settings.
    	#
    	$mode = undef,
    	$owner = undef,
    	$group = undef,
    	$maxage = undef,
    	$argument = undef,
    
    	# Alternative to specifying paths to manage using parameters above.
    	# One or more lines that will be written as-is to the tmpfiles.d
    	# file.
    	# While it says "lines", this can actually be any string, if you
    	# e.g. a template generating several lines as a single string.
    	#
    	$content = [],
    
    	# Comments to prepend to the generated tmpfiles.d config file.
    	#
    	$comment = [],
    
    	# One of 'present' or 'absent'.
    	#
    	$ensure = 'present',
    )
    {
        $resource_ref = "Systemd::Tmpfiles[${title}]"
    
        case $ensure
        {
    	'present': {
    	    if (($paths != []) and ((! $type) or ($type == ""))) {
    		fail("${resource_ref}: paths parameter set, but not type")
    	    }
    	    if (($type) and ($paths == [])) {
    		fail("${resource_ref}: type parameter set, but no paths")
    	    }
    	    if (($paths == []) and ($content == '' or $content == [])) {
    		fail("${resource_ref}: both paths and content are empty")
    	    }
    	    contain systemd::tmpfiles::trigger
    
    	    $cfgfile_content = template('systemd/tmpfiles.conf.erb')
    	    file {
    		"/etc/tmpfiles.d/${name}.conf":
    		    ensure => file,
    		    content => $cfgfile_content,
    		    owner => 'root', group => 'root', mode => '0644',
    		    notify => Exec['systemd::tmpfiles::trigger'];
    	    }
    	}
    
    	'absent': {
    	    file {
    		"/etc/tmpfiles.d/${name}.conf":
    		    ensure => absent;
    	    }
    	}
    
    	default: {
    	    fail("${resource_ref}: Bad ensure parameter, ${ensure}")
    	}
        }
    }
    
    
    class systemd::tmpfiles::trigger
    {
        exec {
    	'systemd::tmpfiles::trigger':
    	    command => shellquote(
    		'systemd-tmpfiles', '--create', '--remove', '--clean'),
    	    path => [ '/bin', '/usr/bin', '/sbin', '/usr/sbin', ],
    	    refreshonly => true;
        }
    }