Switch to puppetlabs/apt

(imported from commit b2f581280dc7877051ef79d86eac671bfd455ace)
This commit is contained in:
Luke Faraone 2014-01-30 14:28:59 -05:00
parent 364bbf08cf
commit aa52475e96
301 changed files with 12221 additions and 1120 deletions

View File

@ -1 +0,0 @@
puppet-apt/

View File

@ -0,0 +1,2 @@
---
BUNDLE_WITHOUT: development

5
puppet/apt/.fixtures.yml Normal file
View File

@ -0,0 +1,5 @@
fixtures:
repositories:
"stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
symlinks:
"apt": "#{source_dir}"

View File

@ -0,0 +1,29 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>puppetlabs</groupId>
<artifactId>ghpublisher</artifactId>
<version>1.0.0</version>
<packaging>puppet-module</packaging>
<name>ghpublisher</name>
<properties>
<forge.login>${env.PUBLISHER_LOGIN}</forge.login>
<forge.password>${env.PUBLISHER_PASSWORD}</forge.password>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.cloudsmith.geppetto</groupId>
<artifactId>forge-maven-plugin</artifactId>
<version>3.2.0</version>
<extensions>true</extensions>
<configuration>
<enablePuppetLintValidation>false</enablePuppetLintValidation>
<cacheLocation>${project.build.directory}/forgeCache</cacheLocation>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,18 @@
#!/bin/sh
#
# Perform GitHub publish
if [ -z "$PUBLISHER_LOGIN" ]
then
echo "Environment variable PUBLISHER_LOGIN must be set"
exit 1
fi
if [ -z "$PUBLISHER_PASSWORD" ]
then
echo "Environment variable PUBLISHER_PASSWORD must be set"
exit 1
fi
MODULES_ROOT=`pwd`
cd $(dirname $0)
mvn -q -s settings.xml -Dforge.modules.root="$MODULES_ROOT" deploy

View File

@ -0,0 +1,34 @@
<settings>
<profiles>
<profile>
<id>cloudsmith</id>
<repositories>
<repository>
<id>cloudsmith</id>
<url>https://am0.cloudsmith.com/nexus/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>cloudsmith</id>
<url>https://am0.cloudsmith.com/nexus/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>cloudsmith</activeProfile>
</activeProfiles>
</settings>

View File

@ -0,0 +1,6 @@
#!/bin/sh
#
# Perform GitHub publish
MODULES_ROOT=`pwd`
cd $(dirname $0)
mvn -q -s settings.xml -Dforge.modules.root="$MODULES_ROOT" compile

19
puppet/apt/.nodeset.yml Normal file
View File

@ -0,0 +1,19 @@
---
default_set: 'ubuntu-server-12042-x64'
sets:
'debian-607-x64':
nodes:
"main.foo.vm":
prefab: 'debian-607-x64'
'debian-70rc1-x64':
nodes:
"main.foo.vm":
prefab: 'debian-70rc1-x64'
'ubuntu-server-10044-x64':
nodes:
"main.foo.vm":
prefab: 'ubuntu-server-10044-x64'
'ubuntu-server-12042-x64':
nodes:
"main.foo.vm":
prefab: 'ubuntu-server-12042-x64'

40
puppet/apt/.travis.yml Normal file
View File

@ -0,0 +1,40 @@
---
branches:
only:
- master
language: ruby
bundler_args: --without development
script: bundle exec rake spec SPEC_OPTS='--format documentation'
after_success:
- git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-release
- .forge-release/publish
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
env:
matrix:
- PUPPET_GEM_VERSION="~> 2.7.0"
- PUPPET_GEM_VERSION="~> 3.0.0"
- PUPPET_GEM_VERSION="~> 3.1.0"
- PUPPET_GEM_VERSION="~> 3.2.0"
global:
- PUBLISHER_LOGIN=puppetlabs
- secure: |-
ipB/CV1rVSTXU9ZDuzrFOlzJrRmJob36tKns2xszuH4r9s5P9qivNAngRGdV
msb69xvOlzQykM0WRF+4kJ6TZ7AbMiDI+VZ8GDtsRaU5/q3BpsvFe8aato+6
QeyFtBG62OsosTEhGws4mqiFsPDu3dHlakuJc9zevlTuhNwbKSs=
matrix:
exclude:
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 2.7.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 2.7.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.0.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.1.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 3.2.0"
notifications:
email: false

183
puppet/apt/CHANGELOG Normal file
View File

