1 # @summary Manages PPA repositories using `add-apt-repository`. Not supported on Debian.
3 # @example Example declaration of an Apt PPA
4 # apt::ppa{ 'ppa:openstack-ppa/bleeding-edge': }
7 # Specifies whether the PPA should exist. Valid options: 'present' and 'absent'.
10 # Supplies options to be passed to the `add-apt-repository` command. Default: '-y'.
13 # Optional if lsb-release is installed (unless you're using a different release than indicated by lsb-release, e.g., Linux Mint).
14 # Specifies the operating system of your node. Valid options: a string containing a valid LSB distribution codename.
17 # Optional if lsb-release is installed (unless you're using a different release than indicated by lsb-release, e.g., Linux Mint).
18 # Specifies the distribution of your node. Valid options: a string containing a valid distribution codename.
21 # Names the package that provides the `apt-add-repository` command. Default: 'software-properties-common'.
23 # @param package_manage
24 # Specifies whether Puppet should manage the package that provides `apt-add-repository`.
27 String $ensure = 'present',
28 Optional[String] $options = $::apt::ppa_options,
29 Optional[String] $release = $facts['lsbdistcodename'],
30 Optional[String] $dist = $facts['lsbdistid'],
31 Optional[String] $package_name = $::apt::ppa_package,
32 Boolean $package_manage = false,
35 fail(translate('lsbdistcodename fact not available: release parameter required'))
38 if $dist == 'Debian' {
39 fail(translate('apt::ppa is not currently supported on Debian.'))
42 if versioncmp($facts['lsbdistrelease'], '14.10') >= 0 {
43 $distid = downcase($dist)
44 $dash_filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1-${distid}-\\2")
45 $underscore_filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1_${distid}_\\2")
47 $dash_filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1-\\2")
48 $underscore_filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1_\\2")
51 $dash_filename_no_slashes = regsubst($dash_filename, '/', '-', 'G')
52 $dash_filename_no_specialchars = regsubst($dash_filename_no_slashes, '[\.\+]', '_', 'G')
53 $underscore_filename_no_slashes = regsubst($underscore_filename, '/', '-', 'G')
54 $underscore_filename_no_specialchars = regsubst($underscore_filename_no_slashes, '[\.\+]', '_', 'G')
56 $sources_list_d_filename = "${dash_filename_no_specialchars}-${release}.list"
58 if versioncmp($facts['lsbdistrelease'], '15.10') >= 0 {
59 $trusted_gpg_d_filename = "${underscore_filename_no_specialchars}.gpg"
61 $trusted_gpg_d_filename = "${dash_filename_no_specialchars}.gpg"
64 if $ensure == 'present' {
66 ensure_packages($package_name)
67 $_require = [File['sources.list.d'], Package[$package_name]]
69 $_require = File['sources.list.d']
72 $_proxy = $::apt::_proxy
75 $_proxy_env = ["http_proxy=http://${$_proxy['host']}:${$_proxy['port']}", "https_proxy=https://${$_proxy['host']}:${$_proxy['port']}"]
77 $_proxy_env = ["http_proxy=http://${$_proxy['host']}:${$_proxy['port']}"]
83 exec { "add-apt-repository-${name}":
84 environment => $_proxy_env,
85 command => "/usr/bin/add-apt-repository ${options} ${name} || (rm ${::apt::sources_list_d}/${sources_list_d_filename} && false)",
86 unless => "/usr/bin/test -f ${::apt::sources_list_d}/${sources_list_d_filename} && /usr/bin/test -f ${::apt::trusted_gpg_d}/${trusted_gpg_d_filename}",
88 logoutput => 'on_failure',
89 notify => Class['apt::update'],
93 file { "${::apt::sources_list_d}/${sources_list_d_filename}":
95 require => Exec["add-apt-repository-${name}"],
99 file { "${::apt::sources_list_d}/${sources_list_d_filename}":
101 notify => Class['apt::update'],