forked from MiamiOH/puppet-httpproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystemd.pp
More file actions
52 lines (47 loc) · 1.41 KB
/
systemd.pp
File metadata and controls
52 lines (47 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Systemd.pp (private class)
# Manages proxies for systemd under DefaultEnvironment
class httpproxy::profiled {
$ensure = $httpproxy::systemd ? {
true => $httpproxy::ensure,
default => $httpproxy::systemd,
}
if $httpproxy::no_proxy {
$lines = [
"\"HTTP_PROXY=${httpproxy::proxy_uri}\"",
"\"HTTPS_PROXY=${httpproxy::proxy_uri}\"",
"\"NO_PROXY=${httpproxy::no_proxy}\"",
"\"http_proxy=${httpproxy::proxy_uri}\"",
"\"https_proxy=${httpproxy::proxy_uri}\"",
"\"no_proxy=${httpproxy::no_proxy}\""
]
}
else {
$lines = [
"\"HTTP_PROXY=${httpproxy::proxy_uri}\"",
"\"HTTPS_PROXY=${httpproxy::proxy_uri}\"",
"\"http_proxy=${httpproxy::proxy_uri}\"",
"\"https_proxy=${httpproxy::proxy_uri}\"",
]
}
$proxy_line = join($lines, ' ')
if $ensure {
file_line{'systemd-default-proxy':
ensure => present,
match => '^#DefaultEnvironment',
line => "DefaultEnvironment=${proxy_line}",
notify => Exec['reload-systemd-for-proxy']
}
} else {
file_line{'systemd-default-proxy':
ensure => absent,
match => 'DefaultEnvironment',
notify => Exec['reload-systemd-for-proxy']
}
}
exec{'reload-systemd-for-proxy':
command => 'systemctl daemon-reload',
path => ['/usr/local/bin', '/usr/bin', '/bin'],
subscribe => File_Line['systemd-default-proxy'],
refreshonly => true
}
}