@ -0,0 +1,183 @@
2013-10-08 1.4.0
Summary:
Minor bugfix and allow the timeout to be adjusted.
Features:
- Add an `updates_timeout` to apt::params
Fixes:
- Ensure apt::ppa can readd a ppa removed by hand.
Summary
1.3.0
=====
Summary:
This major feature in this release is the new apt::unattended_upgrades class,
allowing you to handle Ubuntu's unattended feature. This allows you to select
specific packages to automatically upgrade without any further user
involvement.
In addition we extend our Wheezy support, add proxy support to apt:ppa and do
various cleanups and tweaks.
Features:
- Add apt::unattended_upgrades support for Ubuntu.
- Add wheezy backports support.
- Use the geoDNS http.debian.net instead of the main debian ftp server.
- Add `options` parameter to apt::ppa in order to pass options to apt-add-repository command.
- Add proxy support for apt::ppa (uses proxy_host and proxy_port from apt).
Bugfixes:
- Fix regsubst() calls to quote single letters (for future parser).
- Fix lint warnings and other misc cleanup.
1.2.0
=====
Features:
- Add geppetto `.project` natures
- Add GH auto-release
- Add `apt::key::key_options` parameter
- Add complex pin support using distribution properties for `apt::pin` via new properties:
- `apt::pin::codename`
- `apt::pin::release_version`
- `apt::pin::component`
- `apt::pin::originator`
- `apt::pin::label`
- Add source architecture support to `apt::source::architecture`
Bugfixes:
- Use apt-get instead of aptitude in apt::force
- Update default backports location
- Add dependency for required packages before apt-get update
1.1.1
=====
This is a bug fix release that resolves a number of issues:
* By changing template variable usage, we remove the deprecation warnings
for Puppet 3.2.x
* Fixed proxy file removal, when proxy absent
Some documentation, style and whitespaces changes were also merged. This
release also introduced proper rspec-puppet unit testing on Travis-CI to help
reduce regression.
Thanks to all the community contributors below that made this patch possible.
#### Detail Changes
* fix minor comment type (Chris Rutter)
* whitespace fixes (Michael Moll)
* Update travis config file (William Van Hevelingen)
* Build all branches on travis (William Van Hevelingen)
* Standardize travis.yml on pattern introduced in stdlib (William Van Hevelingen)
* Updated content to conform to README best practices template (Lauren Rother)
* Fix apt::release example in readme (Brian Galey)
* add @ to variables in template (Peter Hoeg)
* Remove deprecation warnings for pin.pref.erb as well (Ken Barber)
* Update travis.yml to latest versions of puppet (Ken Barber)
* Fix proxy file removal (Scott Barber)
* Add spec test for removing proxy configuration (Dean Reilly)
* Fix apt::key listing longer than 8 chars (Benjamin Knofe)
---------------------------------------
1.1.0
=====
This release includes Ubuntu 12.10 (Quantal) support for PPAs.
---------------------------------------
2012-05-25 Puppet Labs <info@puppetlabs.com> - 0.0.4
* Fix ppa list filename when there is a period in the PPA name
* Add .pref extension to apt preferences files
* Allow preferences to be purged
* Extend pin support
2012-05-04 Puppet Labs <info@puppetlabs.com> - 0.0.3
* only invoke apt-get update once
* only install python-software-properties if a ppa is added
* support 'ensure => absent' for all defined types
* add apt::conf
* add apt::backports
* fixed Modulefile for module tool dependency resolution
* configure proxy before doing apt-get update
* use apt-get update instead of aptitude for apt::ppa
* add support to pin release
2012-03-26 Puppet Labs <info@puppetlabs.com> - 0.0.2
41cedbb (#13261) Add real examples to smoke tests.
d159a78 (#13261) Add key.pp smoke test
7116c7a (#13261) Replace foo source with puppetlabs source
1ead0bf Ignore pkg directory.
9c13872 (#13289) Fix some more style violations
0ea4ffa (#13289) Change test scaffolding to use a module & manifest dir fixture path
a758247 (#13289) Clean up style violations and fix corresponding tests
99c3fd3 (#13289) Add puppet lint tests to Rakefile
5148cbf (#13125) Apt keys should be case insensitive
b9607a4 Convert apt::key to use anchors
2012-03-07 Puppet Labs <info@puppetlabs.com> - 0.0.1
d4fec56 Modify apt::source release parameter test
1132a07 (#12917) Add contributors to README
8cdaf85 (#12823) Add apt::key defined type and modify apt::source to use it
7c0d10b (#12809) $release should use $lsbdistcodename and fall back to manual input
be2cc3e (#12522) Adjust spec test for splitting purge
7dc60ae (#12522) Split purge option to spare sources.list
9059c4e Fix source specs to test all key permutations
8acb202 Add test for python-software-properties package
a4af11f Check if python-software-properties is defined before attempting to define it.
1dcbf3d Add tests for required_packages change
f3735d2 Allow duplicate $required_packages
74c8371 (#12430) Add tests for changes to apt module
97ebb2d Test two sources with the same key
1160bcd (#12526) Add ability to reverse apt { disable_keys => true }
2842d73 Add Modulefile to puppet-apt
c657742 Allow the use of the same key in multiple sources
8c27963 (#12522) Adding purge option to apt class
997c9fd (#12529) Add unit test for apt proxy settings
50f3cca (#12529) Add parameter to support setting a proxy for apt
d522877 (#12094) Replace chained .with_* with a hash
8cf1bd0 (#12094) Remove deprecated spec.opts file
2d688f4 (#12094) Add rspec-puppet tests for apt
0fb5f78 (#12094) Replace name with path in file resources
f759bc0 (#11953) Apt::force passes $version to aptitude
f71db53 (#11413) Add spec test for apt::force to verify changes to unless
2f5d317 (#11413) Update dpkg query used by apt::force
cf6caa1 (#10451) Add test coverage to apt::ppa
0dd697d include_src parameter in example; Whitespace cleanup
b662eb8 fix typos in "repositories"
1be7457 Fix (#10451) - apt::ppa fails to "apt-get update" when new PPA source is added
864302a Set the pin priority before adding the source (Fix #10449)
1de4e0a Refactored as per mlitteken
1af9a13 Added some crazy bash madness to check if the ppa is installed already. Otherwise the manifest tries to add it on every run!
52ca73e (#8720) Replace Apt::Ppa with Apt::Builddep
5c05fa0 added builddep command.
a11af50 added the ability to specify the content of a key
c42db0f Fixes ppa test.
77d2b0d reformatted whitespace to match recommended style of 2 space indentation.
27ebdfc ignore swap files.
377d58a added smoke tests for module.
18f614b reformatted apt::ppa according to recommended style.
d8a1e4e Created a params class to hold global data.
636ae85 Added two params for apt class
148fc73 Update LICENSE.
ed2d19e Support ability to add more than one PPA
420d537 Add call to apt-update after add-apt-repository in apt::ppa
945be77 Add package definition for python-software-properties
71fc425 Abs paths for all commands
9d51cd1 Adding LICENSE
71796e3 Heading fix in README
87777d8 Typo in README
f848bac First commit

16
puppet/apt/Gemfile Normal file
View File

@ -0,0 +1,16 @@
source 'https://rubygems.org'
group :development, :test do
gem 'rake', :require => false
gem 'rspec-puppet', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'rspec-system', :require => false
gem 'rspec-system-puppet', :require => false
gem 'rspec-system-serverspec', :require => false
end
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end

70
puppet/apt/Gemfile.lock Normal file
View File

@ -0,0 +1,70 @@
GEM
remote: https://rubygems.org/
specs:
builder (3.2.2)
diff-lcs (1.2.4)
facter (1.6.18)
hiera (1.0.0)
highline (1.6.19)
kwalify (0.7.2)
metaclass (0.0.1)
mocha (0.14.0)
metaclass (~> 0.0.1)
net-scp (1.1.2)
net-ssh (>= 2.6.5)
net-ssh (2.7.0)
nokogiri (1.5.10)
puppet (3.0.2)
facter (~> 1.6.11)
hiera (~> 1.0.0)
puppetlabs_spec_helper (0.4.1)
mocha (>= 0.10.5)
rake
rspec (>= 2.9.0)
rspec-puppet (>= 0.1.1)
rake (10.1.0)
rbvmomi (1.6.0)
builder
nokogiri (>= 1.4.1)
trollop
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.5)
rspec-expectations (2.14.3)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.3)
rspec-puppet (0.1.6)
rspec
rspec-system (2.3.0)
kwalify (~> 0.7.2)
net-scp (~> 1.1)
net-ssh (~> 2.6)
nokogiri (~> 1.5.9)
rbvmomi (~> 1.6)
rspec (~> 2.13)
systemu (~> 2.5)
rspec-system-puppet (2.2.0)
rspec-system (~> 2.0)
rspec-system-serverspec (1.0.1)
rspec-system (~> 2.0)
serverspec (~> 0.0)
serverspec (0.10.5)
highline
net-ssh
rspec (>= 2.13.0)
systemu (2.5.2)
trollop (2.0)
PLATFORMS
ruby
DEPENDENCIES
puppet (~> 3.0.0)
puppetlabs_spec_helper
rake
rspec-puppet
rspec-system
rspec-system-puppet
rspec-system-serverspec

19
puppet/apt/LICENSE Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2011 Evolving Web Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

14
puppet/apt/Modulefile Normal file
View File

@ -0,0 +1,14 @@
name 'puppetlabs-apt'
version '1.4.0'
source 'https://github.com/puppetlabs/puppetlabs-apt'
author 'Evolving Web / Puppet Labs'
license 'Apache License 2.0'
summary 'Puppet Labs Apt Module'
description 'APT Module for Puppet'
project_page 'https://github.com/puppetlabs/puppetlabs-apt'
## Add dependencies, if any:
#dependency 'puppetlabs/stdlib', '2.x'
# The dependency should be written as above but librarian-puppet
# does not support the expression as the PMT does.
dependency 'puppetlabs/stdlib', '>= 2.2.1'

226
puppet/apt/README.md Normal file
View File

@ -0,0 +1,226 @@
apt
===
[![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-apt.png?branch=master)](https://travis-ci.org/puppetlabs/puppetlabs-apt)
## Description
Provides helpful definitions for dealing with Apt.
=======
Overview
--------
The APT module provides a simple interface for managing APT source, key, and definitions with Puppet.
Module Description
------------------
APT automates obtaining and installing software packages on *nix systems.
Setup
-----
**What APT affects:**
* package/service/configuration files for APT
* your system's `sources.list` file and `sources.list.d` directory
* NOTE: Setting the `purge_sources_list` and `purge_sources_list_d` parameters to 'true' will destroy any existing content that was not declared with Puppet. The default for these parameters is 'false'.
* system repositories
* authentication keys
* wget (optional)
###Beginning with APT
To begin using the APT module with default parameters, declare the class
class { 'apt': }
Puppet code that uses anything from the APT module requires that the core apt class be declared.
Usage
-----
Using the APT module consists predominantly in declaring classes that provide desired functionality and features.
###apt
`apt` provides a number of common resources and options that are shared by the various defined types in this module, so you MUST always include this class in your manifests.
The parameters for `apt` are not required in general and are predominantly for development environment use-cases.
class { 'apt':
always_apt_update => false,
disable_keys => undef,
proxy_host => false,
proxy_port => '8080',
purge_sources_list => false,
purge_sources_list_d => false,
purge_preferences_d => false,
update_timeout => undef
}
Puppet will manage your system's `sources.list` file and `sources.list.d` directory but will do its best to respect existing content.
If you declare your apt class with `purge_sources_list` and `purge_sources_list_d` set to 'true', Puppet will unapologetically purge any existing content it finds that wasn't declared with Puppet.
###apt::builddep
Installs the build depends of a specified package.
apt::builddep { 'glusterfs-server': }
###apt::force
Forces a package to be installed from a specific release. This class is particularly useful when using repositories, like Debian, that are unstable in Ubuntu.
apt::force { 'glusterfs-server':
release => 'unstable',
version => '3.0.3',
require => Apt::Source['debian_unstable'],
}
###apt::key
Adds a key to the list of keys used by APT to authenticate packages.
apt::key { 'puppetlabs':
key => '4BD6EC30',
key_server => 'pgp.mit.edu',
}
apt::key { 'jenkins':
key => 'D50582E6',
key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key',
}
Note that use of `key_source` requires wget to be installed and working.
###apt::pin
Adds an apt pin for a certain release.
apt::pin { 'karmic': priority => 700 }
apt::pin { 'karmic-updates': priority => 700 }
apt::pin { 'karmic-security': priority => 700 }
Note you can also specifying more complex pins using distribution properties.
apt::pin { 'stable':
priority => -10,
originator => 'Debian',
release_version => '3.0',
component => 'main',
label => 'Debian'
}
###apt::ppa
Adds a ppa repository using `add-apt-repository`.
apt::ppa { 'ppa:drizzle-developers/ppa': }
###apt::release
Sets the default apt release. This class is particularly useful when using repositories, like Debian, that are unstable in Ubuntu.
class { 'apt::release':
release_id => 'precise',
}
###apt::source
Adds an apt source to `/etc/apt/sources.list.d/`.
apt::source { 'debian_unstable':
location => 'http://debian.mirror.iweb.ca/debian/',
release => 'unstable',
repos => 'main contrib non-free',
required_packages => 'debian-keyring debian-archive-keyring',
key => '55BE302B',
key_server => 'subkeys.pgp.net',
pin => '-10',
include_src => true
}
If you would like to configure your system so the source is the Puppet Labs APT repository
apt::source { 'puppetlabs':
location => 'http://apt.puppetlabs.com',
repos => 'main',
key => '4BD6EC30',
key_server => 'pgp.mit.edu',
}
###Testing
The APT module is mostly a collection of defined resource types, which provide reusable logic that can be leveraged to manage APT. It does provide smoke tests for testing functionality on a target system, as well as spec tests for checking a compiled catalog against an expected set of resources.
####Example Test
This test will set up a Puppet Labs apt repository. Start by creating a new smoke test in the apt module's test folder. Call it puppetlabs-apt.pp. Inside, declare a single resource representing the Puppet Labs APT source and gpg key
apt::source { 'puppetlabs':
location => 'http://apt.puppetlabs.com',
repos => 'main',
key => '4BD6EC30',
key_server => 'pgp.mit.edu',
}
This resource creates an apt source named puppetlabs and gives Puppet information about the repository's location and key used to sign its packages. Puppet leverages Facter to determine the appropriate release, but you can set it directly by adding the release type.
Check your smoke test for syntax errors
$ puppet parser validate tests/puppetlabs-apt.pp
If you receive no output from that command, it means nothing is wrong. Then apply the code
$ puppet apply --verbose tests/puppetlabs-apt.pp
notice: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]/ensure: defined content as '{md5}3be1da4923fb910f1102a233b77e982e'
info: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]: Scheduling refresh of Exec[puppetlabs apt update]
notice: /Stage[main]//Apt::Source[puppetlabs]/Exec[puppetlabs apt update]: Triggered 'refresh' from 1 events>
The above example used a smoke test to easily lay out a resource declaration and apply it on your system. In production, you may want to declare your APT sources inside the classes where theyre needed.
Implementation
--------------
###apt::backports
Adds the necessary components to get backports for Ubuntu and Debian. The release name defaults to `$lsbdistcodename`. Setting this manually can cause undefined behavior (read: universe exploding).
Limitations
-----------
This module should work across all versions of Debian/Ubuntu and support all major APT repository management features.
Development
------------
Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We cant access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve.
We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing)
Contributors
------------
A lot of great people have contributed to this module. A somewhat current list follows:
* Ben Godfrey <ben.godfrey@wonga.com>
* Branan Purvine-Riley <branan@puppetlabs.com>
* Christian G. Warden <cwarden@xerus.org>
* Dan Bode <bodepd@gmail.com> <dan@puppetlabs.com>
* Garrett Honeycutt <github@garretthoneycutt.com>
* Jeff Wallace <jeff@evolvingweb.ca> <jeff@tjwallace.ca>
* Ken Barber <ken@bob.sh>
* Matthaus Litteken <matthaus@puppetlabs.com> <mlitteken@gmail.com>
* Matthias Pigulla <mp@webfactory.de>
* Monty Taylor <mordred@inaugust.com>
* Peter Drake <pdrake@allplayers.com>
* Reid Vandewiele <marut@cat.pdx.edu>
* Robert Navarro <rnavarro@phiivo.com>
* Ryan Coleman <ryan@puppetlabs.com>
* Scott McLeod <scott.mcleod@theice.com>
* Spencer Krum <spencer@puppetlabs.com>
* William Van Hevelingen <blkperl@cat.pdx.edu> <wvan13@gmail.com>
* Zach Leslie <zach@puppetlabs.com>

2
puppet/apt/Rakefile Normal file
View File

@ -0,0 +1,2 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'rspec-system/rake_task'

View File

@ -0,0 +1,48 @@
# This adds the necessary components to get backports for ubuntu and debian
#
# == Parameters
#
# [*release*]
# The ubuntu/debian release name. Defaults to $lsbdistcodename. Setting this
# manually can cause undefined behavior. (Read: universe exploding)
#
# == Examples
#
# include apt::backports
#
# class { 'apt::backports':
# release => 'natty',
# }
#
# == Authors
#
# Ben Hughes, I think. At least blame him if this goes wrong.
# I just added puppet doc.
#
# == Copyright
#
# Copyright 2011 Puppet Labs Inc, unless otherwise noted.
class apt::backports(
$release = $::lsbdistcodename,
$location = $apt::params::backports_location
) inherits apt::params {
$release_real = downcase($release)
$key = $::lsbdistid ? {
'debian' => '55BE302B',
'ubuntu' => '437D05B5',
}
$repos = $::lsbdistid ? {
'debian' => 'main contrib non-free',
'ubuntu' => 'main universe multiverse restricted',
}
apt::source { 'backports':
location => $location,
release => "${release_real}-backports",
repos => $repos,
key => $key,
key_server => 'pgp.mit.edu',
pin => '200',
}
}

View File

@ -0,0 +1,16 @@
# builddep.pp
define apt::builddep() {
include apt::update
exec { "apt-builddep-${name}":
command => "/usr/bin/apt-get -y --force-yes build-dep ${name}",
logoutput => 'on_failure',
notify => Exec['apt_update'],
}
# Need anchor to provide containment for dependencies.
anchor { "apt::builddep::${name}":
require => Class['apt::update'],
}
}

View File

@ -0,0 +1,18 @@
define apt::conf (
$content,
$ensure = present,
$priority = '50'
) {
include apt::params
$apt_conf_d = $apt::params::apt_conf_d
file { "${apt_conf_d}/${priority}${name}":
ensure => $ensure,
content => $content,
owner => root,
group => root,
mode => '0644',
}
}

View File

@ -0,0 +1,21 @@
# testing.pp
class apt::debian::testing {
include apt
# deb http://debian.mirror.iweb.ca/debian/ testing main contrib non-free
# deb-src http://debian.mirror.iweb.ca/debian/ testing main contrib non-free
# Key: 55BE302B Server: subkeys.pgp.net
# debian-keyring
# debian-archive-keyring
apt::source { 'debian_testing':
location => 'http://debian.mirror.iweb.ca/debian/',
release => 'testing',
repos => 'main contrib non-free',
required_packages => 'debian-keyring debian-archive-keyring',
key => '55BE302B',
key_server => 'subkeys.pgp.net',
pin => '-10',
}
}

View File

@ -0,0 +1,21 @@
# unstable.pp
class apt::debian::unstable {
include apt
# deb http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free
# deb-src http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free
# Key: 55BE302B Server: subkeys.pgp.net
# debian-keyring
# debian-archive-keyring
apt::source { 'debian_unstable':
location => 'http://debian.mirror.iweb.ca/debian/',
release => 'unstable',
repos => 'main contrib non-free',
required_packages => 'debian-keyring debian-archive-keyring',
key => '55BE302B',
key_server => 'subkeys.pgp.net',
pin => '-10',
}
}

View File

@ -0,0 +1,24 @@
# force.pp
# force a package from a specific release
define apt::force(
$release = 'testing',
$version = false,
$timeout = 300
) {
$version_string = $version ? {
false => undef,
default => "=${version}",
}
$install_check = $version ? {
false => "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'",
default => "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'",
}
exec { "/usr/bin/apt-get -y -t ${release} install ${name}${version_string}":
unless => $install_check,
logoutput => 'on_failure',
timeout => $timeout,
}
}

View File

@ -0,0 +1,121 @@
# Class: apt
#
# This module manages the initial configuration of apt.
#
# Parameters:
# The parameters listed here are not required in general and were
# added for use cases related to development environments.
# disable_keys - disables the requirement for all packages to be signed
# always_apt_update - rather apt should be updated on every run (intended
# for development environments where package updates are frequent)
# purge_sources_list - Accepts true or false. Defaults to false If set to
# true, Puppet will purge all unmanaged entries from sources.list
# purge_sources_list_d - Accepts true or false. Defaults to false. If set
# to true, Puppet will purge all unmanaged entries from sources.list.d
# update_timeout - Overrides the exec timeout in seconds for apt-get update.
# If not set defaults to Exec's default (300)
#
# Actions:
#
# Requires:
# puppetlabs/stdlib
# Sample Usage:
# class { 'apt': }
class apt(
$always_apt_update = false,
$disable_keys = undef,
$proxy_host = false,
$proxy_port = '8080',
$purge_sources_list = false,
$purge_sources_list_d = false,
$purge_preferences_d = false,
$update_timeout = undef
) {
include apt::params
include apt::update
validate_bool($purge_sources_list, $purge_sources_list_d, $purge_preferences_d)
$sources_list_content = $purge_sources_list ? {
false => undef,
true => "# Repos managed by puppet.\n",
}
if $always_apt_update == true {
Exec <| title=='apt_update' |> {
refreshonly => false,
}
}
$root = $apt::params::root
$apt_conf_d = $apt::params::apt_conf_d
$sources_list_d = $apt::params::sources_list_d
$preferences_d = $apt::params::preferences_d
$provider = $apt::params::provider
file { 'sources.list':
ensure => present,
path => "${root}/sources.list",
owner => root,
group => root,
mode => '0644',
content => $sources_list_content,
notify => Exec['apt_update'],
}
file { 'sources.list.d':
ensure => directory,
path => $sources_list_d,
owner => root,
group => root,
purge => $purge_sources_list_d,
recurse => $purge_sources_list_d,
notify => Exec['apt_update'],
}
file { 'preferences.d':
ensure => directory,
path => $preferences_d,
owner => root,
group => root,
purge => $purge_preferences_d,
recurse => $purge_preferences_d,
}
case $disable_keys {
true: {
file { '99unauth':
ensure => present,
content => "APT::Get::AllowUnauthenticated 1;\n",
path => "${apt_conf_d}/99unauth",
}
}
false: {
file { '99unauth':
ensure => absent,
path => "${apt_conf_d}/99unauth",
}
}
undef: { } # do nothing
default: { fail('Valid values for disable_keys are true or false') }
}
$proxy_set = $proxy_host ? {
false => absent,
default => present
}
file { 'configure-apt-proxy':
ensure => $proxy_set,
path => "${apt_conf_d}/proxy",
content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";",
notify => Exec['apt_update'],
}
# Need anchor to provide containment for dependencies.
anchor { 'apt::update':
require => Class['apt::update'],
}
}

View File

@ -0,0 +1,90 @@
define apt::key (
$key = $title,
$ensure = present,
$key_content = false,
$key_source = false,
$key_server = 'keyserver.ubuntu.com',
$key_options = false
) {
include apt::params
$upkey = upcase($key)
# trim the key to the last 8 chars so we can match longer keys with apt-key list too
$trimmedkey = regsubst($upkey, '^.*(.{8})$', '\1')
if $key_content {
$method = 'content'
} elsif $key_source {
$method = 'source'
} elsif $key_server {
$method = 'server'
}
# This is a hash of the parts of the key definition that we care about.
# It is used as a unique identifier for this instance of apt::key. It gets
# hashed to ensure that the resource name doesn't end up being pages and
# pages (e.g. in the situation where key_content is specified).
$digest = sha1("${upkey}/${key_content}/${key_source}/${key_server}/")
# Allow multiple ensure => present for the same key to account for many
# apt::source resources that all reference the same key.
case $ensure {
present: {
anchor { "apt::key/${title}": }
if defined(Exec["apt::key ${upkey} absent"]) {
fail("Cannot ensure Apt::Key[${upkey}] present; ${upkey} already ensured absent")
}
if !defined(Anchor["apt::key ${upkey} present"]) {
anchor { "apt::key ${upkey} present": }
}
if $key_options{
$options_string = "--keyserver-options ${key_options}"
}
else{
$options_string = ''
}
if !defined(Exec[$digest]) {
$digest_command = $method ? {
'content' => "echo '${key_content}' | /usr/bin/apt-key add -",
'source' => "wget -q '${key_source}' -O- | apt-key add -",
'server' => "apt-key adv --keyserver '${key_server}' ${options_string} --recv-keys '${upkey}'",
}
exec { $digest:
command => $digest_command,
path => '/bin:/usr/bin',
unless => "/usr/bin/apt-key list | /bin/grep '${trimmedkey}'",
logoutput => 'on_failure',
before => Anchor["apt::key ${upkey} present"],
}
}
Anchor["apt::key ${upkey} present"] -> Anchor["apt::key/${title}"]
}
absent: {
if defined(Anchor["apt::key ${upkey} present"]) {
fail("Cannot ensure Apt::Key[${upkey}] absent; ${upkey} already ensured present")
}
exec { "apt::key ${upkey} absent":
command => "apt-key del '${upkey}'",
path => '/bin:/usr/bin',
onlyif => "apt-key list | grep '${trimmedkey}'",
user => 'root',
group => 'root',
logoutput => 'on_failure',
}
}
default: {
fail "Invalid 'ensure' value '${ensure}' for aptkey"
}
}
}

View File

@ -0,0 +1,33 @@
class apt::params {
$root = '/etc/apt'
$provider = '/usr/bin/apt-get'
$sources_list_d = "${root}/sources.list.d"
$apt_conf_d = "${root}/apt.conf.d"
$preferences_d = "${root}/preferences.d"
case $::lsbdistid {
'debian': {
case $::lsbdistcodename {
'squeeze': {
$backports_location = 'http://backports.debian.org/debian-backports'
}
'wheezy': {
$backports_location = 'http://ftp.debian.org/debian/'
}
default: {
$backports_location = 'http://http.debian.net/debian/'
}
}
}
'ubuntu': {
case $::lsbdistcodename {
'hardy','lucid','maverick','natty','oneiric','precise': {
$backports_location = 'http://us.archive.ubuntu.com/ubuntu'
}
default: {
$backports_location = 'http://old-releases.ubuntu.com/ubuntu'
}
}
}
}
}

View File

@ -0,0 +1,73 @@
# pin.pp
# pin a release in apt, useful for unstable repositories
define apt::pin(
$ensure = present,
$explanation = "${::caller_module_name}: ${name}",
$order = '',
$packages = '*',
$priority = 0,
$release = '', # a=
$origin = '',
$version = '',
$codename = '', # n=
$release_version = '', # v=
$component = '', # c=
$originator = '', # o=
$label = '' # l=
) {
include apt::params
$preferences_d = $apt::params::preferences_d
if $order != '' and !is_integer($order) {
fail('Only integers are allowed in the apt::pin order param')
}
$pin_release_array = [
$release,
$codename,
$release_version,
$component,
$originator,
$label]
$pin_release = join($pin_release_array, '')
# Read the manpage 'apt_preferences(5)', especially the chapter
# 'Thea Effect of APT Preferences' to understand the following logic
# and the difference between specific and general form
if $packages != '*' { # specific form
if ( $pin_release != '' and ( $origin != '' or $version != '' )) or
( $origin != '' and ( $pin_release != '' or $version != '' )) or
( $version != '' and ( $pin_release != '' or $origin != '' )) {
fail('parameters release, origin, and version are mutually exclusive')
}
} else { # general form
if $version != '' {
fail('parameter version cannot be used in general form')
}
if ( $pin_release != '' and $origin != '' ) or
( $origin != '' and $pin_release != '' ) {
fail('parmeters release and origin are mutually exclusive')
}
}
$path = $order ? {
'' => "${preferences_d}/${name}.pref",
default => "${preferences_d}/${order}-${name}.pref",
}
file { "${name}.pref":
ensure => $ensure,
path => $path,
owner => root,
group => root,
mode => '0644',
content => template('apt/pin.pref.erb'),
}
}

View File

@ -0,0 +1,63 @@
# ppa.pp
define apt::ppa(
$release = $::lsbdistcodename,
$options = '-y'
) {
include apt::params
include apt::update
$sources_list_d = $apt::params::sources_list_d
if ! $release {
fail('lsbdistcodename fact not available: release parameter required')
}
$filename_without_slashes = regsubst($name, '/', '-', 'G')
$filename_without_dots = regsubst($filename_without_slashes, '\.', '_', 'G')
$filename_without_ppa = regsubst($filename_without_dots, '^ppa:', '', 'G')
$sources_list_d_filename = "${filename_without_ppa}-${release}.list"
$package = $::lsbdistrelease ? {
/^[1-9]\..*|1[01]\..*|12.04$/ => 'python-software-properties',
default => 'software-properties-common',
}
if ! defined(Package[$package]) {
package { $package: }
}
if defined(Class[apt]) {
$proxy_host = getparam(Class[apt], 'proxy_host')
$proxy_port = getparam(Class[apt], 'proxy_port')
case $proxy_host {
false, '': {
$proxy_env = []
}
default: {$proxy_env = ["http_proxy=http://${proxy_host}:${proxy_port}", "https_proxy=http://${proxy_host}:${proxy_port}"]}
}
} else {
$proxy_env = []
}
exec { "add-apt-repository-${name}":
environment => $proxy_env,
command => "/usr/bin/add-apt-repository ${options} ${name}",
unless => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}",
logoutput => 'on_failure',
notify => Exec['apt_update'],
require => [
File[$sources_list_d],
Package[$package],
],
}
file { "${sources_list_d}/${sources_list_d_filename}":
ensure => file,
require => Exec["add-apt-repository-${name}"],
}
# Need anchor to provide containment for dependencies.
anchor { "apt::ppa::${name}":
require => Class['apt::update'],
}
}

View File

@ -0,0 +1,17 @@
# release.pp
class apt::release (
$release_id
) {
include apt::params
$root = $apt::params::root
file { "${root}/apt.conf.d/01release":
owner => root,
group => root,
mode => '0644',
content => "APT::Default-Release \"${release_id}\";"
}
}

View File

@ -0,0 +1,85 @@
# source.pp
# add an apt source
define apt::source(
$ensure = present,
$location = '',
$release = 'UNDEF',
$repos = 'main',
$include_src = true,
$required_packages = false,
$key = false,
$key_server = 'keyserver.ubuntu.com',
$key_content = false,
$key_source = false,
$pin = false,
$architecture = undef
) {
include apt::params
include apt::update
$sources_list_d = $apt::params::sources_list_d
$provider = $apt::params::provider
if $release == 'UNDEF' {
if $::lsbdistcodename == undef {
fail('lsbdistcodename fact not available: release parameter required')
} else {
$release_real = $::lsbdistcodename
}
} else {
$release_real = $release
}
file { "${name}.list":
ensure => $ensure,
path => "${sources_list_d}/${name}.list",
owner => root,
group => root,
mode => '0644',
content => template("${module_name}/source.list.erb"),
notify => Exec['apt_update'],
}
if ($pin != false) {
# Get the host portion out of the url so we can pin to origin
$url_split = split($location, '/')
$host = $url_split[2]
apt::pin { $name:
ensure => $ensure,
priority => $pin,
before => File["${name}.list"],
origin => $host,
}
}
if ($required_packages != false) and ($ensure == 'present') {
exec { "Required packages: '${required_packages}' for ${name}":
command => "${provider} -y install ${required_packages}",
logoutput => 'on_failure',
refreshonly => true,
subscribe => File["${name}.list"],
before => Exec['apt_update'],
}
}
# We do not want to remove keys when the source is absent.
if ($key != false) and ($ensure == 'present') {
apt::key { "Add key: ${key} from Apt::Source ${title}":
ensure => present,
key => $key,
key_server => $key_server,
key_content => $key_content,
key_source => $key_source,
before => File["${name}.list"],
}
}
# Need anchor to provide containment for dependencies.
anchor { "apt::source::${name}":
require => Class['apt::update'],
}
}

View File

@ -0,0 +1,68 @@
# Class: apt::unattended_upgrades
#
# This class manages the unattended-upgrades package and related configuration
# files for ubuntu
#
# origins are the repositories to automatically upgrade included packages
# blacklist is a list of packages to not automatically upgrade
# update is how often to run "apt-get update" in days
# download is how often to run "apt-get upgrade --download-only" in days
# upgrade is how often to upgrade packages included in the origins list in days
# autoclean is how often to run "apt-get autoclean" in days
#
# information on the other options can be found in the 50unattended-upgrades
# file and in /etc/cron.daily/apt
#
class apt::unattended_upgrades (
$origins = ['${distro_id}:${distro_codename}-security'],
$blacklist = [],
$update = "1",
$download = "1",
$upgrade = "1",
$autoclean = "7",
$auto_fix = true,
$minimal_steps = false,
$install_on_shutdown = false,
$mail_to = "NONE",
$mail_only_on_error = false,
$remove_unused = true,
$auto_reboot = false,
$dl_limit = "NONE",
$enable = "1",
$backup_interval = "0",
$backup_level = "3",
$max_age = "0",
$min_age = "0",
$max_size = "0",
$download_delta = "0",
$verbose = "0",
) {
validate_bool(
$auto_fix,
$minimal_steps,
$install_on_shutdown,
$mail_only_on_error,
$remove_unused,
$auto_reboot
)
package { 'unattended-upgrades':
ensure => present,
}
File {
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
require => Package['unattended-upgrades'],
}
file {
'/etc/apt/apt.conf.d/50unattended-upgrades':
content => template('apt/50unattended-upgrades.erb');
'/etc/apt/apt.conf.d/10periodic':
content => template('apt/10periodic.erb');
}
}

View File

@ -0,0 +1,10 @@
class apt::update {
include apt::params
exec { 'apt_update':
command => "${apt::params::provider} update",
logoutput => 'on_failure',
refreshonly => true,
timeout => $apt::update_timeout,
}
}

87
puppet/apt/metadata.json Normal file
View File

@ -0,0 +1,87 @@
{
"name": "puppetlabs-apt",
"version": "1.4.0",
"summary": "Puppet Labs Apt Module",
"author": "Evolving Web / Puppet Labs",
"description": "APT Module for Puppet",
"dependencies": [
{
"name": "puppetlabs/stdlib",
"version_requirement": "\u003e\u003d 2.2.1"
}
],
"types": [],
"checksums": {
".bundle/config": "7f1c988748783d2a8d455376eed1470c",
".fixtures.yml": "0c43f56b0bb8e8d04e8051a0e7aa37a5",
".forge-release/pom.xml": "c650a84961ad88de03192e23b63b3549",
".forge-release/publish": "1c1d6dd64ef52246db485eb5459aa941",
".forge-release/settings.xml": "06d768a57d582fe1ee078b563427e750",
".forge-release/validate": "7fffde8112f42a1ec986d49ba80ac219",
".nodeset.yml": "78d78c172336a387a1067464434ffbcb",
".travis.yml": "782420dcc9d6412c79c30f03b1f3613c",
"CHANGELOG": "f5488e1e891a8f8c47143dac790ddab3",
"Gemfile": "1bfa7eb6e30346c9ddb4a8b144b0d255",
"Gemfile.lock": "8ff8bc3d32bb7412bd97e48190a93b2f",
"LICENSE": "20bcc606fc61ffba2b8cea840e8dce4d",
"Modulefile": "b34e93626fbc137cbb651952e7509839",
"README.md": "65176b395f7202fe5d222ae7b0de4e05",
"Rakefile": "0428ea3759a4692c91604396c406a9c1",
"manifests/backports.pp": "09f1d86603d0f44a2169acb3eeea2a70",
"manifests/builddep.pp": "4f313b5140c84aa7d5793b5a073c30dd",
"manifests/conf.pp": "5ddf258195d414d93284dfd281a8d6e3",
"manifests/debian/testing.pp": "aeb625bacb6a8df46c864ee9ee1cb5a5",
"manifests/debian/unstable.pp": "108038596b05dc1d28975884693f73f5",
"manifests/force.pp": "cf871e869f4114f32ab164de2a67e7e2",
"manifests/init.pp": "5ec106a7a03313c544159a9a1f6b78e6",
"manifests/key.pp": "3cf082ed91a3933ab7218d1be3464f4f",
"manifests/params.pp": "ca4ce3730a65c43f884ab3e6445f1661",
"manifests/pin.pp": "dea8cbaabc37010ce25838080608802b",
"manifests/ppa.pp": "754a83944ae79b5001fc0c0a8c775985",
"manifests/release.pp": "427f3ee70a6a1e55fa291e58655bd5d9",
"manifests/source.pp": "6eab8d33c173a066f5dec8474efdedb6",
"manifests/unattended_upgrades.pp": "e97f908b42010ff9a85be4afd2c721ab",
"manifests/update.pp": "436c79f160f2cb603710795a9ec71ac7",
"spec/classes/apt_spec.rb": "54841b04b42026770ed6d744a82c55df",
"spec/classes/backports_spec.rb": "7d2454a881cc26edd3dcd3acb7ffd20f",
"spec/classes/debian_testing_spec.rb": "fad1384cb9d3c99b2663d7df4762dc0e",
"spec/classes/debian_unstable_spec.rb": "11131efffd18db3c96e2bbe3d98a2fb7",
"spec/classes/params_spec.rb": "a25396d3f0bbac784a7951f03ad7e8f4",
"spec/classes/release_spec.rb": "d8f01a3cf0c2f6f6952b835196163ce4",
"spec/classes/unattended_upgrades_spec.rb": "a2e206bda79d24cdb43312d035eff66f",
"spec/defines/builddep_spec.rb": "e1300bb4f3abbd34029b11d8b733a6e5",
"spec/defines/conf_spec.rb": "b7fc9fb6cb270c276aacbfa4a43f228c",
"spec/defines/force_spec.rb": "97098c5b123be49e321e71cda288fe53",
"spec/defines/key_spec.rb": "7800c30647b1ddf799b991110109cba0",
"spec/defines/pin_spec.rb": "c912e59e9e3d1145280d659cccabe72b",
"spec/defines/ppa_spec.rb": "72ce037a1d6ea0a33f369b1f3d98b3d6",
"spec/defines/source_spec.rb": "e553bb9598dbe2becba6ae7f91d4deb0",
"spec/spec_helper.rb": "0db89c9a486df193c0e40095422e19dc",
"spec/spec_helper_system.rb": "e67d2574baae312f1095f90d78fdf5e9",
"spec/system/apt_builddep_spec.rb": "97be5a48d2d16d96cb7c35ccdbcdcb69",
"spec/system/apt_key_spec.rb": "098835d0c53c69390d4c3b6ea8ef3815",
"spec/system/apt_ppa_spec.rb": "c96f6d0bbdafac39beaf0d5e6eba9010",
"spec/system/apt_source_spec.rb": "df5aa98b03688884903c564bb507469f",
"spec/system/basic_spec.rb": "0a5b33d18254bedcb7886e34846ebff6",
"spec/system/class_spec.rb": "2ba4265236f00685c23cb00f908defc1",
"templates/10periodic.erb": "2aeea866a39f19a62254abbb4f1bc59d",
"templates/50unattended-upgrades.erb": "ae995ade214fdaefab51d335c85819ae",
"templates/pin.pref.erb": "623249839cee7788fa0805a3474396db",
"templates/source.list.erb": "65a016e60daf065c481f3d5f2c883324",
"tests/builddep.pp": "4773f57072111e58f2ed833fa4489a88",
"tests/debian/testing.pp": "1cbee56baddd6a91d981db8fddec70fb",
"tests/debian/unstable.pp": "4b2a090afeb315752262386f4dbcd8ca",
"tests/force.pp": "2bb6cf0b3d655cb51f95aeb79035e600",
"tests/init.pp": "551138eb704e71ab3687932dda429a81",
"tests/key.pp": "371a695e1332d51a38e283a87be52798",
"tests/params.pp": "900db40f3fc84b0be173278df2ebff35",
"tests/pin.pp": "4b4c3612d75a19dba8eb7227070fa4ab",
"tests/ppa.pp": "b902cce8159128b5e8b21bed540743ff",
"tests/release.pp": "53ce5debe6fa5bee42821767599cc768",
"tests/source.pp": "9cecd9aa0dcde250fe49be9e26971a98",
"tests/unattended-upgrades.pp": "cdc853f1b58e5206c5a538621ddca161"
},
"source": "https://github.com/puppetlabs/puppetlabs-apt",
"project_page": "https://github.com/puppetlabs/puppetlabs-apt",
"license": "Apache License 2.0"
}

View File

@ -0,0 +1,133 @@
require 'spec_helper'
describe 'apt', :type => :class do
let :default_params do
{
:disable_keys => :undef,
:always_apt_update => false,
:purge_sources_list => false,
:purge_sources_list_d => false,
}
end
[{},
{
:disable_keys => true,
:always_apt_update => true,
:proxy_host => true,
:proxy_port => '3128',
:purge_sources_list => true,
:purge_sources_list_d => true,
},
{
:disable_keys => false
}
].each do |param_set|
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
let :param_hash do
default_params.merge(param_set)
end
let :params do
param_set
end
let :refresh_only_apt_update do
if param_hash[:always_apt_update]
false
else
true
end
end
it { should include_class("apt::params") }
it {
if param_hash[:purge_sources_list]
should contain_file("sources.list").with({
'path' => "/etc/apt/sources.list",
'ensure' => "present",
'owner' => "root",
'group' => "root",
'mode' => "0644",
"content" => "# Repos managed by puppet.\n"
})
else
should contain_file("sources.list").with({
'path' => "/etc/apt/sources.list",
'ensure' => "present",
'owner' => "root",
'group' => "root",
'mode' => "0644",
'content' => nil
})
end
}
it {
if param_hash[:purge_sources_list_d]
should create_file("sources.list.d").with({
'path' => "/etc/apt/sources.list.d",
'ensure' => "directory",
'owner' => "root",
'group' => "root",
'purge' => true,
'recurse' => true,
'notify' => 'Exec[apt_update]'
})
else
should create_file("sources.list.d").with({
'path' => "/etc/apt/sources.list.d",
'ensure' => "directory",
'owner' => "root",
'group' => "root",
'purge' => false,
'recurse' => false,
'notify' => 'Exec[apt_update]'
})
end
}
it {
should contain_exec("apt_update").with({
'command' => "/usr/bin/apt-get update",
'refreshonly' => refresh_only_apt_update
})
}
it {
if param_hash[:disable_keys] == true
should create_file("99unauth").with({
'content' => "APT::Get::AllowUnauthenticated 1;\n",
'ensure' => "present",
'path' => "/etc/apt/apt.conf.d/99unauth"
})
elsif param_hash[:disable_keys] == false
should create_file("99unauth").with({
'ensure' => "absent",
'path' => "/etc/apt/apt.conf.d/99unauth"
})
elsif param_hash[:disable_keys] != :undef
should_not create_file("99unauth").with({
'path' => "/etc/apt/apt.conf.d/99unauth"
})
end
}
describe 'when setting a proxy' do
it {
if param_hash[:proxy_host]
should contain_file('configure-apt-proxy').with(
'path' => '/etc/apt/apt.conf.d/proxy',
'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";",
'notify' => "Exec[apt_update]"
)
else
should contain_file('configure-apt-proxy').with(
'path' => '/etc/apt/apt.conf.d/proxy',
'notify' => 'Exec[apt_update]',
'ensure' => 'absent'
)
end
}
end
end
end
end

View File

@ -0,0 +1,71 @@
require 'spec_helper'
describe 'apt::backports', :type => :class do
describe 'when turning on backports for ubuntu karmic' do
let :facts do
{
'lsbdistcodename' => 'Karmic',
'lsbdistid' => 'Ubuntu'
}
end
it { should contain_apt__source('backports').with({
'location' => 'http://old-releases.ubuntu.com/ubuntu',
'release' => 'karmic-backports',
'repos' => 'main universe multiverse restricted',
'key' => '437D05B5',
'key_server' => 'pgp.mit.edu',
'pin' => '200',
})
}
end
describe "when turning on backports for debian squeeze" do
let :facts do
{
'lsbdistcodename' => 'Squeeze',
'lsbdistid' => 'Debian',
}
end
it { should contain_apt__source('backports').with({
'location' => 'http://backports.debian.org/debian-backports',
'release' => 'squeeze-backports',
'repos' => 'main contrib non-free',
'key' => '55BE302B',
'key_server' => 'pgp.mit.edu',
'pin' => '200',
})
}
end
describe "when turning on backports for debian squeeze but using your own mirror" do
let :facts do
{
'lsbdistcodename' => 'Squeeze',
'lsbdistid' => 'Debian'
}
end
let :location do
'http://mirrors.example.com/debian-backports'
end
let :params do
{ 'location' => location }
end
it { should contain_apt__source('backports').with({
'location' => location,
'release' => 'squeeze-backports',
'repos' => 'main contrib non-free',
'key' => '55BE302B',
'key_server' => 'pgp.mit.edu',
'pin' => '200',
})
}
end
end

View File

@ -0,0 +1,14 @@
require 'spec_helper'
describe 'apt::debian::testing', :type => :class do
it {
should contain_apt__source("debian_testing").with({
"location" => "http://debian.mirror.iweb.ca/debian/",
"release" => "testing",
"repos" => "main contrib non-free",
"required_packages" => "debian-keyring debian-archive-keyring",
"key" => "55BE302B",
"key_server" => "subkeys.pgp.net",
"pin" => "-10"
})
}
end

View File

@ -0,0 +1,14 @@
require 'spec_helper'
describe 'apt::debian::unstable', :type => :class do
it {
should contain_apt__source("debian_unstable").with({
"location" => "http://debian.mirror.iweb.ca/debian/",
"release" => "unstable",
"repos" => "main contrib non-free",
"required_packages" => "debian-keyring debian-archive-keyring",
"key" => "55BE302B",
"key_server" => "subkeys.pgp.net",
"pin" => "-10"
})
}
end

View File

@ -0,0 +1,13 @@
require 'spec_helper'
describe 'apt::params', :type => :class do
let (:title) { 'my_package' }
it { should contain_apt__params }
# There are 4 resources in this class currently
# there should not be any more resources because it is a params class
# The resources are class[apt::params], class[main], class[settings], stage[main]
it "Should not contain any resources" do
subject.resources.size.should == 4
end
end

View File

@ -0,0 +1,22 @@
require 'spec_helper'
describe 'apt::release', :type => :class do
let (:title) { 'my_package' }
let :param_set do
{ :release_id => 'precise' }
end
let (:params) { param_set }
it { should include_class("apt::params") }
it {
should contain_file("/etc/apt/apt.conf.d/01release").with({
"mode" => "0644",
"owner" => "root",
"group" => "root",
"content" => "APT::Default-Release \"#{param_set[:release_id]}\";"
})
}
end

View File

@ -0,0 +1,204 @@
require 'spec_helper'
describe 'apt::unattended_upgrades', :type => :class do
let(:file_unattended) { '/etc/apt/apt.conf.d/50unattended-upgrades' }
let(:file_periodic) { '/etc/apt/apt.conf.d/10periodic' }
it { should contain_package("unattended-upgrades") }
it {
should create_file("/etc/apt/apt.conf.d/50unattended-upgrades").with({
"owner" => "root",
"group" => "root",
"mode" => "0644",
"require" => "Package[unattended-upgrades]",
})
}
it {
should create_file("/etc/apt/apt.conf.d/10periodic").with({
"owner" => "root",
"group" => "root",
"mode" => "0644",
"require" => "Package[unattended-upgrades]",
})
}
describe "origins" do
describe "with param defaults" do
let(:params) {{ }}
it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"\${distro_id}:\${distro_codename}-security";\n\};$/) }
end
describe "with origins => ['ubuntu:precise-security']" do
let :params do
{ :origins => ['ubuntu:precise-security'] }
end
it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"ubuntu:precise-security";\n\};$/) }
end
end
describe "blacklist" do
describe "with param defaults" do
let(:params) {{ }}
it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\};$/) }
end
describe "with blacklist => []" do
let :params do
{ :blacklist => ['libc6', 'libc6-dev'] }
end
it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\t"libc6";\n\t"libc6-dev";\n\};$/) }
end
end
describe "with update => 2" do
let :params do
{ :update => "2" }
end
it { should contain_file(file_periodic).with_content(/^APT::Periodic::Update-Package-Lists "2";$/) }
end
describe "with download => 2" do
let :params do
{ :download => "2" }
end
it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages "2";$/) }
end
describe "with upgrade => 2" do
let :params do
{ :upgrade => "2" }
end
it { should contain_file(file_periodic).with_content(/^APT::Periodic::Unattended-Upgrade "2";$/) }
end
describe "with autoclean => 2" do
let :params do
{ :autoclean => "2" }
end
it { should contain_file(file_periodic).with_content(/^APT::Periodic::AutocleanInterval "2";$/) }
end
describe "with auto_fix => false" do
let :params do
{ :auto_fix => false }
end
it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::AutoFixInterruptedDpkg "false";$/) }
end
describe "with minimal_steps => true" do
let :params do
{ :minimal_steps => true }
end
it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MinimalSteps "true";$/) }
end
describe "with install_on_shutdown => true" do
let :params do
{ :install_on_shutdown => true }
end
it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::InstallOnShutdown "true";$/) }
end
describe "mail_to" do
describe "param defaults" do
let(:params) {{ }}
it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail /) }
it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError /) }
end
describe "with mail_to => user@website, mail_only_on_error => true" do
let :params do
{ :mail_to => "user@website",
:mail_only_on_error => true }
end
it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail "user@website";$/) }
it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError "true";$/) }
end
end
describe "with remove_unused => false" do
let :params do
{ :remove_unused => false }
end
it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Remove-Unused-Dependencies "false";$/) }
end
describe "with auto_reboot => true" do
let :params do
{ :auto_reboot => true }
end
it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Automatic-Reboot "true";$/) }
end
describe "dl_limit" do
describe "param defaults" do
let(:params) {{ }}
it { should_not contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit /) }
end
describe "with dl_limit => 70" do
let :params do
{ :dl_limit => "70" }
end
it { should contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit "70";$/) }
end
end
describe "with enable => 0" do
let :params do
{ :enable => "0" }
end
it { should contain_file(file_periodic).with_content(/^APT::Periodic::Enable "0";$/) }
end
describe "with backup_interval => 1" do
let :params do
{ :backup_interval => "1" }
end
it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpArchiveInterval "1";$/) }
end
describe "with backup_level => 0" do
let :params do
{ :backup_level => "0" }
end
it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpLevel "0";$/) }
end
describe "with max_age => 1" do
let :params do
{ :max_age => "1" }
end
it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxAge "1";$/) }
end
describe "with min_age => 1" do
let :params do
{ :min_age => "1" }
end
it { should contain_file(file_periodic).with_content(/^APT::Periodic::MinAge "1";$/) }
end
describe "with max_size => 1" do
let :params do
{ :max_size => "1" }
end
it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxSize "1";$/) }
end
describe "with download_delta => 2" do
let :params do
{ :download_delta => "2" }
end
it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";$/) }
end
describe "with verbose => 2" do
let :params do
{ :verbose => "2" }
end
it { should contain_file(file_periodic).with_content(/^APT::Periodic::Verbose "2";$/) }
end
end

