Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rpm repo proxy support #808

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
40 changes: 34 additions & 6 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,26 @@
# The `undef` value also translates to `false` on RHEL/CentOS 8.1 because
# of a bug in libdnf: https://bugzilla.redhat.com/show_bug.cgi?id=1792506
# Boolean. Default: undef
# $rpm_repo_proxy_url
# Wether or not to use a proxy server for RPM repositories.
# Applies to Red Hat platforms. When set to `undef`, or `rpm_repo_proxy_port` is `undef`,
# no proxy is used to download packages from the repo.
# String. Default: undef
# $rpm_repo_proxy_port
# Which port to use with a proxy server for RPM repositories.
# Applies to Red Hat platforms. When set to `undef`, or `rpm_repo_proxy_url` is `undef`,
# no proxy is used to download packages from the repo.
# Integer. Default: undef
# $rpm_repo_proxy_password
# Whether to use a password for proxy connections for RPM repositories.
# Applies to Red Hat platforms. When set to `undef`, no password is used
# for proxy connections to download packages from the repo.
# String. Default: undef
# $rpm_repo_proxy_username
# Whether to use a username for proxy connections for RPM repositories.
# Applies to Red Hat platforms. When set to `undef`, no username is specified
# for proxy connections to download packages from the repo.
# String. Default: undef
# $apt_release
# The distribution channel to be used for the APT repo. Eg: 'stable' or 'beta'.
# String. Default: stable
Expand Down Expand Up @@ -355,6 +375,10 @@
Hash[String[1], Data] $agent_extra_options = {},
Optional[String] $agent_repo_uri = undef,
Optional[Boolean] $rpm_repo_gpgcheck = undef,
Optional[String] $rpm_repo_proxy_url = undef,
Optional[Integer] $rpm_repo_proxy_port = undef,
Optional[String] $rpm_repo_proxy_password = undef,
Optional[String] $rpm_repo_proxy_username = undef,
# TODO: $use_apt_backup_keyserver, $apt_backup_keyserver and $apt_keyserver can be
# removed in the next major version; they're kept now for backwards compatibility
Optional[Boolean] $use_apt_backup_keyserver = undef,
Expand Down Expand Up @@ -462,12 +486,16 @@
}
'RedHat','CentOS','Fedora','Amazon','Scientific','OracleLinux','AlmaLinux','Rocky' : {
class { 'datadog_agent::redhat':
agent_major_version => $_agent_major_version,
agent_flavor => $agent_flavor,
agent_repo_uri => $agent_repo_uri,
manage_repo => $manage_repo,
agent_version => $agent_full_version,
rpm_repo_gpgcheck => $rpm_repo_gpgcheck,
agent_major_version => $_agent_major_version,
agent_flavor => $agent_flavor,
agent_repo_uri => $agent_repo_uri,
manage_repo => $manage_repo,
agent_version => $agent_full_version,
rpm_repo_gpgcheck => $rpm_repo_gpgcheck,
rpm_repo_proxy_url => $rpm_repo_proxy_url,
rpm_repo_proxy_port => $rpm_repo_proxy_port,
rpm_repo_proxy_password => $rpm_repo_proxy_password,
rpm_repo_proxy_username => $rpm_repo_proxy_username,
}
}
'Windows' : {
Expand Down
37 changes: 31 additions & 6 deletions manifests/redhat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
String $agent_version = $datadog_agent::params::agent_version,
String $agent_flavor = $datadog_agent::params::package_name,
Optional[Boolean] $rpm_repo_gpgcheck = undef,
Optional[String] $rpm_repo_proxy_url = undef,
Optional[Integer] $rpm_repo_proxy_port = undef,
Optional[String] $rpm_repo_proxy_password = undef,
Optional[String] $rpm_repo_proxy_username = undef,
) inherits datadog_agent::params {

if $manage_repo {
Expand Down Expand Up @@ -51,7 +55,25 @@
} else {
$repo_gpgcheck = false
}
}

# only set any proxy variables if a proxy url and port are provided
if ($rpm_repo_proxy_url != undef) {
if ($rpm_repo_proxy_port != undef) {
$repo_proxy_url = "http://${rpm_repo_proxy_url}:${rpm_repo_proxy_port}"
if ($rpm_repo_proxy_username != undef) {
$repo_proxy_username = $rpm_repo_proxy_username
if ($rpm_repo_proxy_password != undef) {
$repo_proxy_password = $rpm_repo_proxy_password
} else {
$repo_proxy_password = absent
}
} else {
$repo_proxy_username = absent
}
} else {
$repo_proxy_url = absent
}
}

case $agent_major_version {
Expand Down Expand Up @@ -94,12 +116,15 @@
}

yumrepo {'datadog':
enabled => 1,
gpgcheck => 1,
gpgkey => join($gpgkeys, "\n "),
repo_gpgcheck => $repo_gpgcheck,
descr => 'Datadog, Inc.',
baseurl => $baseurl,
enabled => 1,
gpgcheck => 1,
gpgkey => join($gpgkeys, "\n "),
repo_gpgcheck => $repo_gpgcheck,
descr => 'Datadog, Inc.',
baseurl => $baseurl,
proxy => $repo_proxy_url,
proxy_password => $repo_proxy_password,
proxy_username => $repo_proxy_username,
}

package { $agent_flavor:
Expand Down