Skip to content

Commit

Permalink
Merge pull request #160 from jordiprats/master
Browse files Browse the repository at this point in the history
added support for UnsetEnvironment
  • Loading branch information
jordiprats authored Sep 13, 2019
2 parents a98cb1a + fa65702 commit a5cbdbb
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## 0.2.12

* Added flag for systemd release: **eyp_systemd_release**
* Added support for **UnsetEnvironment** to **systemd::service** and **systemd::service::dropin** - fixes [issue 152](https://github.com/NTTCom-MS/eyp-systemd/issues/152)

## 0.2.11

* Added **capability_bounding_set** to **systemd::service** and **systemd::service::dropin**
Expand Down
15 changes: 15 additions & 0 deletions lib/facter/eyp_systemd_release.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'puppet'

if File.exist?('/bin/systemctl')

systemd_release=Facter::Util::Resolution.exec('bash -c \'/bin/systemctl --version 2>/dev/null | head -n1 | awk "{ print \\$NF }" \'')

unless systemd_release.nil? or systemd_release.empty? or !/\A\d+\z/.match(systemd_release)
Facter.add('eyp_systemd_release') do
setcode do
systemd_release
end
end
end

end
15 changes: 15 additions & 0 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
$remain_after_exit = undef,
$type = undef,
$env_vars = [],
$unset_env_vars = [],
$environment_files = [],
$permissions_start_only = false,
$timeoutstartsec = undef,
Expand Down Expand Up @@ -86,6 +87,20 @@
fail('Incompatible options: There are multiple execstop values and Type is not "oneshot"')
}

# TODO: puppet4 / puppet 6 compatibility
# if(size($unset_env_vars)>0)
# {
# if(defined($::eyp_systemd_release))
# {
# $systemd_release=0+$::eyp_systemd_release
#
# if($systemd_release < 235)
# {
# fail("ERROR: UnsetEnvironment is not available for systemd < 235 - current release: ${systemd_release}")
# }
# }
# }

# if($restart!=undef)
# {
# # Takes one of no, on-success, on-failure, on-abnormal, on-watchdog, on-abort, or always.
Expand Down
15 changes: 15 additions & 0 deletions manifests/service/dropin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
$remain_after_exit = undef,
$type = undef,
$env_vars = [],
$unset_env_vars = [],
$environment_files = [],
$permissions_start_only = undef,
$timeoutstartsec = undef,
Expand Down Expand Up @@ -79,6 +80,20 @@
# validate_re($restart, [ '^no$', '^on-success$', '^on-failure$', '^on-abnormal$', '^on-watchdog$', '^on-abort$', '^always$'], "Not a supported restart type: ${restart} - Takes one of no, on-success, on-failure, on-abnormal, on-watchdog, on-abort, or always")
# }

# TODO: puppet4 / puppet 6 compatibility
# if(size($unset_env_vars)>0)
# {
# if(defined($::eyp_systemd_release))
# {
# $systemd_release=0+$::eyp_systemd_release
#
# if($systemd_release < 235)
# {
# fail("ERROR: UnsetEnvironment is not available for systemd < 235 - current release: ${systemd_release}")
# }
# }
# }

if versioncmp($::puppetversion, '4.0.0') >= 0
{
contain ::systemd
Expand Down
2 changes: 2 additions & 0 deletions manifests/tmpfile.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# TODO:
# https://manpages.debian.org/stretch/systemd/tmpfiles.d.5.en.html
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eyp-systemd",
"version": "0.2.11",
"version": "0.2.12",
"author": "eyp",
"summary": "management of systemd services, services dropins, sockets, timers, mounts, timesyncd, journald, logind and resolved",
"license": "Apache-2.0",
Expand Down
5 changes: 5 additions & 0 deletions templates/section/service.erb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ Type=<%= @type %>
Environment=<%= env %>
<%- end -%>
<% end -%>
<% if @unset_env_vars.any? -%>
<%- @unset_env_vars.each do |env| -%>
UnsetEnvironment=<%= env %>
<%- end -%>
<% end -%>
<% if @environment_files.any? -%>
<%- @environment_files.each do |env_file| -%>
EnvironmentFile=<%= env_file %>
Expand Down

0 comments on commit a5cbdbb

Please sign in to comment.