View File

@ -0,0 +1,18 @@
require 'spec_helper'
describe 'apt::builddep', :type => :define do
let(:title) { 'my_package' }
describe "should require apt-get update" do
it { should contain_exec("apt_update").with({
'command' => "/usr/bin/apt-get update",
'refreshonly' => true
})
}
it { should contain_anchor("apt::builddep::my_package").with({
'require' => 'Class[Apt::Update]',
})
}
end
end

View File

@ -0,0 +1,57 @@
require 'spec_helper'
describe 'apt::conf', :type => :define do
let :title do
'norecommends'
end
describe "when creating an apt preference" do
let :params do
{
:priority => '00',
:content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n"
}
end
let :filename do
"/etc/apt/apt.conf.d/00norecommends"
end
it { should contain_apt__conf('norecommends').with({
'priority' => '00',
'content' => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n"
})
}
it { should contain_file(filename).with({
'ensure' => 'present',
'content' => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n",
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
end
describe "when removing an apt preference" do
let :params do
{
:ensure => 'absent',
:priority => '00',
:content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n"
}
end
let :filename do
"/etc/apt/apt.conf.d/00norecommends"
end
it { should contain_file(filename).with({
'ensure' => 'absent',
'content' => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n",
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
end
end

View File

@ -0,0 +1,41 @@
require 'spec_helper'
describe 'apt::force', :type => :define do
let :title do
'my_package'
end
let :default_params do
{
:release => 'testing',
:version => false
}
end
[{},
{
:release => 'stable',
:version => '1'
}
].each do |param_set|
describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do
let :param_hash do
default_params.merge(param_set)
end
let :params do
param_set
end
let :unless_query do
base_command = "/usr/bin/dpkg -s #{title} | grep -q "
base_command + (params[:version] ? "'Version: #{params[:version]}'" : "'Status: install'")
end
let :exec_title do
base_exec = "/usr/bin/apt-get -y -t #{param_hash[:release]} install #{title}"
base_exec + (params[:version] ? "=#{params[:version]}" : "")
end
it { should contain_exec(exec_title).with_unless(unless_query) }
end
end
end

View File

@ -0,0 +1,123 @@
require 'spec_helper'
describe 'apt::key', :type => :define do
let :title do
'8347A27F'
end
let :default_params do
{
:key => title,
:ensure => 'present',
:key_server => "keyserver.ubuntu.com",
:key_source => false,
:key_content => false
}
end
[{},
{
:ensure => 'absent'
},
{
:ensure => 'random'
},
{
:key_source => 'ftp://ftp.example.org/key',
},
{
:key_content => 'deadbeef',
}
].each do |param_set|
let :param_hash do
param_hash = default_params.merge(param_set)
param_hash[:key].upcase! if param_hash[:key]
param_hash
end
let :params do
param_set
end
let :digest do
str = String.new
str << param_hash[:key].to_s << '/'
str << param_hash[:key_content].to_s << '/'
str << param_hash[:key_source].to_s << '/'
str << param_hash[:key_server].to_s << '/'
Digest::SHA1.hexdigest(str)
end
describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do
it {
if [:present, 'present', :absent, 'absent'].include? param_hash[:ensure]
should contain_apt__params
end
}
it {
if [:present, 'present'].include? param_hash[:ensure]
should_not contain_exec("apt::key #{param_hash[:key]} absent")
should contain_anchor("apt::key #{param_hash[:key]} present")
should contain_exec(digest).with({
"path" => "/bin:/usr/bin",
"unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'"
})
elsif [:absent, 'absent'].include? param_hash[:ensure]
should_not contain_anchor("apt::key #{param_hash[:key]} present")
should contain_exec("apt::key #{param_hash[:key]} absent").with({
"path" => "/bin:/usr/bin",
"onlyif" => "apt-key list | grep '#{param_hash[:key]}'",
"command" => "apt-key del '#{param_hash[:key]}'"
})
else
expect { should raise_error(Puppet::Error) }
end
}
it {
if [:present, 'present'].include? param_hash[:ensure]
if param_hash[:key_content]
should contain_exec(digest).with({
"command" => "echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -"
})
elsif param_hash[:key_source]
should contain_exec(digest).with({
"command" => "wget -q '#{param_hash[:key_source]}' -O- | apt-key add -"
})
elsif param_hash[:key_server]
should contain_exec(digest).with({
"command" => "apt-key adv --keyserver '#{param_hash[:key_server]}' --recv-keys '#{param_hash[:key]}'"
})
end
end
}
end
end
[{ :ensure => 'present' }, { :ensure => 'absent' }].each do |param_set|
describe "should correctly handle duplicate definitions" do
let :pre_condition do
"apt::key { 'duplicate': key => '#{title}'; }"
end
let(:params) { param_set }
it {
if param_set[:ensure] == 'present'
should contain_anchor("apt::key #{title} present")
should contain_apt__key(title)
should contain_apt__key("duplicate")
elsif param_set[:ensure] == 'absent'
expect { should raise_error(Puppet::Error) }
end
}
end
end
end

View File

@ -0,0 +1,101 @@
require 'spec_helper'
describe 'apt::pin', :type => :define do
let(:title) { 'my_pin' }
let :default_params do
{
:ensure => 'present',
:order => '',
:packages => '*',
:priority => '0',
:release => nil
}
end
[
{ :params => {},
:content => "# my_pin\nExplanation: : my_pin\nPackage: *\nPin: release a=my_pin\nPin-Priority: 0\n"
},
{
:params => {
:packages => 'apache',
:priority => '1'
},
:content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n"
},
{
:params => {
:order => 50,
:packages => 'apache',
:priority => '1'
},
:content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n"
},
{
:params => {
:ensure => 'absent',
:packages => 'apache',
:priority => '1'
},
:content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n"
},
{
:params => {
:packages => 'apache',
:priority => '1',
:release => 'my_newpin'
},
:content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_newpin\nPin-Priority: 1\n"
},
{
:params => {
:packages => 'apache',
:priority => '1',
:version => '2.2.16*'
},
:content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: version 2.2.16*\nPin-Priority: 1\n"
},
{
:params => {
:priority => '1',
:origin => 'ftp.de.debian.org'
},
:content => "# my_pin\nExplanation: : my_pin\nPackage: *\nPin: origin \"ftp.de.debian.org\"\nPin-Priority: 1\n"
},
{
:params => {
:packages => 'apache',
:priority => '1',
:release => 'stable',
:codename => 'wheezy',
:release_version => '3.0',
:component => 'main',
:originator => 'Debian',
:label => 'Debian'
},
:content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=stable, n=wheezy, v=3.0, c=main, o=Debian, l=Debian\nPin-Priority: 1\n"
},
].each do |param_set|
describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do
let :param_hash do
default_params.merge(param_set[:params])
end
let :params do
param_set[:params]
end
it { should include_class("apt::params") }
it { should contain_file("#{title}.pref").with({
'ensure' => param_hash[:ensure],
'path' => "/etc/apt/preferences.d/#{param_hash[:order] == '' ? "" : "#{param_hash[:order]}-"}#{title}.pref",
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
'content' => param_set[:content],
})
}
end
end
end

View File

@ -0,0 +1,143 @@
require 'spec_helper'
describe 'apt::ppa', :type => :define do
[ { :lsbdistrelease => '11.04',
:lsbdistcodename => 'natty',
:package => 'python-software-properties'},
{ :lsbdistrelease => '12.10',
:lsbdistcodename => 'quantal',
:package => 'software-properties-common'},
].each do |platform|
context "on #{platform[:lsbdistcodename]}" do
let :facts do
{
:lsbdistrelease => platform[:lsbdistrelease],
:lsbdistcodename => platform[:lsbdistcodename],
}
end
let :release do
"#{platform[:lsbdistcodename]}"
end
let :package do
"#{platform[:package]}"
end
let :options do
"-y"
end
['ppa:dans_ppa', 'dans_ppa','ppa:dans-daily/ubuntu'].each do |t|
describe "with title #{t}" do
let :pre_condition do
'class { "apt": }'
end
let :title do
t
end
let :filename do
t.sub(/^ppa:/,'').gsub('/','-') << "-" << "#{release}.list"
end
it { should contain_package("#{package}") }
it { should contain_exec("apt_update").with(
'command' => '/usr/bin/apt-get update',
'refreshonly' => true
)
}
it { should contain_exec("add-apt-repository-#{t}").with(
'command' => "/usr/bin/add-apt-repository #{options} #{t}",
'unless' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"],
'notify' => "Exec[apt_update]"
)
}
it { should create_file("/etc/apt/sources.list.d/#{filename}").with(
'ensure' => 'file',
'require' => "Exec[add-apt-repository-#{t}]"
)
}
end
end
describe 'without a proxy defined' do
let :title do
'rspec_ppa'
end
let :pre_condition do
'class { "apt":
proxy_host => false
}'
end
let :filename do
"#{title}-#{release}.list"
end
it { should contain_exec("add-apt-repository-#{title}").with(
'environment' => [],
'command' => "/usr/bin/add-apt-repository #{options} #{title}",
'unless' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"],
'notify' => "Exec[apt_update]"
)
}
end
describe 'behind a proxy' do
let :title do
'rspec_ppa'
end
let :pre_condition do
'class { "apt":
proxy_host => "user:pass@proxy",
}'
end
let :filename do
"#{title}-#{release}.list"
end
it { should contain_exec("add-apt-repository-#{title}").with(
'environment' => [
"http_proxy=http://user:pass@proxy:8080",
"https_proxy=http://user:pass@proxy:8080",
],
'command' => "/usr/bin/add-apt-repository #{options} #{title}",
'unless' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"],
'notify' => "Exec[apt_update]"
)
}
end
end
end
[ { :lsbdistcodename => 'natty',
:package => 'python-software-properties' },
{ :lsbdistcodename => 'quantal',
:package => 'software-properties-common'},
].each do |platform|
context "on #{platform[:lsbdistcodename]}" do
describe "it should not error if package['#{platform[:package]}'] is already defined" do
let :pre_condition do
'class {"apt": }' +
'package { "#{platform[:package]}": }->Apt::Ppa["ppa"]'
end
let :facts do
{:lsbdistcodename => '#{platform[:lsbdistcodename]}'}
end
let(:title) { "ppa" }
let(:release) { "#{platform[:lsbdistcodename]}" }
it { should contain_package('#{platform[:package]}') }
end
end
end
describe "without Class[apt] should raise a Puppet::Error" do
let(:release) { "natty" }
let(:title) { "ppa" }
it { expect { should contain_apt__ppa(title) }.to raise_error(Puppet::Error) }
end
describe "without release should raise a Puppet::Error" do
let(:title) { "ppa:" }
it { expect { should contain_apt__ppa(:release) }.to raise_error(Puppet::Error) }
end
end

View File

@ -0,0 +1,166 @@
require 'spec_helper'
describe 'apt::source', :type => :define do
let :title do
'my_source'
end
let :default_params do
{
:ensure => 'present',
:location => '',
:release => 'karmic',
:repos => 'main',
:include_src => true,
:required_packages => false,
:key => false,
:key_server => 'keyserver.ubuntu.com',
:key_content => false,
:key_source => false,
:pin => false
}
end
[{},
{
:location => 'http://example.com',
:release => 'precise',
:repos => 'security',
:include_src => false,
:required_packages => 'apache',
:key => 'key_name',
:key_server => 'keyserver.debian.com',
:pin => '600',
:key_content => 'ABCD1234'
},
{
:key => 'key_name',
:key_server => 'keyserver.debian.com',
:key_content => false,
},
{
:ensure => 'absent',
:location => 'http://example.com',
:release => 'precise',
:repos => 'security',
},
{
:release => '',
},
{
:release => 'custom',
},
{
:architecture => 'amd64',
}
].each do |param_set|
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
let :param_hash do
default_params.merge(param_set)
end
let :facts do
{:lsbdistcodename => 'karmic'}
end
let :params do
param_set
end
let :filename do
"/etc/apt/sources.list.d/#{title}.list"
end
let :content do
content = "# #{title}"
if param_hash[:architecture]
arch = "[arch=#{param_hash[:architecture]}]"
end
content << "\ndeb #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
if param_hash[:include_src]
content << "deb-src #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
end
content
end
it { should contain_apt__params }
it { should contain_file("#{title}.list").with({
'ensure' => param_hash[:ensure],
'path' => filename,
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
'content' => content,
})
}
it {
if param_hash[:pin]
should contain_apt__pin(title).with({
"priority" => param_hash[:pin],
"before" => "File[#{title}.list]"
})
else
should_not contain_apt__pin(title).with({
"priority" => param_hash[:pin],
"before" => "File[#{title}.list]"
})
end
}
it {
should contain_exec("apt_update").with({
"command" => "/usr/bin/apt-get update",
"refreshonly" => true
})
}
it {
if param_hash[:required_packages]
should contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
"command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
"subscribe" => "File[#{title}.list]",
"refreshonly" => true,
"before" => 'Exec[apt_update]',
})
else
should_not contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
"command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
"subscribe" => "File[#{title}.list]",
"refreshonly" => true
})
end
}
it {
if param_hash[:key]
should contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
"key" => param_hash[:key],
"ensure" => :present,
"key_server" => param_hash[:key_server],
"key_content" => param_hash[:key_content],
"key_source" => param_hash[:key_source],
"before" => "File[#{title}.list]"
})
else
should_not contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
"key" => param_hash[:key],
"ensure" => :present,
"key_server" => param_hash[:key_server],
"key_content" => param_hash[:key_content],
"key_source" => param_hash[:key_source],
"before" => "File[#{title}.list]"
})
end
}
end
end
describe "without release should raise a Puppet::Error" do
let(:default_params) { Hash.new }
let(:facts) { Hash.new }
it { expect { should raise_error(Puppet::Error) } }
let(:facts) { { :lsbdistcodename => 'lucid' } }
it { should contain_apt__source(title) }
end
end

