Skip to content

Commit 5dc241e

Browse files
committed
Support multiple Environment Settings
It was previously impossible to set more than one environment variable: e.g. ```puppet systemd::manage_unit { 'test.service': unit_entry => { 'Description' => 'Bla', }, service_entry => { 'Type' => 'oneshot', 'Environment' => [ 'bla=foo', 'bar=bla', ], 'ExecStart' => '/usr/bin/true', }, enable => false, active => false, } ``` * Fixes #404
1 parent 3eccd13 commit 5dc241e

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

REFERENCE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2444,7 +2444,7 @@ Struct[{
24442444
Optional['NotifyAccess'] => Enum['none', 'default', 'main', 'exec', 'all'],
24452445
Optional['OOMPolicy'] => Enum['continue', 'stop','kill'],
24462446
Optional['OOMScoreAdjust'] => Integer[-1000,1000],
2447-
Optional['Environment'] => String,
2447+
Optional['Environment'] => Variant[String[0],Array[String[1],1]],
24482448
Optional['EnvironmentFile'] => Variant[
24492449
Stdlib::Unixpath,Pattern[/-\/.+/],
24502450
Array[Variant[Stdlib::Unixpath,Pattern[/-\/.+/]],1],

spec/defines/manage_unit_spec.rb

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
Type: 'oneshot',
2222
ExecStart: '/usr/bin/doit.sh',
2323
SyslogIdentifier: 'doit-backwards.sh',
24+
Environment: ['bla=foo', 'foo=bla']
2425
},
2526
install_entry: {
2627
WantedBy: 'multi-user.target',
@@ -36,6 +37,8 @@
3637
with_content(%r{^DefaultDependencies=true$}).
3738
with_content(%r{^\[Service\]$}).
3839
with_content(%r{^SyslogIdentifier=doit-backwards\.sh$}).
40+
with_content(%r{^Environment=bla=foo$}).
41+
with_content(%r{^Environment=foo=bla$}).
3942
with_content(%r{^\[Install\]$}).
4043
with_content(%r{^Description=My great service$}).
4144
with_content(%r{^Description=has two lines of description$}).

spec/type_aliases/systemd_unit_service_spec.rb

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
it { is_expected.to allow_value({ 'ExecStart' => 'notabsolute.sh' }) }
3535
it { is_expected.not_to allow_value({ 'ExecStart' => '*/wrongprefix.sh' }) }
3636

37+
it { is_expected.to allow_value({ 'Environment' => '' }) }
38+
it { is_expected.to allow_value({ 'Environment' => 'FOO=BAR' }) }
39+
it { is_expected.to allow_value({ 'Environment' => ['FOO=BAR', 'BAR=FOO'] }) }
3740
it { is_expected.to allow_value({ 'EnvironmentFile' => '/etc/sysconfig/foo' }) }
3841
it { is_expected.to allow_value({ 'EnvironmentFile' => '-/etc/sysconfig/foo' }) }
3942
it { is_expected.to allow_value({ 'EnvironmentFile' => ['/etc/sysconfig/foo', '-/etc/sysconfig/foo-bar'] }) }

types/unit/service.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
Optional['NotifyAccess'] => Enum['none', 'default', 'main', 'exec', 'all'],
9292
Optional['OOMPolicy'] => Enum['continue', 'stop','kill'],
9393
Optional['OOMScoreAdjust'] => Integer[-1000,1000],
94-
Optional['Environment'] => String,
94+
Optional['Environment'] => Variant[String[0],Array[String[1],1]],
9595
Optional['EnvironmentFile'] => Variant[
9696
Stdlib::Unixpath,Pattern[/-\/.+/],
9797
Array[Variant[Stdlib::Unixpath,Pattern[/-\/.+/]],1],

0 commit comments

Comments
 (0)