Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ httpproxy
5. [Contributors](#contributors)

## Overview
WARNING: This module will default to wiping any proxies in profile.d, apt conf.d, and yum.conf. Pass false to disable
WARNING: This module will default to wiping any proxies in profile.d, apt conf.d, yum.conf and systemd. Pass false to disable
the module from handling those software packages.

This module was created to streamline proxy management of popular software. It can place and remove
Expand All @@ -27,6 +27,7 @@ proxies in profile.d, apt, yum, and wget. Currently only http (no https) proxies
wget => true,
profiled => true,
packagemanager => true,
systemd => true,
http_proxy => 'my.proxy.com',
http_proxy_port => '80'
}
Expand All @@ -35,19 +36,23 @@ Puppet will manage the proxy for the desired software when its boolean is set to
puppet will ensure that the proxy is present. If a proxy is left undefined, puppet will remove whatever proxy it
placed (ensure absent). If the boolean is set to false, nothing will be removed or placed.

The no_proxy parameter takes a comma separated string of addresses to be ignored by the profile.d proxy.
The no_proxy parameter takes a comma separated string of addresses to be ignored by the profile.d and systemd proxy.

## Reference

httpproxy uses the Unibets profile.d management module to manage proxies in profile.d. The puppetlabs/inifile
resource is used to manage the yum and wget proxies. The apt proxy is managed via the puppetlabs/apt module.

systemd proxy is managed with file_line. Note the systemd proxy will override any DefaultEnvironment you currently have set in systemd.

Please contribute, pull requests are welcome. The more proxies that can be managed the better.

## Limitations

This module has been tested against Puppet 4, CentOS 5,6,7, and Ubuntu 14.04.
This module has been tested against Puppet 4, CentOS 5,6,7, Oracle Linux 9, and Ubuntu 14.04.

## Contributors

Chris Edester and Michael Callahan
Chris Edester
Michael Callahan
Michael Baker (@elmobp)
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
$no_proxy = undef,
$profiled = true,
$packagemanager = true,
$systemd = true,
$wget = false,
Boolean $purge_apt_conf = false,
){
Expand Down Expand Up @@ -36,5 +37,6 @@
# Boolean parameter for class selection
if $profiled { contain 'httpproxy::profiled' }
if $packagemanager { contain 'httpproxy::packagemanager' }
if $systemd { contain 'httpproxy::systemd' }
if $wget { contain 'httpproxy::wget' }
}
52 changes: 52 additions & 0 deletions manifests/systemd.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
}
}