View File

@ -0,0 +1 @@
require 'puppetlabs_spec_helper/module_spec_helper'

View File

@ -0,0 +1,30 @@
require 'rspec-system/spec_helper'
require 'rspec-system-puppet/helpers'
require 'rspec-system-serverspec/helpers'
include RSpecSystemPuppet::Helpers
include Serverspec::Helper::RSpecSystem
include Serverspec::Helper::DetectOS
RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
# Enable colour
c.tty = true
c.include RSpecSystemPuppet::Helpers
# This is where we 'setup' the nodes before running our tests
c.before :suite do
# May as well update here as this can only run on apt-get machines.
shell('apt-get update')
# Install puppet
puppet_install
# Install modules and dependencies
puppet_module_install(:source => proj_root, :module_name => 'apt')
shell('puppet module install puppetlabs-stdlib')
end
end

View File

@ -0,0 +1,38 @@
require 'spec_helper_system'
describe 'apt::builddep' do
context 'reset' do
it 'removes packages' do
shell('apt-get -y remove glusterfs-server')
shell('apt-get -y remove g++')
end
end
context 'apt::builddep' do
it 'should work with no errors' do
pp = <<-EOS
include '::apt'
apt::builddep { 'glusterfs-server': }
EOS
puppet_apply(pp) do |r|
r.exit_code.should_not == 1
end
end
describe 'should install g++ as a dependency' do
describe package('g++') do
it { should be_installed }
end
end
end
context 'reset' do
it 'removes packages' do
shell('apt-get -y remove glusterfs-server')
shell('apt-get -y remove g++')
end
end
end

