Merge remote-tracking branch 'shared/master' into bugfix/drop-obsolete-code-and-global-variable-in-apt-cron

This commit is contained in:
intrigeri 2016-06-29 18:42:02 +00:00
commit f035fd1621
10 changed files with 130 additions and 37 deletions

1
.gitignore vendored
View file

@ -5,6 +5,7 @@
/spec/fixtures/modules/* /spec/fixtures/modules/*
!/spec/fixtures/modules/apt !/spec/fixtures/modules/apt
!/spec/fixtures/modules/apt/* !/spec/fixtures/modules/apt/*
/log
/.vagrant/ /.vagrant/
/.bundle/ /.bundle/
/coverage/ /coverage/

View file

@ -11,3 +11,10 @@ group :test do
gem "rspec-puppet-facts" gem "rspec-puppet-facts"
gem "mocha" gem "mocha"
end end
group :system_tests do
gem 'beaker', :require => false
gem 'beaker-rspec', :require => false
gem 'beaker_spec_helper', :require => false
gem 'serverspec', :require => false
end

View file

@ -23,12 +23,13 @@
* [apt::preseeded_package](#apt-preseeded_package) * [apt::preseeded_package](#apt-preseeded_package)
* [apt::sources_list](#apt-sources_list) * [apt::sources_list](#apt-sources_list)
* [apt::key](#apt-key) * [apt::key](#apt-key)
* [apt::key::plain](#apt-key-plain) * [`apt::key::plain`](#apt-key-plain)
* [apt::upgrade_package](#apt-upgrade_package) * [apt::upgrade_package](#apt-upgrade_package)
* [Resources](#ressources) * [Resources](#ressources)
* [File\['apt_config'\]](#fileapt_config) * [File\['apt_config'\]](#fileapt_config)
* [Exec\['apt_updated'\]](#execapt_updated) * [Exec\['apt_updated'\]](#execapt_updated)
* [Tests](#tests) * [Tests](#tests)
* [Acceptance Tests](#acceptance-tests)
* [Licensing](#licensing) * [Licensing](#licensing)
@ -55,7 +56,7 @@ Ubuntu support is lagging behind but not absent either.
* The default value of the `$repos` parameter was removed since the logic is * The default value of the `$repos` parameter was removed since the logic is
now in the `apt::params` class. If you have explicitly set `$repos` to now in the `apt::params` class. If you have explicitly set `$repos` to
'auto' in your manifests, you should remove this. 'auto' in your manifests, you should remove this.
* The `disable_update` parameter has been removed. The main apt class * The `disable_update` parameter has been removed. The main apt class
defaults to *not* run an `apt-get update` on every run anyway so this defaults to *not* run an `apt-get update` on every run anyway so this
parameter seems useless. parameter seems useless.
@ -79,17 +80,16 @@ Ubuntu support is lagging behind but not absent either.
instantiating the class with those variables instead. For example, if you instantiating the class with those variables instead. For example, if you
had the following in your manifests: had the following in your manifests:
$apt_debian_url = 'http://localhost:9999/debian/' $apt_debian_url = 'http://localhost:9999/debian/'
$apt_use_next_release = true $apt_use_next_release = true
include apt include apt
you will need to remove the variables, and the include and instead do you will need to remove the variables, and the include and instead do
the following: the following:
class { class { 'apt':
'apt': debian_url => 'http://localhost:9999/debian/',
debian_url => 'http://localhost:9999/debian/', use_next_release => true;
use_next_release => true;
} }
previously, you could manually set `$lsbdistcodename` which would enable forced previously, you could manually set `$lsbdistcodename` which would enable forced
@ -101,26 +101,24 @@ Ubuntu support is lagging behind but not absent either.
you to trigger upgrades: you to trigger upgrades:
include apt::dist_upgrade include apt::dist_upgrade
class { class { 'apt':
'apt': codename => 'wheezy',
codename => 'wheezy', notify => Exec['apt_dist-upgrade'];
notify => Exec['apt_dist-upgrade'];
} }
* the `apticron` class has been moved to a parameterized class. if you were * the `apticron` class has been moved to a parameterized class. if you were
including this class before, you will need to move to instantiating the including this class before, you will need to move to instantiating the
class instead. For example, if you had the following in your manifests: class instead. For example, if you had the following in your manifests:
$apticron_email = 'foo@example.com' $apticron_email = 'foo@example.com'
$apticron_notifynew = '1' $apticron_notifynew = '1'
... any $apticron_* variables ... any $apticron_* variables
include apticron include apticron
you will need to remove the variables, and the include and instead do the you will need to remove the variables, and the include and instead do the
following: following:
class { class { 'apt::apticron':
'apt::apticron':
email => 'foo@example.com', email => 'foo@example.com',
notifynew => '1'; notifynew => '1';
} }
@ -130,16 +128,15 @@ Ubuntu support is lagging behind but not absent either.
to move to instantiating the class with those variables instead. For example, to move to instantiating the class with those variables instead. For example,
if you had the following in your manifests: if you had the following in your manifests:
$apt_listchanges_email = 'foo@example.com' $apt_listchanges_email = 'foo@example.com'
... any $apt_listchanges_* variables ... any $apt_listchanges_* variables
include apt::listchanges include apt::listchanges
you will need to remove the variables, and the include and instead do the you will need to remove the variables, and the include and instead do the
following: following:
class { class { 'apt::listchanges':
'apt::listchanges': email => 'foo@example.com';
email => 'foo@example.com';
} }
* the `apt::proxy_client` class has been moved to a paramterized class. if you * the `apt::proxy_client` class has been moved to a paramterized class. if you
@ -147,18 +144,17 @@ Ubuntu support is lagging behind but not absent either.
to move to instantiating the class with those variables instead. For example, to move to instantiating the class with those variables instead. For example,
if you had the following in your manifests: if you had the following in your manifests:
$apt_proxy = 'http://proxy.domain' $apt_proxy = 'http://proxy.domain'
$apt_proxy_port = 666 $apt_proxy_port = 666
include apt::proxy_client include apt::proxy_client
you will need to remove the variables, and the include and instead do the you will need to remove the variables, and the include and instead do the
following: following:
class { class { 'apt::proxy_client':
'apt::proxy_client': proxy => 'http://proxy.domain',
proxy => 'http://proxy.domain', port => '666';
port => '666'; }
}
# Requirements<a name="requirements"></a> # Requirements<a name="requirements"></a>
@ -570,7 +566,7 @@ use `apt::key::plain`.
The `.gpg` extension is compulsory for `apt` to pickup the key properly. The `.gpg` extension is compulsory for `apt` to pickup the key properly.
## apt::key::plain<a name="apt-key-plain"></a> ## `apt::key::plain`<a name="apt-key-plain"></a>
Deploys a secure apt OpenPGP key. This usually accompanies the Deploys a secure apt OpenPGP key. This usually accompanies the
sources.list snippets above for third party repositories. For example, sources.list snippets above for third party repositories. For example,
@ -647,11 +643,33 @@ To run pupept rspec tests:
bundle install --path vendor/bundle bundle install --path vendor/bundle
bundle exec rake spec bundle exec rake spec
Verbose Output:
bundle exec rake spec SPEC_OPTS='--format documentation'
Using different facter/puppet versions: Using different facter/puppet versions:
FACTER_GEM_VERSION=1.6.10 PUPPET_GEM_VERSION=2.7.23 bundle install --path vendor/bundle FACTER_GEM_VERSION=1.6.10 PUPPET_GEM_VERSION=2.7.23 bundle install --path vendor/bundle
bundle exec rake spec bundle exec rake spec
## Acceptance Tests<a name="acceptance-tests"></a>
At the moment, we use [beaker together with docker](https://github.com/puppetlabs/beaker/blob/master/docs/Docker-Support.md)
to do acceptance testing.
Be sure to have a recent docker version installed.
List configured nodesets:
bundle exec rake beaker_nodes
Run tests on default node (Debian Jessie):
bundle exec rake beaker
Run different nodeset:
BEAKER_set="debian-8-x86_64-docker" bundle exec rspec spec/acceptance/*_spec.rb
# Licensing<a name="licensing"></a> # Licensing<a name="licensing"></a>

View file

@ -1,3 +1,4 @@
# Install a package with a preseed file to automatically answer some questions.
define apt::preseeded_package ( define apt::preseeded_package (
$ensure = 'installed', $ensure = 'installed',
$content = '' $content = ''
@ -10,7 +11,9 @@ define apt::preseeded_package (
file { $seedfile: file { $seedfile:
content => $real_content, content => $real_content,
mode => '0600', owner => root, group => root, mode => '0600',
owner => 'root',
group => 0,
} }
package { $name: package { $name:

View file

@ -1,3 +1,4 @@
# Configure an apt source
define apt::sources_list ( define apt::sources_list (
$ensure = 'present', $ensure = 'present',
$source = '', $source = '',
@ -22,7 +23,9 @@ define apt::sources_list (
# apparently doesn't. # apparently doesn't.
file { "/etc/apt/sources.list.d/${realname}.list": file { "/etc/apt/sources.list.d/${realname}.list":
ensure => $ensure, ensure => $ensure,
owner => root, group => 0, mode => '0644', mode => '0644',
owner => 'root',
group => 0,
notify => Exec['apt_updated'], notify => Exec['apt_updated'],
} }

View file

@ -1,3 +1,5 @@
# Install a package either to a certain version, or while making sure that it's
# always the latest version that's installed.
define apt::upgrade_package ( define apt::upgrade_package (
$version = '' $version = ''
) { ) {
@ -23,7 +25,7 @@ define apt::upgrade_package (
} }
exec { "apt-get -q -y -o 'DPkg::Options::=--force-confold' install ${name}${version_suffix}": exec { "apt-get -q -y -o 'DPkg::Options::=--force-confold' install ${name}${version_suffix}":
onlyif => [ "grep-status -F Status installed -a -P $name -q", "apt-show-versions -u $name | grep -q upgradeable" ], onlyif => [ "grep-status -F Status installed -a -P ${name} -q", "apt-show-versions -u ${name} | grep -q upgradeable" ],
require => Package['apt-show-versions', 'dctrl-tools'], require => Package['apt-show-versions', 'dctrl-tools'],
before => Exec['apt_updated'] before => Exec['apt_updated']
} }

View file

@ -0,0 +1,21 @@
require 'spec_helper_acceptance'
describe 'apt class' do
context 'default parameters' do
it 'should work idempotently with no errors' do
pp = <<-EOS
class { 'apt': }
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe package('apt') do
it { is_expected.to be_installed }
end
end
end

View file

@ -0,0 +1,19 @@
HOSTS:
debian-8-x64:
platform: debian-8-amd64
image: debian:8
hypervisor: docker
docker_preserve_image: true
docker_cmd: '["/sbin/init"]'
docker_image_commands:
- 'apt-get install -y wget locales-all puppet git'
- 'rm -f /usr/sbin/policy-rc.d'
CONFIG:
type: foss
#log_level: verbose
#log_level: debug
ssh:
password: root
auth_methods: ["password"]

View file

@ -0,0 +1 @@
debian-8-x86_64-docker.yml

View file

@ -0,0 +1,18 @@
require 'beaker-rspec'
RSpec.configure do |c|
module_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
module_name = module_root.split('-').last
# Readable test descriptions
c.formatter = :documentation
# Configure all nodes in nodeset
c.before :suite do
# Install module and dependencies
puppet_module_install(:source => module_root, :module_name => module_name)
hosts.each do |host|
shell('git clone https://gitlab.com/shared-puppet-modules-group/common.git /etc/puppet/modules/common')
end
end
end