/Gemfile.lock
/junit/
/log/
-/log/
/pkg/
/spec/fixtures/manifests/
/spec/fixtures/modules/
/tmp/
/vendor/
/convert_report.txt
-
+/update_report.txt
+.DS_Store
--- /dev/null
+.*.sw[op]
+.metadata
+.yardoc
+.yardwarns
+*.iml
+/.bundle/
+/.idea/
+/.vagrant/
+/coverage/
+/bin/
+/doc/
+/Gemfile.local
+/Gemfile.lock
+/junit/
+/log/
+/pkg/
+/spec/fixtures/manifests/
+/spec/fixtures/modules/
+/tmp/
+/vendor/
+/convert_report.txt
+/update_report.txt
+.DS_Store
Exclude:
- bin/*
- ".vendor/**/*"
- - Gemfile
- - Rakefile
+ - "**/Gemfile"
+ - "**/Rakefile"
- pkg/**/*
- spec/fixtures/**/*
- vendor/**/*
+ - "**/Puppetfile"
+ - "**/Vagrantfile"
+ - "**/Guardfile"
Metrics/LineLength:
Description: People have wide screens, use them.
Max: 200
Style/SymbolArray:
Description: Using percent style obscures symbolic intent of array's contents.
EnforcedStyle: brackets
+RSpec/MessageSpies:
+ EnforcedStyle: receive
+Style/Documentation:
+ Exclude:
+ - lib/puppet/parser/functions/**/*
+Style/WordArray:
+ EnforcedStyle: brackets
Style/CollectionMethods:
Enabled: true
Style/MethodCalledOnDoEndBlock:
appveyor.yml:
delete: true
+
+.gitlab-ci.yml:
+ unmanaged: true
- bundle -v
- rm -f Gemfile.lock
- gem update --system
- - gem update bundler
- gem --version
- bundle -v
script:
rvm:
- 2.4.1
env:
- - PUPPET_GEM_VERSION="~> 5.0" CHECK=spec
+ global:
+ - BEAKER_PUPPET_COLLECTION=puppet5 PUPPET_GEM_VERSION="~> 5.0"
matrix:
fast_finish: true
include:
-
bundler_args:
dist: trusty
- env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/debian-8
+ env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/debian-8
rvm: 2.4.1
script: bundle exec rake beaker
services: docker
-
bundler_args:
dist: trusty
- env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-14.04
+ env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/ubuntu-14.04
rvm: 2.4.1
script: bundle exec rake beaker
services: docker
sudo: required
-
- env: CHECK=rubocop
+ env: CHECK="syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop"
-
- env: CHECK="syntax lint"
+ env: CHECK=parallel_spec
-
- env: CHECK=metadata_lint
- -
- env: CHECK=release_checks
- -
- env: CHECK=spec
- -
- env: PUPPET_GEM_VERSION="~> 4.0" CHECK=spec
+ env: PUPPET_GEM_VERSION="~> 4.0" CHECK=parallel_spec
rvm: 2.1.9
branches:
only:
--- /dev/null
+--markup markdown
gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
+ gem "json", '<= 2.0.4', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.4.4')
gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby]
gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby]
gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
- gem "puppet-blacksmith", '~> 3.4', require: false
+ gem "puppet-blacksmith", '~> 3.4', require: false, platforms: [:ruby]
end
group :system_tests do
gem "puppet-module-posix-system-r#{minor_version}", require: false, platforms: [:ruby]
facter_version = ENV['FACTER_GEM_VERSION']
hiera_version = ENV['HIERA_GEM_VERSION']
-def puppet_older_than?(version)
- puppet_version = ENV['PUPPET_GEM_VERSION']
- !puppet_version.nil? &&
- Gem::Version.correct?(puppet_version) &&
- Gem::Requirement.new("< #{version}").satisfied_by?(Gem::Version.new(puppet_version.dup))
-end
-
gems = {}
gems['puppet'] = location_for(puppet_version)
# If facter or hiera versions have been specified via the environment
-# variables, use those versions. If not, and if the puppet version is < 3.5.0,
-# use known good versions of both for puppet < 3.5.0.
-if facter_version
- gems['facter'] = location_for(facter_version)
-elsif puppet_type == :gem && puppet_older_than?('3.5.0')
- gems['facter'] = ['>= 1.6.11', '<= 1.7.5', require: false]
-end
-
-if hiera_version
- gems['hiera'] = location_for(ENV['HIERA_GEM_VERSION'])
-elsif puppet_type == :gem && puppet_older_than?('3.5.0')
- gems['hiera'] = ['>= 1.0.0', '<= 1.3.0', require: false]
-end
+# variables
-if Gem.win_platform? && (puppet_type != :gem || puppet_older_than?('3.5.0'))
- # For Puppet gems < 3.5.0 (tested as far back as 3.0.0) on Windows
- if puppet_type == :gem
- gems['ffi'] = ['1.9.0', require: false]
- gems['minitar'] = ['0.5.4', require: false]
- gems['win32-eventlog'] = ['0.5.3', '<= 0.6.5', require: false]
- gems['win32-process'] = ['0.6.5', '<= 0.7.5', require: false]
- gems['win32-security'] = ['~> 0.1.2', '<= 0.2.5', require: false]
- gems['win32-service'] = ['0.7.2', '<= 0.8.8', require: false]
- else
- gems['ffi'] = ['~> 1.9.0', require: false]
- gems['minitar'] = ['~> 0.5.4', require: false]
- gems['win32-eventlog'] = ['~> 0.5', '<= 0.6.5', require: false]
- gems['win32-process'] = ['~> 0.6', '<= 0.7.5', require: false]
- gems['win32-security'] = ['~> 0.1', '<= 0.2.5', require: false]
- gems['win32-service'] = ['~> 0.7', '<= 0.8.8', require: false]
- end
-
- gems['win32-dir'] = ['~> 0.3', '<= 0.4.9', require: false]
-
- if RUBY_VERSION.start_with?('1.')
- gems['win32console'] = ['1.3.2', require: false]
- # sys-admin was removed in Puppet 3.7.0 and doesn't compile under Ruby 2.x
- gems['sys-admin'] = ['1.5.6', require: false]
- end
+gems['facter'] = location_for(facter_version) if facter_version
+gems['hiera'] = location_for(hiera_version) if hiera_version
- # Puppet < 3.7.0 requires these.
- # Puppet >= 3.5.0 gem includes these as requirements.
- # The following versions are tested to work with 3.0.0 <= puppet < 3.7.0.
- gems['win32-api'] = ['1.4.8', require: false]
- gems['win32-taskscheduler'] = ['0.2.2', require: false]
- gems['windows-api'] = ['0.4.3', require: false]
- gems['windows-pr'] = ['1.2.3', require: false]
-elsif Gem.win_platform?
+if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)}
# If we're using a Puppet gem on Windows which handles its own win32-xxx gem
# dependencies (>= 3.5.0), set the maximum versions (see PUP-6445).
gems['win32-dir'] = ['<= 0.4.9', require: false]
gems['win32-eventlog'] = ['<= 0.6.5', require: false]
gems['win32-process'] = ['<= 0.7.5', require: false]
gems['win32-security'] = ['<= 0.2.5', require: false]
- gems['win32-service'] = ['<= 0.8.8', require: false]
+ gems['win32-service'] = ['0.8.8', require: false]
end
gems.each do |gem_name, gem_params|
}
```
+### Manage login configuration settings for an APT source or proxy in `/etc/apt/auth.conf`
+
+Starting with APT version 1.5 you can define login configuration settings (like
+username and password) for APT sources or proxies that require authentication
+in the file `/etc/apt/auth.conf`. This is preferable to embedding login
+information directly in `source.list` entries which are usually world-readable.
+
+The file `/etc/apt/auth.conf` follows the format of netrc (as used by ftp or
+curl) and has restrictive file permissions. See
+https://manpages.debian.org/testing/apt/apt_auth.conf.5.en.html for details.
+
+Use the optional `apt::auth_conf_entries` parameter to specify an array of
+hashes containing login configuration settings. These hashes may only contain
+the keys `machine`, `login` and `password`.
+
+```puppet
+class { 'apt':
+ auth_conf_entries => [
+ {
+ 'machine' => 'apt-proxy.example.net',
+ 'login' => 'proxylogin',
+ 'password' => 'proxypassword',
+ },
+ {
+ 'machine' => 'apt.example.com/ubuntu',
+ 'login' => 'reader',
+ 'password' => 'supersecret',
+ },
+ ],
+}
+```
+
## Reference
### Classes
* `settings`: Creates new `apt::setting` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}.
+* `auth_conf_entries`: An optional array of login configuration settings (hashes) that will be recorded in the file `/etc/apt/auth.conf`. This file has a netrc-like format (similar to what curl uses) and contains the login configuration for APT sources and proxies that require authentication. See https://manpages.debian.org/testing/apt/apt_auth.conf.5.en.html for details. If specified each hash must contain the keys `machine`, `login` and `password` and no others. Default: [].
+
* `sources`: Creates new `apt::source` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}.
* `pins`: Creates new `apt::pin` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}.
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-syntax/tasks/puppet-syntax'
-require 'puppet_blacksmith/rake_tasks'
+require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
+
+PuppetLint.configuration.send('disable_relative')
+
Hash $ppas = $apt::params::ppas,
Hash $pins = $apt::params::pins,
Hash $settings = $apt::params::settings,
+ Array[Apt::Auth_conf_entry]
+ $auth_conf_entries = $apt::params::auth_conf_entries,
String $root = $apt::params::root,
String $sources_list = $apt::params::sources_list,
String $sources_list_d = $apt::params::sources_list_d,
create_resources('apt::setting', $settings)
}
+ $auth_conf_ensure = $auth_conf_entries ? {
+ [] => 'absent',
+ default => 'present',
+ }
+
+ $auth_conf_tmp = epp('apt/auth_conf.epp')
+
+ file { '/etc/apt/auth.conf':
+ ensure => $auth_conf_ensure,
+ owner => 'root',
+ group => 'root',
+ mode => '0600',
+ content => "${confheadertmp}${auth_conf_tmp}",
+ notify => Class['apt::update'],
+ }
+
# manage pins if present
if $pins {
create_resources('apt::pin', $pins)
}
# required for adding GPG keys on Debian 9 (and derivatives)
- case $facts['os']['name'] {
- 'Debian': {
- if versioncmp($facts['os']['release']['major'], '9') >= 0 {
- ensure_packages(['dirmngr'])
- }
- }
- 'Ubuntu': {
- if versioncmp($facts['os']['release']['full'], '17.04') >= 0 {
- ensure_packages(['dirmngr'])
- }
- }
- default: { }
- }
+ ensure_packages(['dirmngr'])
}
$ppas = {}
$pins = {}
$settings = {}
+ $auth_conf_entries = []
$config_files = {
'conf' => {
case $facts['os']['name']{
'Debian': {
- case $facts['os']['release']['full'] {
- default: {
$backports = {
'location' => 'http://deb.debian.org/debian',
'key' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
'repos' => 'main contrib non-free',
}
- }
- }
-
$ppa_options = undef
$ppa_package = undef
-
}
'Ubuntu': {
$backports = {
'key' => '630239CC130E1A7FD81A27B140976EAF437D05B5',
'repos' => 'main universe multiverse restricted',
}
-
- case $facts['os']['release']['full'] {
- '10.04': {
- $ppa_options = undef
- $ppa_package = 'python-software-properties'
- }
- '12.04': {
- $ppa_options = '-y'
- $ppa_package = 'python-software-properties'
- }
- '14.04', '14.10', '15.04', '15.10', '16.04': {
- $ppa_options = '-y'
- $ppa_package = 'software-properties-common'
- }
- default: {
- $ppa_options = '-y'
- $ppa_package = 'python-software-properties'
- }
- }
+ $ppa_options = '-y'
+ $ppa_package = 'software-properties-common'
}
undef: {
fail('Unable to determine value for fact os["name"]')
Boolean $notify_update = true,
) {
- # This is needed for compat with 1.8.x
include ::apt
$_before = Apt::Setting["list-${title}"]
$_release = $release
}
- # Some releases do not support https transport with default installation
- $_transport_https_releases = [ 'wheezy', 'jessie', 'stretch', 'trusty', 'xenial' ]
-
if $ensure == 'present' {
if ! $location {
fail('cannot create a source entry without specifying a location')
- } elsif $_release in $_transport_https_releases {
- $method = split($location, '[:\/]+')[0]
- if $method == 'https' {
- ensure_packages('apt-transport-https')
- }
}
}
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
- "7",
- "8"
+ "8",
+ "9"
]
},
{
"version_requirement": ">= 4.7.0 < 6.0.0"
}
],
- "template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git",
- "template-ref": "1.3.2-0-g07678c8"
+ "template-url": "https://github.com/puppetlabs/pdk-templates",
+ "template-ref": "heads/master-0-g34e3266",
+ "pdk-version": "1.5.0"
}
CENTOS_GPG_KEY_FINGERPRINT = 'C1DAC52D1664E8A4386DBA430946FCA2C105B9DE'.freeze
CENTOS_REPO_URL = 'ftp.cvut.cz/centos'.freeze
CENTOS_GPG_KEY_FILE = 'RPM-GPG-KEY-CentOS-6'.freeze
-
SHOULD_NEVER_EXIST_ID = 'EF8D349F'.freeze
-
KEY_CHECK_COMMAND = 'apt-key adv --list-keys --with-colons --fingerprint | grep '.freeze
PUPPETLABS_KEY_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} #{PUPPETLABS_GPG_KEY_FINGERPRINT}".freeze
CENTOS_KEY_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} #{CENTOS_GPG_KEY_FINGERPRINT}".freeze
-MAX_TIMEOUT_RETRY = 3
-TIMEOUT_RETRY_WAIT = 5
-TIMEOUT_ERROR_MATCHER = %r{no valid OpenPGP data found}
-
def populate_default_options_pp(value)
default_options_pp = <<-MANIFEST
apt_key { 'puppetlabs':
end
def install_key(key)
- retry_on_error_matching(MAX_TIMEOUT_RETRY, TIMEOUT_RETRY_WAIT, TIMEOUT_ERROR_MATCHER) do
- shell("apt-key adv --keyserver hkps.pool.sks-keyservers.net \
- --recv-keys #{key}")
+ retry_on_error_matching do
+ shell("apt-key adv --keyserver hkps.pool.sks-keyservers.net --recv-keys #{key}")
end
end
def apply_manifest_twice(manifest_pp)
- apply_manifest(manifest_pp, catch_failures: true)
- apply_manifest(manifest_pp, catch_changes: true)
+ retry_on_error_matching do
+ apply_manifest(manifest_pp, catch_failures: true)
+ end
+ retry_on_error_matching do
+ apply_manifest(manifest_pp, catch_changes: true)
+ end
end
invalid_key_length_pp = <<-MANIFEST
end
end
- context 'when absent, added with long key', unless: (fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '6') do
+ context 'when absent, added with long key' do
it 'is removed' do
# Install the key first (retry because key pool may timeout)
install_key(PUPPETLABS_GPG_KEY_LONG_ID)
context 'with puppetlabs gpg key' do
it 'works' do
# Apply the manifest (Retry if timeout error is received from key pool)
- retry_on_error_matching(MAX_TIMEOUT_RETRY, TIMEOUT_RETRY_WAIT, TIMEOUT_ERROR_MATCHER) do
+ retry_on_error_matching do
apply_manifest(gpg_key_pp, catch_failures: true)
end
context 'with hkps.pool.sks-keyservers.net' do
it 'works' do
# Apply the manifest (Retry if timeout error is received from key pool)
- retry_on_error_matching(MAX_TIMEOUT_RETRY, TIMEOUT_RETRY_WAIT, TIMEOUT_ERROR_MATCHER) do
+ retry_on_error_matching do
apply_manifest(hkps_pool_pp, catch_failures: true)
end
context 'with hkp://hkps.pool.sks-keyservers.net:80' do
it 'works' do
- retry_on_error_matching(MAX_TIMEOUT_RETRY, TIMEOUT_RETRY_WAIT, TIMEOUT_ERROR_MATCHER) do
+ retry_on_error_matching do
apply_manifest(hkp_pool_pp, catch_failures: true)
end
context 'with nonexistant.key.server' do
it 'fails' do
apply_manifest(nonexistant_key_server_pp, expect_failures: true) do |r|
- expect(r.stderr).to match(%r{(Host not found|Couldn't resolve host)})
+ expect(r.stderr).to match(%r{(Host not found|Couldn't resolve host|No name)})
end
end
end
end
end
- context 'with ftp://' do
+ # disabled when running in travis, security issues prevent FTP
+ context 'with ftp://', unless: (ENV['TRAVIS'] == 'true') do
before(:each) do
shell("apt-key del #{CENTOS_GPG_KEY_LONG_ID}",
acceptable_exit_codes: [0, 1, 2])
require 'spec_helper_acceptance'
-MAX_TIMEOUT_RETRY = 3
-TIMEOUT_RETRY_WAIT = 5
-TIMEOUT_ERROR_MATCHER = %r{no valid OpenPGP data found}
-
everything_everything_pp = <<-MANIFEST
- if $::lsbdistcodename == 'lucid' {
- $sources = undef
- } else {
- $sources = {
- 'puppetlabs' => {
- 'ensure' => present,
- 'location' => 'http://apt.puppetlabs.com',
- 'repos' => 'main',
- 'key' => {
- 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
- 'server' => 'hkps.pool.sks-keyservers.net',
- },
+ $sources = {
+ 'puppetlabs' => {
+ 'ensure' => present,
+ 'location' => 'http://apt.puppetlabs.com',
+ 'repos' => 'main',
+ 'key' => {
+ 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
+ 'server' => 'pool.sks-keyservers.net',
},
- }
+ },
}
class { 'apt':
update => {
context 'with all the things' do
it 'works with no errors' do
# Apply the manifest (Retry if timeout error is received from key pool)
- retry_on_error_matching(MAX_TIMEOUT_RETRY, TIMEOUT_RETRY_WAIT, TIMEOUT_ERROR_MATCHER) do
+ retry_on_error_matching do
apply_manifest(everything_everything_pp, catch_failures: true)
end
-
- apply_manifest(everything_everything_pp, catch_failures: true)
end
it 'stills work' do
shell('apt-get update')
context 'with defaults on deb' do
let(:facts) do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
osfamily: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
puppetversion: Puppet.version,
}
end
is_expected.to contain_apt__source('backports').with(location: 'http://deb.debian.org/debian',
key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
repos: 'main contrib non-free',
- release: 'wheezy-backports',
- pin: { 'priority' => 200, 'release' => 'wheezy-backports' })
+ release: 'jessie-backports',
+ pin: { 'priority' => 200, 'release' => 'jessie-backports' })
}
end
context 'with defaults on ubuntu' do
let(:facts) do
{
- os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } },
+ os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } },
lsbdistid: 'Ubuntu',
osfamily: 'Debian',
- lsbdistcodename: 'trusty',
- lsbdistrelease: '14.04',
+ lsbdistcodename: 'xenial',
+ lsbdistrelease: '16.04',
puppetversion: Puppet.version,
}
end
is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu',
key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
repos: 'main universe multiverse restricted',
- release: 'trusty-backports',
- pin: { 'priority' => 200, 'release' => 'trusty-backports' })
+ release: 'xenial-backports',
+ pin: { 'priority' => 200, 'release' => 'xenial-backports' })
}
end
context 'with everything set' do
let(:facts) do
{
- os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } },
+ os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } },
lsbdistid: 'Ubuntu',
osfamily: 'Debian',
- lsbdistcodename: 'trusty',
- lsbdistrelease: '14.04',
+ lsbdistcodename: 'xenial',
+ lsbdistrelease: '16.04',
puppetversion: Puppet.version,
}
end
context 'when set things with hashes' do
let(:facts) do
{
- os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } },
+ os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } },
lsbdistid: 'Ubuntu',
osfamily: 'Debian',
- lsbdistcodename: 'trusty',
- lsbdistrelease: '14.04',
+ lsbdistcodename: 'xenial',
+ lsbdistrelease: '16.04',
puppetversion: Puppet.version,
}
end
describe 'validation' do
let(:facts) do
{
- os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } },
+ os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } },
lsbdistid: 'Ubuntu',
osfamily: 'Debian',
- lsbdistcodename: 'trusty',
- lsbdistrelease: '14.04',
+ lsbdistcodename: 'xenial',
+ lsbdistrelease: '16.04',
puppetversion: Puppet.version,
}
end
is_expected.to contain_file('preferences.d').that_notifies('Class[Apt::Update]').only_with(preferences_d)
}
+ it { is_expected.to contain_file('/etc/apt/auth.conf').with_ensure('absent') }
+
it 'lays down /etc/apt/apt.conf.d/15update-stamp' do
is_expected.to contain_file('/etc/apt/apt.conf.d/15update-stamp').with(group: 'root',
mode: '0644',
}
end
+ context 'with entries for /etc/apt/auth.conf' do
+ let(:params) do
+ {
+ auth_conf_entries: [
+ { machine: 'deb.example.net',
+ login: 'foologin',
+ password: 'secret' },
+ { machine: 'apt.example.com',
+ login: 'aptlogin',
+ password: 'supersecret' },
+ ],
+ }
+ end
+
+ auth_conf_content = "// This file is managed by Puppet. DO NOT EDIT.
+machine deb.example.net login foologin password secret
+machine apt.example.com login aptlogin password supersecret
+"
+
+ it {
+ is_expected.to contain_file('/etc/apt/auth.conf').with(ensure: 'present',
+ owner: 'root',
+ group: 'root',
+ mode: '0600',
+ notify: 'Class[Apt::Update]',
+ content: auth_conf_content)
+ }
+ end
+
+ context 'with improperly specified entries for /etc/apt/auth.conf' do
+ let(:params) do
+ {
+ auth_conf_entries: [
+ { machinn: 'deb.example.net',
+ username: 'foologin',
+ password: 'secret' },
+ { machine: 'apt.example.com',
+ login: 'aptlogin',
+ password: 'supersecret' },
+ ],
+ }
+ end
+
+ it { is_expected.to raise_error(Puppet::Error) }
+ end
+
context 'with sources defined on valid osfamily' do
let :facts do
- { os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04' } },
+ { os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } },
osfamily: 'Debian',
- lsbdistcodename: 'precise',
+ lsbdistcodename: 'xenial',
lsbdistid: 'Ubuntu',
- lsbdistrelease: '12.04',
+ lsbdistrelease: '16.04',
puppetversion: Puppet.version }
end
let(:params) do
is_expected.to contain_apt__setting('list-puppetlabs').with(ensure: 'present')
}
- it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(%r{^deb http://apt.puppetlabs.com precise main$}) }
+ it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(%r{^deb http://apt.puppetlabs.com xenial main$}) }
end
context 'with confs defined on valid osfamily' do
let :facts do
{
- os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } },
+ os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } },
osfamily: 'Debian',
- lsbdistcodename: 'precise',
+ lsbdistcodename: 'xenial',
lsbdistid: 'Debian',
puppetversion: Puppet.version,
}
context 'with keys defined on valid osfamily' do
let :facts do
{
- os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } },
+ os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } },
osfamily: 'Debian',
- lsbdistcodename: 'precise',
+ lsbdistcodename: 'xenial',
lsbdistid: 'Debian',
puppetversion: Puppet.version,
}
context 'with ppas defined on valid osfamily' do
let :facts do
{
- os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } },
+ os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } },
osfamily: 'Debian',
- lsbdistcodename: 'precise',
+ lsbdistcodename: 'xenial',
lsbdistid: 'ubuntu',
- lsbdistrelease: '12.04',
+ lsbdistrelease: '16.04',
puppetversion: Puppet.version,
}
end
context 'with settings defined on valid osfamily' do
let :facts do
{
- os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } },
+ os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } },
osfamily: 'Debian',
- lsbdistcodename: 'precise',
+ lsbdistcodename: 'xenial',
lsbdistid: 'Debian',
puppetversion: Puppet.version,
}
context 'with pins defined on valid osfamily' do
let :facts do
{
- os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } },
+ os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } },
osfamily: 'Debian',
- lsbdistcodename: 'precise',
+ lsbdistcodename: 'xenial',
lsbdistid: 'Debian',
puppetversion: Puppet.version,
}
context "when $::apt_update_last_success indicates #{desc}" do
let(:facts) do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
osfamily: 'Debian',
apt_update_last_success: factval,
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
puppetversion: Puppet.version,
}
end
context 'when $::apt_update_last_success is nil' do
let(:facts) do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
osfamily: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
puppetversion: Puppet.version,
}
end
context "when $::apt_update_last_success indicates #{desc}" do
let(:facts) do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
osfamily: 'Debian',
apt_update_last_success: factval,
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
puppetversion: Puppet.version,
}
end
context 'when $::apt_update_last_success is nil' do
let(:facts) do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
osfamily: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
puppetversion: Puppet.version,
}
end
end
end
end
- %w[daily weekly].each do |update_frequency|
+ ['daily', 'weekly'].each do |update_frequency|
context "when apt::update['frequency'] has the value of #{update_frequency}" do
{ 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
context "when $::apt_update_last_success indicates #{desc}" do
let(:facts) do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
osfamily: 'Debian',
apt_update_last_success: factval,
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
puppetversion: Puppet.version,
}
end
context 'when the $::apt_update_last_success fact has a recent value' do
let(:facts) do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
osfamily: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
apt_update_last_success: Time.now.to_i,
puppetversion: Puppet.version,
}
context 'when $::apt_update_last_success is nil' do
let(:facts) do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
osfamily: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
apt_update_last_success: nil,
puppetversion: Puppet.version,
}
--- /dev/null
+# Use default_module_facts.yml for module specific facts.
+#
+# Facts specified here will override the values provided by rspec-puppet-facts.
+---
+concat_basedir: "/tmp"
+ipaddress: "172.16.254.254"
+is_pe: false
+macaddress: "AA:AA:AA:AA:AA:AA"
end
let(:facts) do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
osfamily: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
puppetversion: Puppet.version,
}
end
let(:facts) do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
osfamily: 'Debian',
puppetversion: Puppet.version,
let(:facts) do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
osfamily: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
puppetversion: Puppet.version,
}
end
end
context 'with invalid ensure' do
- %w[foo aabsent absenta apresent presenta].each do |param|
+ ['foo', 'aabsent', 'absenta', 'apresent', 'presenta'].each do |param|
let :params do
{
ensure: param,
end
let(:facts) do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
osfamily: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
puppetversion: Puppet.version,
}
end
describe 'defaults' do
let :facts do
{
- os: { family: 'Debian', name: 'Ubuntu', release: { major: '11', full: '11.04' } },
- lsbdistrelease: '11.04',
- lsbdistcodename: 'natty',
+ os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '41.04' } },
+ lsbdistrelease: '14.04',
+ lsbdistcodename: 'trusty',
operatingsystem: 'Ubuntu',
osfamily: 'Debian',
lsbdistid: 'Ubuntu',
it {
is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow+type').that_notifies('Class[Apt::Update]').with(environment: [],
command: '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow+type', # rubocop:disable Metrics/LineLength
- unless: '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow_type-natty.list', # rubocop:disable Metrics/LineLength
+ unless: '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow_type-trusty.list', # rubocop:disable Metrics/LineLength
user: 'root',
logoutput: 'on_failure')
}
end
let :facts do
{
- os: { family: 'Debian', name: 'Ubuntu', release: { major: '11', full: '11.04' } },
- lsbdistrelease: '11.04',
- lsbdistcodename: 'natty',
+ os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } },
+ lsbdistrelease: '14.04',
+ lsbdistcodename: 'trusty',
operatingsystem: 'Ubuntu',
osfamily: 'Debian',
lsbdistid: 'Ubuntu',
it {
is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with('environment' => [],
'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', # rubocop:disable Metrics/LineLength
- 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', # rubocop:disable Metrics/LineLength
+ 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list', # rubocop:disable Metrics/LineLength
'user' => 'root',
'logoutput' => 'on_failure')
}
it {
- is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with('ensure' => 'file')
- }
- end
-
- describe 'package_manage => true, multiple ppas, MODULES-2873' do
- let :pre_condition do
- 'class { "apt": }
- apt::ppa {"ppa:user/foo":
- package_manage => true
- }'
- end
- let :facts do
- {
- os: { family: 'Debian', name: 'Ubuntu', release: { major: '11', full: '11.04' } },
- lsbdistrelease: '11.04',
- lsbdistcodename: 'natty',
- operatingsystem: 'Ubuntu',
- osfamily: 'Debian',
- lsbdistid: 'Ubuntu',
- puppetversion: Puppet.version,
- }
- end
- let :params do
- {
- package_manage: true,
- }
- end
-
- let(:title) { 'ppa:user/bar' }
-
- it { is_expected.to contain_package('python-software-properties') }
- it {
- is_expected.to contain_exec('add-apt-repository-ppa:user/bar').that_notifies('Class[Apt::Update]').with('environment' => [],
- 'command' => '/usr/bin/add-apt-repository -y ppa:user/bar',
- 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/user-bar-natty.list',
- 'user' => 'root',
- 'logoutput' => 'on_failure')
- }
-
- it {
- is_expected.to contain_file('/etc/apt/sources.list.d/user-bar-natty.list').that_requires('Exec[add-apt-repository-ppa:user/bar]').with('ensure' => 'file')
+ is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with('ensure' => 'file')
}
end
end
let :facts do
{
- os: { family: 'Debian', name: 'Ubuntu', release: { major: '11', full: '11.04' } },
- lsbdistrelease: '11.04',
- lsbdistcodename: 'natty',
+ os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } },
+ lsbdistrelease: '14.04',
+ lsbdistcodename: 'trusty',
operatingsystem: 'Ubuntu',
osfamily: 'Debian',
lsbdistid: 'Ubuntu',
it {
is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with('environment' => [],
'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', # rubocop:disable Metrics/LineLength
- 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', # rubocop:disable Metrics/LineLength
+ 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list', # rubocop:disable Metrics/LineLength
'user' => 'root',
'logoutput' => 'on_failure')
}
it {
- is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with('ensure' => 'file')
+ is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with('ensure' => 'file')
}
end
let(:pre_condition) { 'class { "apt": }' }
let :facts do
{
- os: { distro: { codename: 'wheezy' }, family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
- lsbdistrelease: '7.0',
- lsbdistcodename: 'wheezy',
+ os: { distro: { codename: 'wheezy' }, family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
+ lsbdistrelease: '8.0',
+ lsbdistcodename: 'jessie',
operatingsystem: 'Debian',
osfamily: 'Debian',
lsbdistid: 'Debian',
end
let(:facts) do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
osfamily: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
puppetversion: Puppet.version,
}
end
context 'with mostly defaults' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
osfamily: 'Debian',
puppetversion: Puppet.version,
}
end
it {
- is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb-src http://debian.mirror.iweb.ca/debian/ wheezy main\n})
+ is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb-src http://debian.mirror.iweb.ca/debian/ jessie main\n})
}
end
context 'with no defaults' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
osfamily: 'Debian',
puppetversion: Puppet.version,
}
context 'when allow_unsigned true' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
osfamily: 'Debian',
puppetversion: Puppet.version,
}
}
end
- it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[trusted=yes\] http://debian.mirror.iweb.ca/debian/ wheezy main\n}) }
+ it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[trusted=yes\] http://debian.mirror.iweb.ca/debian/ jessie main\n}) }
end
context 'with architecture equals x86_64' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
osfamily: 'Debian',
puppetversion: Puppet.version,
}
end
it {
- is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[arch=x86_64\] http://debian.mirror.iweb.ca/debian/ wheezy main\n})
+ is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[arch=x86_64\] http://debian.mirror.iweb.ca/debian/ jessie main\n})
}
end
context 'with ensure => absent' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
osfamily: 'Debian',
puppetversion: Puppet.version,
}
context 'with no release' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
osfamily: 'Debian',
puppetversion: Puppet.version,
context 'without location' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
osfamily: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
puppetversion: Puppet.version,
}
end
context 'with location' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
osfamily: 'Debian',
puppetversion: Puppet.version,
}
describe 'no defaults' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
osfamily: 'Debian',
operatingsystem: 'Debian',
- lsbdistrelease: '7.0',
+ lsbdistrelease: '8.0',
puppetversion: Puppet.version,
}
end
end
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{hello.there wheezy main\n})
+ is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{hello.there jessie main\n})
}
it { is_expected.to contain_file('/etc/apt/sources.list.d/my_source.list').that_notifies('Class[Apt::Update]') }
context 'with allow_unsigned true' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
osfamily: 'Debian',
puppetversion: Puppet.version,
}
end
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[trusted=yes\] hello.there wheezy main\n})
+ is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[trusted=yes\] hello.there jessie main\n})
}
end
let :facts do
{
architecture: 'amd64',
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
osfamily: 'Debian',
puppetversion: Puppet.version,
}
end
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src hello.there wheezy main\n})
+ is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src hello.there jessie main\n})
}
end
context 'with include_src => true' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
osfamily: 'Debian',
puppetversion: Puppet.version,
}
end
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb hello.there wheezy main\ndeb-src hello.there wheezy main\n})
+ is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb hello.there jessie main\ndeb-src hello.there jessie main\n})
}
end
context 'with include deb => false' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
osfamily: 'debian',
puppetversion: Puppet.version,
}
context 'with include src => true and include deb => false' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
osfamily: 'debian',
puppetversion: Puppet.version,
}
end
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{deb-src hello.there wheezy main\n})
+ is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{deb-src hello.there jessie main\n})
}
- it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there wheezy main\n}) }
+ it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there jessie main\n}) }
end
context 'with ensure => absent' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
osfamily: 'Debian',
puppetversion: Puppet.version,
}
context 'with no release' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
osfamily: 'Debian',
puppetversion: Puppet.version,
context 'with release is empty string' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
osfamily: 'Debian',
puppetversion: Puppet.version,
context 'with invalid pin' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
osfamily: 'Debian',
puppetversion: Puppet.version,
}
context 'with notify_update = undef (default)' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
osfamily: 'Debian',
puppetversion: Puppet.version,
}
context 'with notify_update = true' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
osfamily: 'Debian',
puppetversion: Puppet.version,
}
context 'with notify_update = false' do
let :facts do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
- lsbdistcodename: 'wheezy',
+ lsbdistcodename: 'jessie',
osfamily: 'Debian',
puppetversion: Puppet.version,
}
+
require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'
+
+begin
+ require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb'))
+rescue LoadError => loaderror
+ warn "Could not require spec_helper_local: #{loaderror.message}"
+end
+
include RspecPuppetFacts
default_facts = {
RSpec.configure do |c|
c.default_facts = default_facts
+ c.before :each do
+ # set to strictest setting for testing
+ # by default Puppet runs at warning level
+ Puppet.settings[:strict] = :warning
+ end
end
require 'beaker-rspec'
require 'beaker/puppet_install_helper'
require 'beaker/module_install_helper'
-
-def install_bolt_on(hosts)
- on(hosts, "/opt/puppetlabs/puppet/bin/gem install --source http://rubygems.delivery.puppetlabs.net bolt -v '> 0.0.1'", acceptable_exit_codes: [0, 1]).stdout
-end
-
-def pe_install?
- ENV['PUPPET_INSTALL_TYPE'] =~ %r{pe}i
-end
+require 'beaker-task_helper'
run_puppet_install_helper
install_bolt_on(hosts) unless pe_install?
install_module_on(hosts)
install_module_dependencies_on(hosts)
-UNSUPPORTED_PLATFORMS = %w[RedHat Suse windows AIX Solaris].freeze
-
-DEFAULT_PASSWORD = if default[:hypervisor] == 'vagrant'
- 'vagrant'
- elsif default[:hypervisor] == 'vcloud'
- 'Qu@lity!'
- end
-
-def puppet_version
- (on default, puppet('--version')).output.chomp
-end
-
-def run_puppet_access_login(user:, password:
- '~!@#$%^*-/ aZ', lifetime: '5y')
- on(master, puppet('access', 'login', '--username', user, '--lifetime', lifetime), stdin: password)
-end
-
-def run_task(task_name:, params: nil, password: DEFAULT_PASSWORD)
- if pe_install?
- run_puppet_task(task_name: task_name, params: params)
- else
- run_bolt_task(task_name: task_name, params: params, password: password)
- end
-end
-
-def run_bolt_task(task_name:, params: nil, password: DEFAULT_PASSWORD)
- on(master, "/opt/puppetlabs/puppet/bin/bolt task run #{task_name} --modules /etc/puppetlabs/code/modules/service --nodes localhost --password #{password} #{params}", acceptable_exit_codes: [0, 1]).stdout # rubocop:disable Metrics/LineLength
-end
-
-def run_puppet_task(task_name:, params: nil)
- on(master, puppet('task', 'run', task_name, '--nodes', fact_on(master, 'fqdn'), params.to_s), acceptable_exit_codes: [0, 1]).stdout
-end
-
-def expect_multiple_regexes(result:, regexes:)
- regexes.each do |regex|
- expect(result).to match(regex)
- end
-end
+UNSUPPORTED_PLATFORMS = ['RedHat', 'Suse', 'windows', 'AIX', 'Solaris'].freeze
+MAX_RETRY_COUNT = 12
+RETRY_WAIT = 10
+ERROR_MATCHER = %r{(no valid OpenPGP data found|keyserver timed out|keyserver receive failed)}
# This method allows a block to be passed in and if an exception is raised
# that matches the 'error_matcher' matcher, the block will wait a set number
# retry_on_error_matching(3, 5, /OpenGPG Error/) do
# apply_manifest(pp, :catch_failures => true)
# end
-def retry_on_error_matching(max_retry_count = 3, retry_wait_interval_secs = 5, error_matcher = nil)
+def retry_on_error_matching(max_retry_count = MAX_RETRY_COUNT, retry_wait_interval_secs = RETRY_WAIT, error_matcher = ERROR_MATCHER)
try = 0
begin
+ puts "retry_on_error_matching: try #{try}" unless try.zero?
try += 1
yield
rescue StandardError => e
if Facter.version < '2.0.0'
it { is_expected.to eq('extremetuxracer,vim') }
else
- it { is_expected.to eq(%w[extremetuxracer vim]) }
+ it { is_expected.to eq(['extremetuxracer', 'vim']) }
end
end
end
if Facter.version < '2.0.0'
it { is_expected.to eq('tzdata,curl') }
else
- it { is_expected.to eq(%w[tzdata curl]) }
+ it { is_expected.to eq(['tzdata', 'curl']) }
end
end
end
--- /dev/null
+<% if $apt::auth_conf_entries != [] { -%>
+<% $apt::auth_conf_entries.each | $auth_conf_entry | { -%>
+machine <%= $auth_conf_entry['machine'] %> login <%= $auth_conf_entry['login'] %> password <%= $auth_conf_entry['password'] %>
+<% } -%>
+<% } -%>
<%- | $name, $pin_release, $release, $codename, $release_version, $component, $originator, $label, $version, $origin, $explanation, $packages_string, $priority | -%>
<%-
$pin =
-if $pin_release.length > 0 {
+if $pin_release != '' {
$options = [
- if $release { "a=${release}" },
- if $codename { "n=${codename}" },
- if $release_version { "v=${release_version}"},
- if $component { "c=${component}" },
- if $originator { "o=${originator}" },
- if $label { "l=${label}" },
+ if $release != '' { "a=${release}" },
+ if $codename != '' { "n=${codename}" },
+ if $release_version != '' { "v=${release_version}"},
+ if $component != '' { "c=${component}" },
+ if $originator != '' { "o=${originator}" },
+ if $label != '' { "l=${label}" },
].filter |$x| { $x != undef }
"release ${options.join(', ')}" }
--- /dev/null
+type Apt::Auth_conf_entry = Struct[{ machine => String[1], login => String, password => String }]