View File

@ -0,0 +1,53 @@
require 'spec_helper_system'
describe 'apt::key' do
context 'reset' do
it 'clean up keys' do
shell('apt-key del 4BD6EC30')
shell('apt-key del D50582E6')
end
end
context 'apt::key' do
it 'should work with no errors' do
pp = <<-EOS
include '::apt'
apt::key { 'puppetlabs':
key => '4BD6EC30',
key_server => 'pgp.mit.edu',
}
apt::key { 'jenkins':
key => 'D50582E6',
key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key',
}
EOS
puppet_apply(pp) do |r|
r.exit_code.should_not == 1
end
end
describe 'keys should exist' do
it 'finds puppetlabs key' do
shell('apt-key list | grep 4BD6EC30') do |r|
r.exit_code.should be_zero
end
end
it 'finds jenkins key' do
shell('apt-key list | grep D50582E6') do |r|
r.exit_code.should be_zero
end
end
end
end
context 'reset' do
it 'clean up keys' do
shell('apt-key del 4BD6EC30')
shell('apt-key del D50582E6')
end
end
end

View File

@ -0,0 +1,59 @@
require 'spec_helper_system'
describe 'apt::ppa' do
context 'reset' do
it 'removes ppa' do
shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*')
shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
end
end
context 'adding a ppa that doesnt exist' do
it 'should work with no errors' do
pp = <<-EOS
include '::apt'
apt::ppa { 'ppa:drizzle-developers/ppa': }
EOS
puppet_apply(pp) do |r|
r.exit_code.should_not == 1
end
end
describe 'contains the source file' do
it 'contains a drizzle ppa source' do
shell('ls /etc/apt/sources.list.d/drizzle-developers-ppa-*.list') do |r|
r.exit_code.should be_zero
end
end
end
end
context 'readding a removed ppa.' do
it 'setup' do
shell('add-apt-repository -y ppa:raravena80/collectd5')
# This leaves a blank file
shell('add-apt-repository --remove ppa:raravena80/collectd5')
end
it 'should readd it successfully' do
pp = <<-EOS
include '::apt'
apt::ppa { 'ppa:raravena80/collectd5': }
EOS
puppet_apply(pp) do |r|
r.exit_code.should_not == 1
end
end
end
context 'reset' do
it 'removes added ppas' do
shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*')
shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
end
end
end

