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
8 changes: 4 additions & 4 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1028,9 +1028,9 @@ Default value: `'present'`

Data type: `Optional[Array[String[1]]]`

Supplies options to be passed to the `add-apt-repository` command.
Supplies options to be passed to the `add-apt-repository` command. Defaults to `apt::ppa_options`.

Default value: `$apt::ppa_options`
Default value: `undef`

##### <a name="-apt--ppa--release"></a>`release`

Expand All @@ -1054,9 +1054,9 @@ Default value: `$facts['os']['name']`

Data type: `Optional[String[1]]`

Names the package that provides the `apt-add-repository` command.
Names the package that provides the `apt-add-repository` command. Defaults to `apt::ppa_package`.

Default value: `$apt::ppa_package`
Default value: `undef`

##### <a name="-apt--ppa--package_manage"></a>`package_manage`

Expand Down
2 changes: 2 additions & 0 deletions manifests/auth.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
String $login = undef,
String $password = undef,
) {
include apt

$content = epp('apt/auth_conf.d.epp',
machine => $machine,
login => $login,
Expand Down
19 changes: 12 additions & 7 deletions manifests/ppa.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Specifies whether the PPA should exist.
#
# @param options
# Supplies options to be passed to the `add-apt-repository` command.
# Supplies options to be passed to the `add-apt-repository` command. Defaults to `apt::ppa_options`.
#
# @param release
# Specifies the operating system of your node. Valid options: a string containing a valid LSB distribution codename.
Expand All @@ -18,19 +18,24 @@
# Optional if `puppet facts show os.name` returns your correct distribution name.
#
# @param package_name
# Names the package that provides the `apt-add-repository` command.
# Names the package that provides the `apt-add-repository` command. Defaults to `apt::ppa_package`.
#
# @param package_manage
# Specifies whether Puppet should manage the package that provides `apt-add-repository`.
#
define apt::ppa (
Enum['present', 'absent'] $ensure = 'present',
Optional[Array[String[1]]] $options = $apt::ppa_options,
Optional[Array[String[1]]] $options = undef,
Optional[String[1]] $release = fact('os.distro.codename'),
Optional[String[1]] $dist = $facts['os']['name'],
Optional[String[1]] $package_name = $apt::ppa_package,
Optional[String[1]] $package_name = undef,
Boolean $package_manage = false,
) {
include apt

$_options = $options ? { undef => $apt::ppa_options, default => $options }
$_package_name = $package_name ? { undef => $apt::ppa_package, default => $package_name }

unless $release {
fail('os.distro.codename fact not available: release parameter required')
}
Expand Down Expand Up @@ -71,8 +76,8 @@

if $ensure == 'present' {
if $package_manage {
stdlib::ensure_packages($package_name)
$_require = [File['sources.list.d'], Package[$package_name]]
stdlib::ensure_packages($_package_name)
$_require = [File['sources.list.d'], Package[$_package_name]]
} else {
$_require = File['sources.list.d']
}
Expand All @@ -90,7 +95,7 @@

unless $sources_list_d_filename in $facts['apt_sources'] {
$script_content = epp('apt/add-apt-repository.sh.epp', {
command => ['/usr/bin/add-apt-repository', shell_join($options), $name],
command => ['/usr/bin/add-apt-repository', shell_join($_options), $name],
sources_list_d_path => $apt::sources_list_d,
sources_list_d_filename => $sources_list_d_filename,
}
Expand Down
2 changes: 2 additions & 0 deletions manifests/setting.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
Optional[String[1]] $content = undef,
Boolean $notify_update = true,
) {
include apt

if $content and $source {
fail('apt::setting cannot have both content and source')
}
Expand Down
7 changes: 7 additions & 0 deletions spec/defines/ppa_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = [])
.that_notifies('Class[Apt::Update]')
.with(*ppa_exec_params('needs', 'substitution'))
}

context 'without apt class declared' do
let(:pre_condition) { '' }

it { is_expected.to contain_class('apt') }
it { is_expected.to contain_file('add-apt-repository-script-ppa:needs/substitution').with_content(%r{add-apt-repository -y ppa:needs/substitution}) }
end
end

[
Expand Down
8 changes: 8 additions & 0 deletions spec/defines/setting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,12 @@
expect(subject).to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'absent')
}
end

describe 'without apt class declared' do
let(:pre_condition) { '' }
let(:params) { default_params }

it { is_expected.to contain_class('apt') }
it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]') }
end
end
Loading