View File

@ -0,0 +1,51 @@
require 'spec_helper_system'
describe 'apt::source' do
context 'reset' do
it 'clean up puppetlabs repo' do
shell('apt-key del 4BD6EC30')
shell('rm /etc/apt/sources.list.d/puppetlabs.list')
end
end
context 'apt::source' do
it 'should work with no errors' do
pp = <<-EOS
include '::apt'
apt::source { 'puppetlabs':
location => 'http://apt.puppetlabs.com',
repos => 'main',
key => '4BD6EC30',
key_server => 'pgp.mit.edu',
}
EOS
puppet_apply(pp) do |r|
r.exit_code.should_not == 1
end
end
describe 'key should exist' do
it 'finds puppetlabs key' do
shell('apt-key list | grep 4BD6EC30') do |r|
r.exit_code.should be_zero
end
end
end
describe 'source should exist' do
describe file('/etc/apt/sources.list.d/puppetlabs.list') do
it { should be_file }
end
end
end
context 'reset' do
it 'clean up puppetlabs repo' do
shell('apt-key del 4BD6EC30')
shell('rm /etc/apt/sources.list.d/puppetlabs.list')
end
end
end

View File

@ -0,0 +1,10 @@
require 'spec_helper_system'
describe 'basic tests:' do
# Using puppet_apply as a subject
context puppet_apply 'notice("foo")' do
its(:stdout) { should =~ /foo/ }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
end
end

View File

@ -0,0 +1,20 @@
require 'spec_helper_system'
describe 'apt class' do
context 'default parameters' do
# Using puppet_apply as a helper
it 'should work with no errors' do
pp = <<-EOS
class { 'apt': }
EOS
# Run it twice and test for idempotency
puppet_apply(pp) do |r|
r.exit_code.should_not == 1
r.refresh
r.exit_code.should be_zero
end
end
end
end

View File

@ -0,0 +1,12 @@
APT::Periodic::Enable "<%= @enable %>";
APT::Periodic::BackUpArchiveInterval "<%= @backup_interval %>";
APT::Periodic::BackUpLevel "<%= @backup_level %>";
APT::Periodic::MaxAge "<%= @max_age %>";
APT::Periodic::MinAge "<%= @min_age %>";
APT::Periodic::MaxSize "<%= @max_size %>";
APT::Periodic::Update-Package-Lists "<%= @update %>";
APT::Periodic::Download-Upgradeable-Packages "<%= @download %>";
APT::Periodic::Download-Upgradeable-Packages-Debdelta "<%= @download_delta %>";
APT::Periodic::Unattended-Upgrade "<%= @upgrade %>";
APT::Periodic::AutocleanInterval "<%= @autoclean %>";
APT::Periodic::Verbose "<%= @verbose %>";

View File

@ -0,0 +1,53 @@
// Automatically upgrade packages from these (origin:archive) pairs
Unattended-Upgrade::Allowed-Origins {
<% @origins.each do |origin| -%>
"<%= origin %>";
<% end -%>
};
// List of packages to not update
Unattended-Upgrade::Package-Blacklist {
<% @blacklist.each do |package| -%>
"<%= package %>";
<% end -%>
};
// This option allows you to control if on a unclean dpkg exit
// unattended-upgrades will automatically run
// dpkg --force-confold --configure -a
// The default is true, to ensure updates keep getting installed
Unattended-Upgrade::AutoFixInterruptedDpkg "<%= @auto_fix %>";
// Split the upgrade into the smallest possible chunks so that
// they can be interrupted with SIGUSR1. This makes the upgrade
// a bit slower but it has the benefit that shutdown while a upgrade
// is running is possible (with a small delay)
Unattended-Upgrade::MinimalSteps "<%= @minimal_steps %>";
// Install all unattended-upgrades when the machine is shuting down
// instead of doing it in the background while the machine is running
// This will (obviously) make shutdown slower
Unattended-Upgrade::InstallOnShutdown "<%= @install_on_shutdown %>";
// Send email to this address for problems or packages upgrades
// If empty or unset then no email is sent, make sure that you
// have a working mail setup on your system. A package that provides
// 'mailx' must be installed.
<% if @mail_to != "NONE" %>Unattended-Upgrade::Mail "<%= @mail_to %>";<% end %>
// Set this value to "true" to get emails only on errors. Default
// is to always send a mail if Unattended-Upgrade::Mail is set
<% if @mail_to != "NONE" %>Unattended-Upgrade::MailOnlyOnError "<%= @mail_only_on_error %>";<% end %>
// Do automatic removal of new unused dependencies after the upgrade
// (equivalent to apt-get autoremove)
Unattended-Upgrade::Remove-Unused-Dependencies "<%= @remove_unused %>";
// Automatically reboot *WITHOUT CONFIRMATION* if a
// the file /var/run/reboot-required is found after the upgrade
Unattended-Upgrade::Automatic-Reboot "<%= @auto_reboot %>";
// Use apt bandwidth limit feature, this example limits the download
// speed to 70kb/sec
<% if @dl_limit != "NONE" %>Acquire::http::Dl-Limit "<%= @dl_limit %>";<% end %>

View File

@ -0,0 +1,22 @@
<%-
@pin = "release a=#{@name}" # default value
if @pin_release.length > 0
options = []
options.push("a=#{@release}") if @release.length > 0
options.push("n=#{@codename}") if @codename.length > 0
options.push("v=#{@release_version}") if @release_version.length > 0
options.push("c=#{@component}") if @component.length > 0
options.push("o=#{@originator}") if @originator.length > 0
options.push("l=#{@label}") if @label.length > 0
@pin = "release #{options.join(', ')}"
elsif @version.length > 0
@pin = "version #{@version}"
elsif @origin.length > 0
@pin = "origin \"#{@origin}\""
end
-%>
# <%= @name %>
Explanation: <%= @explanation %>
Package: <%= @packages %>
Pin: <%= @pin %>
Pin-Priority: <%= @priority %>

View File

@ -0,0 +1,5 @@
# <%= @name %>
deb <% if @architecture %>[arch=<%= @architecture %>]<% end %><%= @location %> <%= @release_real %> <%= @repos %>
<%- if @include_src then -%>
deb-src <% if @architecture %>[arch=<%= @architecture %>]<% end %><%= @location %> <%= @release_real %> <%= @repos %>
<%- end -%>

View File

@ -0,0 +1,2 @@
class { 'apt': }
apt::builddep{ 'glusterfs-server': }

View File

@ -0,0 +1,2 @@
class { 'apt': }
class { 'apt::debian::testing': }

View File

@ -0,0 +1,2 @@
class { 'apt': }
class { 'apt::debian::unstable': }

View File

@ -0,0 +1,7 @@
# force.pp
# force a package from a specific release
apt::force { 'package':
release => 'testing',
version => false
}

1
puppet/apt/tests/init.pp Normal file
View File

@ -0,0 +1 @@
class { 'apt': }

6
puppet/apt/tests/key.pp Normal file
View File

@ -0,0 +1,6 @@
# Declare Apt key for apt.puppetlabs.com source
apt::key { 'puppetlabs':
key => '4BD6EC30',
key_server => 'pgp.mit.edu',
key_options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"',
}

View File

@ -0,0 +1 @@
include apt::params

5
puppet/apt/tests/pin.pp Normal file
View File

@ -0,0 +1,5 @@
# pin a release in apt, useful for unstable repositories
apt::pin { 'foo':
packages => '*',
priority => 0,
}

4
puppet/apt/tests/ppa.pp Normal file
View File

@ -0,0 +1,4 @@
class { 'apt': }
# Example declaration of an Apt PPA
apt::ppa{ 'ppa:openstack-ppa/bleeding-edge': }

View File

@ -0,0 +1,4 @@
class { 'apt': }
class { 'apt::release':
release_id => 'karmic'
}

View File

@ -0,0 +1,29 @@
# Declare the apt class to manage /etc/apt/sources.list and /etc/sources.list.d
class { 'apt': }
# Install the puppetlabs apt source
# Release is automatically obtained from lsbdistcodename fact if available.
apt::source { 'puppetlabs':
location => 'http://apt.puppetlabs.com',
repos => 'main',
key => '4BD6EC30',
key_server => 'pgp.mit.edu',
}
# test two sources with the same key
apt::source { 'debian_testing':
location => 'http://debian.mirror.iweb.ca/debian/',
release => 'testing',
repos => 'main contrib non-free',
key => '55BE302B',
key_server => 'subkeys.pgp.net',
pin => '-10',
}
apt::source { 'debian_unstable':
location => 'http://debian.mirror.iweb.ca/debian/',
release => 'unstable',
repos => 'main contrib non-free',
key => '55BE302B',
key_server => 'subkeys.pgp.net',
pin => '-10',
}

View File

@ -0,0 +1 @@
include apt::unattended-upgrades

View File

@ -1,674 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -1,8 +0,0 @@
name 'camptocamp-apt'
version '0.0.2'
source 'https://github.com/camptocamp/puppet-apt'
author 'DevOps Team / Camptocamp'
license 'GNU GPLv3'
summary 'Camptocamp Apt Module'
description 'APT Module for Puppet'
project_page 'https://github.com/camptocamp/puppet-apt'

View File

@ -1,98 +0,0 @@
# Apt module for Puppet
**Manages apt configuration under Debian or Ubuntu.**
This module is provided by [Camptocamp](http://www.camptocamp.com/)
## Classes
* apt
* apt::backports
* apt::clean
* apt::params
* apt::unattended-upgrade
* apt::unattended-upgrade::automatic
### apt::clean
Variables
* **$apt\_clean\_minutes**: cronjob minutes - default uses fqdn\_rand()
* **$apt\_clean\_hours** : cronjob hours - default to 0
* **$apt\_clean\_mday** : cronjob monthday - default uses fqdn\_rand()
## Definitions
* apt::conf
* apt::key
* apt::ppa
* apt::preferences
* apt::sources\_list
### apt::conf
apt::conf{'99unattended-upgrade':
ensure => present,
content => "APT::Periodic::Unattended-Upgrade \"1\";\n",
}
### apt::key
apt::key {"A37E4CF5":
source => "http://dev.camptocamp.com/packages/debian/pub.key",
}
apt::key {"997D3880":
keyserver => "keyserver.ubuntu.com",
}
### apt::ppa
apt::ppa {'chris-lea':
ensure => present,
key => 'C7917B12',
ppa => 'node.js'
}
### apt::preferences
apt::preferences {"${lsbdistcodename}-backports":
ensure => present,
package => '*',
pin => "release a=${lsbdistcodename}-backports",
priority => 400,
}
### apt::sources\_list
apt::sources_list {"camptocamp":
ensure => present,
content => 'deb http://dev.camptocamp.com/packages/ etch puppet',
}
## Contributing
Please report bugs and feature request using [GitHub issue
tracker](https://github.com/camptocamp/puppet-apt/issues).
For pull requests, it is very much appreciated to check your Puppet manifest
with [puppet-lint](https://github.com/camptocamp/puppet-apt/issues) to follow the recommended Puppet style guidelines from the
[Puppet Labs style guide](http://docs.puppetlabs.com/guides/style_guide.html).
## License
Copyright (c) 2012 <mailto:puppet@camptocamp.com> All rights reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

View File

@ -1,4 +0,0 @@
// Unattended-Upgrade::Mail "root";
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "1";

View File

@ -1,10 +0,0 @@
output = %x{apt-get -v 2>&1}
if $?.exitstatus and output.match(/apt (\d+\.\d+\.\d+).*/)
Facter.add("apt_version") do
setcode do
$1
end
end
end

View File

@ -1,23 +0,0 @@
class apt::backports ($priority = 400) {
$debian_mirror = 'http://backports.debian.org/debian-backports'
$ubuntu_mirror = 'http://archive.ubuntu.com/ubuntu'
$uri = $::operatingsystem ? {
Debian => "deb ${debian_mirror} ${::lsbdistcodename}-backports main contrib non-free\n",
Ubuntu => "deb ${ubuntu_mirror} ${::lsbdistcodename}-backports main universe multiverse restricted\n",
}
apt::sources_list{'backports':
ensure => present,
content => $uri,
}
apt::preferences {"${::lsbdistcodename}-backports":
ensure => present,
package => '*',
pin => "release a=${::lsbdistcodename}-backports",
priority => $priority,
}
}

View File

@ -1,23 +0,0 @@
# == Class: apt::clean
#
# Create a cronjob which will run "apt-get clean" once a month.
#
# === Variables
#
# *$apt_clean_minutes*: cronjob minutes - default uses fqdn_rand()
# *$apt_clean_hours*: cronjob hours - default to 0
# *$apt_clean_mday*: cronjob monthday - default uses fqdn_rand()
#
class apt::clean {
$minutes = $apt_clean_minutes? {'' => fqdn_rand(60), default => $apt_clean_minutes }
$hours = $apt_clean_hours? {'' => '0' , default => $apt_clean_hours }
$monthday = $apt_clean_mday? {'' => fqdn_rand(29), default => $apt_clean_mday }
cron {'cleanup APT cache - prevents diskfull':
ensure => present,
command => 'apt-get clean',
hour => $hours,
minute => $minutes,
monthday => $monthday,
}
}

View File

@ -1,23 +0,0 @@
define apt::conf($ensure, $content = false, $source = false) {
if $content {
file {"/etc/apt/apt.conf.d/${name}":
ensure => $ensure,
content => $content,
owner => "root",
group => "root",
before => Exec['apt-get_update'],
notify => Exec['apt-get_update'],
}
}
if $source {
file {"/etc/apt/apt.conf.d/${name}":
ensure => $ensure,
source => $source,
owner => "root",
group => "root",
before => Exec['apt-get_update'],
notify => Exec['apt-get_update'],
}
}
}

View File

@ -1,50 +0,0 @@
class apt {
include apt::params
Package {
require => Exec['apt-get_update']
}
# apt support preferences.d since version >= 0.7.22
if versioncmp($::apt_version, '0.7.22') >= 0 {
file {'/etc/apt/preferences':
ensure => absent,
}
file {'/etc/apt/preferences.d':
ensure => directory,
owner => root,
group => root,
mode => '0755',
recurse => $apt::params::manage_preferences,
purge => $apt::params::manage_preferences,
force => $apt::params::manage_preferences,
}
}
package {$apt::params::keyring_package:
ensure => present,
}
# ensure only files managed by puppet be present in this directory.
file {'/etc/apt/sources.list.d':
ensure => directory,
source => 'puppet:///modules/apt/empty/',
recurse => $apt::params::manage_sourceslist,
purge => $apt::params::manage_sourceslist,
force => $apt::params::manage_sourceslist,
ignore => $apt::params::ignore_sourceslist,
}
apt::conf {'10periodic':
ensure => present,
source => 'puppet:///modules/apt/10periodic',
}
exec {'apt-get_update':
command => 'apt-get update',
refreshonly => true,
}
}

View File

@ -1,43 +0,0 @@
define apt::key (
$keyserver = 'pgp.mit.edu',
$ensure = present,
$source = '',
$content = ''
) {
case $ensure {
present: {
if $content == '' {
if $source == '' {
$thekey = "gpg --keyserver ${keyserver} --recv-key '${name}' && gpg --export --armor '${name}'"
}
else {
$thekey = "wget -O - '${source}'"
}
}
else {
$thekey = "echo '${content}'"
}
exec { "import gpg key ${name}":
command => "${thekey} | apt-key add -",
unless => "apt-key list | grep -Fqe '${name}'",
before => Exec['apt-get_update'],
notify => Exec['apt-get_update'],
}
}
absent: {
exec {"apt-key del ${name}":
onlyif => "apt-key list | grep -Fqe '${name}'",
}
}
default: {
fail "Invalid 'ensure' value '${ensure}' for apt::key"
}
}
}

View File

@ -1,23 +0,0 @@
class apt::params {
$manage_preferences = $apt_manage_preferences ? {
'' => true,
default => $apt_manage_preferences,
}
$manage_sourceslist = $apt_manage_sourceslist ? {
'' => true,
default => $apt_manage_sourceslist,
}
$ignore_sourceslist = $apt_ignore_sourceslist ? {
'' => '.placeholder',
default => $apt_ignore_sourceslist,
}
$keyring_package = $::lsbdistid ? {
Debian => ['debian-keyring', 'debian-archive-keyring'],
Ubuntu => 'ubuntu-keyring',
}
}

View File

@ -1,23 +0,0 @@
define apt::ppa (
$key,
$ensure = present,
$ppa ='ppa'
) {
apt::key {$key:
ensure => $ensure,
}
$ppa_name = inline_template("<%=
if ppa.is_a?(Array)
ppa.join('-')
else
ppa
end %>")
apt::sources_list {"${name}-${ppa_name}-${lsbdistcodename}":
ensure => $ensure,
content => template('apt/ppa-list.erb'),
}
}

View File

@ -1,23 +0,0 @@
define apt::preferences($ensure="present", $package="", $pin, $priority) {
$pkg = $package ? {
"" => $name,
default => $package,
}
$fname = regsubst($name, '\.', '-', 'G')
# apt support preferences.d since version >= 0.7.22
if versioncmp($::apt_version, '0.7.22') >= 0 {
file {"/etc/apt/preferences.d/$fname":
ensure => $ensure,
owner => root,
group => root,
mode => 644,
content => template("apt/preferences.erb"),
before => Exec["apt-get_update"],
notify => Exec["apt-get_update"],
}
}
}

View File

@ -1,27 +0,0 @@
define apt::sources_list (
$ensure = present,
$source = false,
$content = false
) {
if $source {
file {"/etc/apt/sources.list.d/${name}.list":
ensure => $ensure,
source => $source,
owner => "root",
group => "root",
before => Exec['apt-get_update'],
notify => Exec['apt-get_update'],
}
} else {
file {"/etc/apt/sources.list.d/${name}.list":
ensure => $ensure,
content => $content,
owner => "root",
group => "root",
before => Exec['apt-get_update'],
notify => Exec['apt-get_update'],
}
}
}

View File

@ -1,5 +0,0 @@
class apt::unattended-upgrade {
package {'unattended-upgrades':
ensure => present,
}
}

View File

@ -1,18 +0,0 @@
class apt::unattended-upgrade::automatic inherits apt::unattended-upgrade {
apt::conf{'99unattended-upgrade':
ensure => present,
content => "APT::Periodic::Unattended-Upgrade \"1\";\n",
}
$dist = $::lsbdistid? {
Debian => $::lsbdistcodename,
default => $::lsbdistid,
}
apt::conf{'50unattended-upgrades':
ensure => present,
content => template("apt/unattended-upgrades.${dist}.erb"),
}
}

View File

@ -1,4 +0,0 @@
<% ppa.each do |one_ppa| %>
deb http://ppa.launchpad.net/<%= name %>/<%= one_ppa %>/ubuntu <%= lsbdistcodename %> main
deb-src http://ppa.launchpad.net/<%= name %>/<%= one_ppa %>/ubuntu <%= lsbdistcodename %> main
<% end %>

View File

@ -1,5 +0,0 @@
# file managed by puppet
Package: <%= pkg %>
Pin: <%= pin %>
Pin-Priority: <%= priority %>

View File

@ -1,8 +0,0 @@
Unattended-Upgrade::Allowed-Origins {
"Ubuntu <%= lsbdistcodename %>-security";
"Ubuntu <%= lsbdistcodename %>-updates";
"Ubuntu <%= lsbdistcodename %>";
"Canonical <%= lsbdistcodename %>";
};
Dpkg::Options { "--force-confold"; }

View File

@ -1,6 +0,0 @@
// file managed by puppet
Unattended-Upgrade::Allowed-Origins {
"Debian oldstable";
};
Dpkg::Options { "--force-confold"; }

View File

@ -1,7 +0,0 @@
// file managed by puppet
Unattended-Upgrade::Allowed-Origins {
"Debian stable";
"Debian squeeze-security";
};
Dpkg::Options { "--force-confold"; }

278
puppet/stdlib/CHANGELOG Normal file
View File

@ -0,0 +1,278 @@
2013-05-06 - Jeff McCune <jeff@puppetlabs.com> - 4.1.0
* (#20582) Restore facter_dot_d to stdlib for PE users (3b887c8)
* (maint) Update Gemfile with GEM_FACTER_VERSION (f44d535)
2013-05-06 - Alex Cline <acline@us.ibm.com> - 4.1.0
* Terser method of string to array conversion courtesy of ethooz. (d38bce0)
2013-05-06 - Alex Cline <acline@us.ibm.com> 4.1.0
* Refactor ensure_resource expectations (b33cc24)
2013-05-06 - Alex Cline <acline@us.ibm.com> 4.1.0
* Changed str-to-array conversion and removed abbreviation. (de253db)
2013-05-03 - Alex Cline <acline@us.ibm.com> 4.1.0
* (#20548) Allow an array of resource titles to be passed into the ensure_resource function (e08734a)
2013-05-02 - Raphaël Pinson <raphael.pinson@camptocamp.com> - 4.1.0
* Add a dirname function (2ba9e47)
2013-04-29 - Mark Smith-Guerrero <msmithgu@gmail.com> - 4.1.0
* (maint) Fix a small typo in hash() description (928036a)
2013-04-12 - Jeff McCune <jeff@puppetlabs.com> - 4.0.2
* Update user information in gemspec to make the intent of the Gem clear.
2013-04-11 - Jeff McCune <jeff@puppetlabs.com> - 4.0.1
* Fix README function documentation (ab3e30c)
2013-04-11 - Jeff McCune <jeff@puppetlabs.com> - 4.0.0
* stdlib 4.0 drops support with Puppet 2.7
* stdlib 4.0 preserves support with Puppet 3
2013-04-11 - Jeff McCune <jeff@puppetlabs.com> - 4.0.0
* Add ability to use puppet from git via bundler (9c5805f)
2013-04-10 - Jeff McCune <jeff@puppetlabs.com> - 4.0.0
* (maint) Make stdlib usable as a Ruby GEM (e81a45e)
2013-04-10 - Erik Dalén <dalen@spotify.com> - 4.0.0
* Add a count function (f28550e)
2013-03-31 - Amos Shapira <ashapira@atlassian.com> - 4.0.0
* (#19998) Implement any2array (7a2fb80)
2013-03-29 - Steve Huff <shuff@vecna.org> - 4.0.0
* (19864) num2bool match fix (8d217f0)
2013-03-20 - Erik Dalén <dalen@spotify.com> - 4.0.0
* Allow comparisons of Numeric and number as String (ff5dd5d)
2013-03-26 - Richard Soderberg <rsoderberg@mozilla.com> - 4.0.0
* add suffix function to accompany the prefix function (88a93ac)
2013-03-19 - Kristof Willaert <kristof.willaert@gmail.com> - 4.0.0
* Add floor function implementation and unit tests (0527341)
2012-04-03 - Eric Shamow <eric@puppetlabs.com> - 4.0.0
* (#13610) Add is_function_available to stdlib (961dcab)
2012-12-17 - Justin Lambert <jlambert@eml.cc> - 4.0.0
* str2bool should return a boolean if called with a boolean (5d5a4d4)
2012-10-23 - Uwe Stuehler <ustuehler@team.mobile.de> - 4.0.0
* Fix number of arguments check in flatten() (e80207b)
2013-03-11 - Jeff McCune <jeff@puppetlabs.com> - 4.0.0
* Add contributing document (96e19d0)
2013-03-04 - Raphaël Pinson <raphael.pinson@camptocamp.com> - 4.0.0
* Add missing documentation for validate_augeas and validate_cmd to README.markdown (a1510a1)
2013-02-14 - Joshua Hoblitt <jhoblitt@cpan.org> - 4.0.0
* (#19272) Add has_element() function (95cf3fe)
2013-02-07 - Raphaël Pinson <raphael.pinson@camptocamp.com> - 4.0.0
* validate_cmd(): Use Puppet::Util::Execution.execute when available (69248df)
2012-12-06 - Raphaël Pinson <raphink@gmail.com> - 4.0.0
* Add validate_augeas function (3a97c23)
2012-12-06 - Raphaël Pinson <raphink@gmail.com> - 4.0.0
* Add validate_cmd function (6902cc5)
2013-01-14 - David Schmitt <david@dasz.at> - 4.0.0
* Add geppetto project definition (b3fc0a3)
2013-01-02 - Jaka Hudoklin <jakahudoklin@gmail.com> - 4.0.0
* Add getparam function to get defined resource parameters (20e0e07)
2013-01-05 - Jeff McCune <jeff@puppetlabs.com> - 4.0.0
* (maint) Add Travis CI Support (d082046)
2012-12-04 - Jeff McCune <jeff@puppetlabs.com> - 4.0.0
* Clarify that stdlib 3 supports Puppet 3 (3a6085f)
2012-11-30 - Erik Dalén <dalen@spotify.com> - 4.0.0
* maint: style guideline fixes (7742e5f)
2012-11-09 - James Fryman <james@frymanet.com> - 4.0.0
* puppet-lint cleanup (88acc52)
2012-11-06 - Joe Julian <me@joejulian.name> - 4.0.0
* Add function, uriescape, to URI.escape strings. Redmine #17459 (fd52b8d)
2012-09-18 - Chad Metcalf <chad@wibidata.com> - 3.2.0
* Add an ensure_packages function. (8a8c09e)
2012-11-23 - Erik Dalén <dalen@spotify.com> - 3.2.0
* (#17797) min() and max() functions (9954133)
2012-05-23 - Peter Meier <peter.meier@immerda.ch> - 3.2.0
* (#14670) autorequire a file_line resource's path (dfcee63)
2012-11-19 - Joshua Harlan Lifton <lifton@puppetlabs.com> - 3.2.0
* Add join_keys_to_values function (ee0f2b3)
2012-11-17 - Joshua Harlan Lifton <lifton@puppetlabs.com> - 3.2.0
* Extend delete function for strings and hashes (7322e4d)
2012-08-03 - Gary Larizza <gary@puppetlabs.com> - 3.2.0
* Add the pick() function (ba6dd13)
2012-03-20 - Wil Cooley <wcooley@pdx.edu> - 3.2.0
* (#13974) Add predicate functions for interface facts (f819417)
2012-11-06 - Joe Julian <me@joejulian.name> - 3.2.0
* Add function, uriescape, to URI.escape strings. Redmine #17459 (70f4a0e)
2012-10-25 - Jeff McCune <jeff@puppetlabs.com> - 3.1.1
* (maint) Fix spec failures resulting from Facter API changes (97f836f)
2012-10-23 - Matthaus Owens <matthaus@puppetlabs.com> - 3.1.0
* Add PE facts to stdlib (cdf3b05)
2012-08-16 - Jeff McCune <jeff@puppetlabs.com> - 3.0.1
* Fix accidental removal of facts_dot_d.rb in 3.0.0 release
2012-08-16 - Jeff McCune <jeff@puppetlabs.com> - 3.0.0
* stdlib 3.0 drops support with Puppet 2.6
* stdlib 3.0 preserves support with Puppet 2.7
2012-08-07 - Dan Bode <dan@puppetlabs.com> - 3.0.0
* Add function ensure_resource and defined_with_params (ba789de)
2012-07-10 - Hailee Kenney <hailee@puppetlabs.com> - 3.0.0
* (#2157) Remove facter_dot_d for compatibility with external facts (f92574f)
2012-04-10 - Chris Price <chris@puppetlabs.com> - 3.0.0
* (#13693) moving logic from local spec_helper to puppetlabs_spec_helper (85f96df)
2012-10-25 - Jeff McCune <jeff@puppetlabs.com> - 2.5.1
* (maint) Fix spec failures resulting from Facter API changes (97f836f)
2012-10-23 - Matthaus Owens <matthaus@puppetlabs.com> - 2.5.0
* Add PE facts to stdlib (cdf3b05)
2012-08-15 - Dan Bode <dan@puppetlabs.com> - 2.5.0
* Explicitly load functions used by ensure_resource (9fc3063)
2012-08-13 - Dan Bode <dan@puppetlabs.com> - 2.5.0
* Add better docs about duplicate resource failures (97d327a)
2012-08-13 - Dan Bode <dan@puppetlabs.com> - 2.5.0
* Handle undef for parameter argument (4f8b133)
2012-08-07 - Dan Bode <dan@puppetlabs.com> - 2.5.0
* Add function ensure_resource and defined_with_params (a0cb8cd)
2012-08-20 - Jeff McCune <jeff@puppetlabs.com> - 2.5.0
* Disable tests that fail on 2.6.x due to #15912 (c81496e)
2012-08-20 - Jeff McCune <jeff@puppetlabs.com> - 2.5.0
* (Maint) Fix mis-use of rvalue functions as statements (4492913)
2012-08-20 - Jeff McCune <jeff@puppetlabs.com> - 2.5.0
* Add .rspec file to repo root (88789e8)
2012-06-07 - Chris Price <chris@puppetlabs.com> - 2.4.0
* Add support for a 'match' parameter to file_line (a06c0d8)
2012-08-07 - Erik Dalén <dalen@spotify.com> - 2.4.0
* (#15872) Add to_bytes function (247b69c)
2012-07-19 - Jeff McCune <jeff@puppetlabs.com> - 2.4.0
* (Maint) use PuppetlabsSpec::PuppetInternals.scope (master) (deafe88)
2012-07-10 - Hailee Kenney <hailee@puppetlabs.com> - 2.4.0
* (#2157) Make facts_dot_d compatible with external facts (5fb0ddc)
2012-03-16 - Steve Traylen <steve.traylen@cern.ch> - 2.4.0
* (#13205) Rotate array/string randomley based on fqdn, fqdn_rotate() (fef247b)
2012-05-22 - Peter Meier <peter.meier@immerda.ch> - 2.3.3
* fix regression in #11017 properly (f0a62c7)
2012-05-10 - Jeff McCune <jeff@puppetlabs.com> - 2.3.3
* Fix spec tests using the new spec_helper (7d34333)
2012-05-10 - Puppet Labs <support@puppetlabs.com> - 2.3.2
* Make file_line default to ensure => present (1373e70)
* Memoize file_line spec instance variables (20aacc5)
* Fix spec tests using the new spec_helper (1ebfa5d)
* (#13595) initialize_everything_for_tests couples modules Puppet ver (3222f35)
* (#13439) Fix MRI 1.9 issue with spec_helper (15c5fd1)
* (#13439) Fix test failures with Puppet 2.6.x (665610b)
* (#13439) refactor spec helper for compatibility with both puppet 2.7 and master (82194ca)
* (#13494) Specify the behavior of zero padded strings (61891bb)
2012-03-29 Puppet Labs <support@puppetlabs.com> - 2.1.3
* (#11607) Add Rakefile to enable spec testing
* (#12377) Avoid infinite loop when retrying require json
2012-03-13 Puppet Labs <support@puppetlabs.com> - 2.3.1
* (#13091) Fix LoadError bug with puppet apply and puppet_vardir fact
2012-03-12 Puppet Labs <support@puppetlabs.com> - 2.3.0
* Add a large number of new Puppet functions
* Backwards compatibility preserved with 2.2.x
2011-12-30 Puppet Labs <support@puppetlabs.com> - 2.2.1
* Documentation only release for the Forge
2011-12-30 Puppet Labs <support@puppetlabs.com> - 2.1.2
* Documentation only release for PE 2.0.x
2011-11-08 Puppet Labs <support@puppetlabs.com> - 2.2.0
* #10285 - Refactor json to use pson instead.
* Maint - Add watchr autotest script
* Maint - Make rspec tests work with Puppet 2.6.4
* #9859 - Add root_home fact and tests
2011-08-18 Puppet Labs <support@puppetlabs.com> - 2.1.1
* Change facts.d paths to match Facter 2.0 paths.
* /etc/facter/facts.d
* /etc/puppetlabs/facter/facts.d
2011-08-17 Puppet Labs <support@puppetlabs.com> - 2.1.0
* Add R.I. Pienaar's facts.d custom facter fact
* facts defined in /etc/facts.d and /etc/puppetlabs/facts.d are
automatically loaded now.
2011-08-04 Puppet Labs <support@puppetlabs.com> - 2.0.0
* Rename whole_line to file_line
* This is an API change and as such motivating a 2.0.0 release according to semver.org.
2011-08-04 Puppet Labs <support@puppetlabs.com> - 1.1.0
* Rename append_line to whole_line
* This is an API change and as such motivating a 1.1.0 release.
2011-08-04 Puppet Labs <support@puppetlabs.com> - 1.0.0
* Initial stable release
* Add validate_array and validate_string functions
* Make merge() function work with Ruby 1.8.5
* Add hash merging function
* Add has_key function
* Add loadyaml() function
* Add append_line native
2011-06-21 Jeff McCune <jeff@puppetlabs.com> - 0.1.7
* Add validate_hash() and getvar() functions
2011-06-15 Jeff McCune <jeff@puppetlabs.com> - 0.1.6
* Add anchor resource type to provide containment for composite classes
2011-06-03 Jeff McCune <jeff@puppetlabs.com> - 0.1.5
* Add validate_bool() function to stdlib
0.1.4 2011-05-26 Jeff McCune <jeff@puppetlabs.com>
* Move most stages after main
0.1.3 2011-05-25 Jeff McCune <jeff@puppetlabs.com>
* Add validate_re() function
0.1.2 2011-05-24 Jeff McCune <jeff@puppetlabs.com>
* Update to add annotated tag
0.1.1 2011-05-24 Jeff McCune <jeff@puppetlabs.com>
* Add stdlib::stages class with a standard set of stages

View File

@ -0,0 +1,65 @@
# How to contribute
Third-party patches are essential for keeping stdlib great. We simply can't
access the huge number of platforms and myriad configurations for running
stdlib. We want to keep it as easy as possible to contribute changes that
get things working in your environment. There are a few guidelines that we
need contributors to follow so that we can have a chance of keeping on
top of things.
## Getting Started
* Make sure you have a [Redmine account](http://projects.puppetlabs.com)
* Make sure you have a [GitHub account](https://github.com/signup/free)
* Submit a ticket for your issue, assuming one does not already exist.
* Clearly describe the issue including steps to reproduce when it is a bug.
* Make sure you fill in the earliest version that you know has the issue.
* Fork the repository on GitHub
## Making Changes
* Create a topic branch from where you want to base your work.
* This is usually the master branch.
* Only target release branches if you are certain your fix must be on that
branch.
* To quickly create a topic branch based on master; `git branch
fix/master/my_contribution master` then checkout the new branch with `git
checkout fix/master/my_contribution`. Please avoid working directly on the
`master` branch.
* Make commits of logical units.
* Check for unnecessary whitespace with `git diff --check` before committing.
* Make sure your commit messages are in the proper format.
````
(#99999) Make the example in CONTRIBUTING imperative and concrete
Without this patch applied the example commit message in the CONTRIBUTING
document is not a concrete example. This is a problem because the
contributor is left to imagine what the commit message should look like
based on a description rather than an example. This patch fixes the
problem by making the example concrete and imperative.
The first line is a real life imperative statement with a ticket number
from our issue tracker. The body describes the behavior without the patch,
why this is a problem, and how the patch fixes the problem when applied.
````
* Make sure you have added the necessary tests for your changes.
* Run _all_ the tests to assure nothing else was accidentally broken.
## Submitting Changes
* Sign the [Contributor License Agreement](http://links.puppetlabs.com/cla).
* Push your changes to a topic branch in your fork of the repository.
* Submit a pull request to the repository in the puppetlabs organization.
* Update your Redmine ticket to mark that you have submitted code and are ready for it to be reviewed.
* Include a link to the pull request in the ticket
# Additional Resources
* [More information on contributing](http://links.puppetlabs.com/contribute-to-puppet)
* [Bug tracker (Redmine)](http://projects.puppetlabs.com)
* [Contributor License Agreement](http://links.puppetlabs.com/cla)
* [General GitHub documentation](http://help.github.com/)
* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
* #puppet-dev IRC channel on freenode.org

42
puppet/stdlib/Gemfile Normal file
View File

@ -0,0 +1,42 @@
source "https://rubygems.org"
def location_for(place, fake_version = nil)
mdata = /^(git:[^#]*)#(.*)/.match(place)
if mdata
[fake_version, { :git => mdata[1], :branch => mdata[2], :require => false }].compact
elsif place =~ /^file:\/\/(.*)/
['>= 0', { :path => File.expand_path(mdata[1]), :require => false }]
else
[place, { :require => false }]
end
end
group :development do
gem 'watchr'
end
group :development, :test do
gem 'rake'
gem 'puppetmodule-stdlib', ">= 1.0.0", :path => File.expand_path("..", __FILE__)
gem 'rspec', "~> 2.11.0", :require => false
gem 'mocha', "~> 0.10.5", :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'rspec-puppet', :require => false
end
facterversion = ENV['GEM_FACTER_VERSION']
if facterversion
gem 'facter', *location_for(facterversion)
else
gem 'facter', :require => false
end
ENV['GEM_PUPPET_VERSION'] ||= ENV['PUPPET_GEM_VERSION']
puppetversion = ENV['GEM_PUPPET_VERSION']
if puppetversion
gem 'puppet', *location_for(puppetversion)
else
gem 'puppet', :require => false
end
# vim:ft=ruby

19
puppet/stdlib/LICENSE Normal file
View File

@ -0,0 +1,19 @@
Copyright (C) 2011 Puppet Labs Inc
and some parts:
Copyright (C) 2011 Krzysztof Wilczynski
Puppet Labs can be contacted at: info@puppetlabs.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

11
puppet/stdlib/Modulefile Normal file
View File

@ -0,0 +1,11 @@
name 'puppetlabs-stdlib'
version '4.1.0'
source 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
author 'puppetlabs'
license 'Apache 2.0'
summary 'Puppet Module Standard Library'
description 'Standard Library for Puppet Modules'
project_page 'https://github.com/puppetlabs/puppetlabs-stdlib'
## Add dependencies, if any:
# dependency 'username/name', '>= 1.2.0'

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
Puppet Specific Facts
=====================
Facter is meant to stand alone and apart from Puppet. However, Facter often
runs inside Puppet and all custom facts included in the stdlib module will
almost always be evaluated in the context of Puppet and Facter working
together.
Still, we don't want to write custom facts that blow up in the users face if
Puppet is not loaded in memory. This is often the case if the user runs
`facter` without also supplying the `--puppet` flag.
Ah! But Jeff, the custom fact won't be in the `$LOAD_PATH` unless the user
supplies `--facter`! You might say...
Not (always) true I say! If the user happens to have a CWD of
`<modulepath>/stdlib/lib` then the facts will automatically be evaluated and
blow up.
In any event, it's pretty easy to write a fact that has no value if Puppet is
not loaded. Simply do it like this:
Facter.add(:node_vardir) do
setcode do
# This will be nil if Puppet is not available.
Facter::Util::PuppetSettings.with_puppet do
Puppet[:vardir]
end
end
end
The `Facter::Util::PuppetSettings.with_puppet` method accepts a block and
yields to it only if the Puppet library is loaded. If the Puppet library is
not loaded, then the method silently returns `nil` which Facter interprets as
an undefined fact value. The net effect is that the fact won't be set.

View File

@ -0,0 +1,7 @@
NOTE
====
This project's specs depend on puppet core, and thus they require the
`puppetlabs_spec_helper` project. For more information please see the README
in that project, which can be found here: [puppetlabs spec
helper](https://github.com/puppetlabs/puppetlabs_spec_helper)

View File

@ -0,0 +1,24 @@
# Contributing to this module #
* Work in a topic branch
* Submit a github pull request
* Address any comments / feeback
* Merge into master using --no-ff
# Releasing this module #
* This module adheres to http://semver.org/
* Look for API breaking changes using git diff vX.Y.Z..master
* If no API breaking changes, the minor version may be bumped.
* If there are API breaking changes, the major version must be bumped.
* If there are only small minor changes, the patch version may be bumped.
* Update the CHANGELOG
* Update the Modulefile
* Commit these changes with a message along the lines of "Update CHANGELOG and
Modulefile for release"
* Create an annotated tag with git tag -a vX.Y.Z -m 'version X.Y.Z' (NOTE the
leading v as per semver.org)
* Push the tag with git push origin --tags
* Build a new package with puppet-module or the rake build task if it exists
* Publish the new package to the forge
* Bonus points for an announcement to puppet-users.

Some files were not shown because too many files have changed in this diff Show More