puppet: Remove vendored puppetlabs apt and stdlibs dependencies.

This commit works by vendoring the couple functions we still use from
puppetlabs stdlib (join and range), but removing the rest of the
puppetlabs codebase, and of course cleaning up our linter rules in the
process.

Fixes #7423.
This commit is contained in:
rht 2018-12-06 20:46:36 +00:00 committed by Tim Abbott
parent d2aa81858c
commit c9d54f7854
281 changed files with 105 additions and 12187 deletions

View File

@ -28,11 +28,7 @@ Files: docs/code-of-conduct.md
Copyright: 2017, Kandra Labs Inc.
License: CC-BY-SA-4.0
Files: puppet/apt/*
Copyright: 2011, Evolving Web Inc.
License: Expat
Files: puppet/stdlib/*
Files: puppet/zulip/lib/puppet/parser/functions/join.rb puppet/zulip/lib/puppet/parser/functions/range.rb
Copyright: 2011, Krzysztof Wilczynski
2011, Puppet Labs Inc
License: Apache-2.0

View File

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

View File

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

View File

@ -1,29 +0,0 @@
<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

@ -1,18 +0,0 @@
#!/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

@ -1,34 +0,0 @@
<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

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

View File

@ -1,19 +0,0 @@
---
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'

View File

@ -1,40 +0,0 @@
---
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

View File

@ -1,183 +0,0 @@
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

View File

@ -1,16 +0,0 @@
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

View File

@ -1,70 +0,0 @@
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

View File

@ -1,19 +0,0 @@
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.

View File

@ -1,14 +0,0 @@
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'

View File

@ -1,226 +0,0 @@
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>

View File

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

View File

@ -1,48 +0,0 @@
# 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

@ -1,16 +0,0 @@
# 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

@ -1,18 +0,0 @@
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

@ -1,21 +0,0 @@
# 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

@ -1,21 +0,0 @@
# 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

@ -1,24 +0,0 @@
# 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

@ -1,121 +0,0 @@
# 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

@ -1,90 +0,0 @@
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 | sed 's| ||g' | /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 | sed 's| ||g' | grep '${trimmedkey}'",
user => 'root',
group => 'root',
logoutput => 'on_failure',
}
}
default: {
fail "Invalid 'ensure' value '${ensure}' for aptkey"
}
}
}

View File

@ -1,33 +0,0 @@
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

@ -1,73 +0,0 @@
# 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

@ -1,63 +0,0 @@
# 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

@ -1,17 +0,0 @@
# 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

@ -1,85 +0,0 @@
# 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

@ -1,68 +0,0 @@
# 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

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

View File

@ -1,87 +0,0 @@
{
"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

@ -1,133 +0,0 @@
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

@ -1,71 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,13 +0,0 @@
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

@ -1,22 +0,0 @@
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

@ -1,204 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,57 +0,0 @@
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

@ -1,41 +0,0 @@
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

@ -1,123 +0,0 @@
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

@ -1,101 +0,0 @@
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

@ -1,143 +0,0 @@
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

@ -1,166 +0,0 @@
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

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

View File

@ -1,30 +0,0 @@
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

@ -1,38 +0,0 @@
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

@ -1,53 +0,0 @@
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

@ -1,59 +0,0 @@
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

@ -1,51 +0,0 @@
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

@ -1,10 +0,0 @@
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

@ -1,20 +0,0 @@
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

@ -1,12 +0,0 @@
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

@ -1,53 +0,0 @@
// 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

@ -1,22 +0,0 @@
<%-
@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

@ -1,5 +0,0 @@
# <%= @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

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +0,0 @@
# 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

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

View File

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

View File

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

View File

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

View File

@ -1,29 +0,0 @@
# 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

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

View File

@ -1,278 +0,0 @@
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

@ -1,65 +0,0 @@
# 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

View File

@ -1,42 +0,0 @@
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

View File

@ -1,19 +0,0 @@
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.

View File

@ -1,11 +0,0 @@
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

@ -1,35 +0,0 @@
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

@ -1,7 +0,0 @@
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

@ -1,24 +0,0 @@
# 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.

View File

@ -1,2 +0,0 @@
require 'rubygems'
require 'puppetlabs_spec_helper/rake_tasks'

View File

@ -1,202 +0,0 @@
# A Facter plugin that loads facts from /etc/facter/facts.d
# and /etc/puppetlabs/facter/facts.d.
#
# Facts can be in the form of JSON, YAML or Text files
# and any executable that returns key=value pairs.
#
# In the case of scripts you can also create a file that
# contains a cache TTL. For foo.sh store the ttl as just
# a number in foo.sh.ttl
#
# The cache is stored in /tmp/facts_cache.yaml as a mode
# 600 file and will have the end result of not calling your
# fact scripts more often than is needed
class Facter::Util::DotD
require 'yaml'
def initialize(dir="/etc/facts.d", cache_file="/tmp/facts_cache.yml")
@dir = dir
@cache_file = cache_file
@cache = nil
@types = {".txt" => :txt, ".json" => :json, ".yaml" => :yaml}
end
def entries
Dir.entries(@dir).reject{|f| f =~ /^\.|\.ttl$/}.sort.map {|f| File.join(@dir, f) }
rescue
[]
end
def fact_type(file)
extension = File.extname(file)
type = @types[extension] || :unknown
type = :script if type == :unknown && File.executable?(file)
return type
end
def txt_parser(file)
File.readlines(file).each do |line|
if line =~ /^(.+)=(.+)$/
var = $1; val = $2
Facter.add(var) do
setcode { val }
end
end
end
rescue Exception => e
Facter.warn("Failed to handle #{file} as text facts: #{e.class}: #{e}")
end
def json_parser(file)
begin
require 'json'
rescue LoadError
retry if require 'rubygems'
raise
end
JSON.load(File.read(file)).each_pair do |f, v|
Facter.add(f) do
setcode { v }
end
end
rescue Exception => e
Facter.warn("Failed to handle #{file} as json facts: #{e.class}: #{e}")
end
def yaml_parser(file)
require 'yaml'
YAML.load_file(file).each_pair do |f, v|
Facter.add(f) do
setcode { v }
end
end
rescue Exception => e
Facter.warn("Failed to handle #{file} as yaml facts: #{e.class}: #{e}")
end
def script_parser(file)
result = cache_lookup(file)
ttl = cache_time(file)
unless result
result = Facter::Util::Resolution.exec(file)
if ttl > 0
Facter.debug("Updating cache for #{file}")
cache_store(file, result)
cache_save!
end
else
Facter.debug("Using cached data for #{file}")
end
result.split("\n").each do |line|
if line =~ /^(.+)=(.+)$/
var = $1; val = $2
Facter.add(var) do
setcode { val }
end
end
end
rescue Exception => e
Facter.warn("Failed to handle #{file} as script facts: #{e.class}: #{e}")
Facter.debug(e.backtrace.join("\n\t"))
end
def cache_save!
cache = load_cache
File.open(@cache_file, "w", 0600) {|f| f.write(YAML.dump(cache)) }
rescue
end
def cache_store(file, data)
load_cache
@cache[file] = {:data => data, :stored => Time.now.to_i}
rescue
end
def cache_lookup(file)
cache = load_cache
return nil if cache.empty?
ttl = cache_time(file)
if cache[file]
now = Time.now.to_i
return cache[file][:data] if ttl == -1
return cache[file][:data] if (now - cache[file][:stored]) <= ttl
return nil
else
return nil
end
rescue
return nil
end
def cache_time(file)
meta = file + ".ttl"
return File.read(meta).chomp.to_i
rescue
return 0
end
def load_cache
unless @cache
if File.exist?(@cache_file)
@cache = YAML.load_file(@cache_file)
else
@cache = {}
end
end
return @cache
rescue
@cache = {}
return @cache
end
def create
entries.each do |fact|
type = fact_type(fact)
parser = "#{type}_parser"
if respond_to?("#{type}_parser")
Facter.debug("Parsing #{fact} using #{parser}")
send(parser, fact)
end
end
end
end
mdata = Facter.version.match(/(\d+)\.(\d+)\.(\d+)/)
if mdata
(major, minor, patch) = mdata.captures.map { |v| v.to_i }
if major < 2
# Facter 1.7 introduced external facts support directly
unless major == 1 and minor > 6
Facter::Util::DotD.new("/etc/facter/facts.d").create
Facter::Util::DotD.new("/etc/puppetlabs/facter/facts.d").create
# Windows has a different configuration directory that defaults to a vendor
# specific sub directory of the %COMMON_APPDATA% directory.
if Dir.const_defined? 'COMMON_APPDATA' then
windows_facts_dot_d = File.join(Dir::COMMON_APPDATA, 'PuppetLabs', 'facter', 'facts.d')
Facter::Util::DotD.new(windows_facts_dot_d).create
end
end
end
end

View File

@ -1,53 +0,0 @@
# Fact: is_pe, pe_version, pe_major_version, pe_minor_version, pe_patch_version
#
# Purpose: Return various facts about the PE state of the system
#
# Resolution: Uses a regex match against puppetversion to determine whether the
# machine has Puppet Enterprise installed, and what version (overall, major,
# minor, patch) is installed.
#
# Caveats:
#
Facter.add("pe_version") do
setcode do
pe_ver = Facter.value("puppetversion").match(/Puppet Enterprise (\d+\.\d+\.\d+)/)
pe_ver[1] if pe_ver
end
end
Facter.add("is_pe") do
setcode do
if Facter.value(:pe_version).to_s.empty? then
false
else
true
end
end
end
Facter.add("pe_major_version") do
confine :is_pe => true
setcode do
if pe_version = Facter.value(:pe_version)
pe_version.to_s.split('.')[0]
end
end
end
Facter.add("pe_minor_version") do
confine :is_pe => true
setcode do
if pe_version = Facter.value(:pe_version)
pe_version.to_s.split('.')[1]
end
end
end
Facter.add("pe_patch_version") do
confine :is_pe => true
setcode do
if pe_version = Facter.value(:pe_version)
pe_version.to_s.split('.')[2]
end
end
end

View File

@ -1,26 +0,0 @@
# This facter fact returns the value of the Puppet vardir setting for the node
# running puppet or puppet agent. The intent is to enable Puppet modules to
# automatically have insight into a place where they can place variable data,
# regardless of the node's platform.
#
# The value should be directly usable in a File resource path attribute.
begin
require 'facter/util/puppet_settings'
rescue LoadError => e
# puppet apply does not add module lib directories to the $LOAD_PATH (See
# #4248). It should (in the future) but for the time being we need to be
# defensive which is what this rescue block is doing.
rb_file = File.join(File.dirname(__FILE__), 'util', 'puppet_settings.rb')
load rb_file if File.exists?(rb_file) or raise e
end
Facter.add(:puppet_vardir) do
setcode do
# This will be nil if Puppet is not available.
Facter::Util::PuppetSettings.with_puppet do
Puppet[:vardir]
end
end
end

View File

@ -1,19 +0,0 @@
# A facter fact to determine the root home directory.
# This varies on PE supported platforms and may be
# reconfigured by the end user.
module Facter::Util::RootHome
class << self
def get_root_home
root_ent = Facter::Util::Resolution.exec("getent passwd root")
# The home directory is the sixth element in the passwd entry
# If the platform doesn't have getent, root_ent will be nil and we should
# return it straight away.
root_ent && root_ent.split(":")[5]
end
end
end
Facter.add(:root_home) do
setcode { Facter::Util::RootHome.get_root_home }
end

View File

@ -1,21 +0,0 @@
module Facter
module Util
module PuppetSettings
# This method is intended to provide a convenient way to evaluate a
# Facter code block only if Puppet is loaded. This is to account for the
# situation where the fact happens to be in the load path, but Puppet is
# not loaded for whatever reason. Perhaps the user is simply running
# facter without the --puppet flag and they happen to be working in a lib
# directory of a module.
def self.with_puppet
begin
Module.const_get("Puppet")
rescue NameError
nil
else
yield
end
end
end
end
end

View File

@ -1,36 +0,0 @@
#
# abs.rb
#
module Puppet::Parser::Functions
newfunction(:abs, :type => :rvalue, :doc => <<-EOS
Returns the absolute value of a number, for example -34.56 becomes
34.56. Takes a single integer and float value as an argument.
EOS
) do |arguments|
raise(Puppet::ParseError, "abs(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size < 1
value = arguments[0]
# Numbers in Puppet are often string-encoded which is troublesome ...
if value.is_a?(String)
if value.match(/^-?(?:\d+)(?:\.\d+){1}$/)
value = value.to_f
elsif value.match(/^-?\d+$/)
value = value.to_i
else
raise(Puppet::ParseError, 'abs(): Requires float or ' +
'integer to work with')
end
end
# We have numeric value to handle ...
result = value.abs
return result
end
end
# vim: set ts=2 sw=2 et :

View File

@ -1,33 +0,0 @@
#
# any2array.rb
#
module Puppet::Parser::Functions
newfunction(:any2array, :type => :rvalue, :doc => <<-EOS
This converts any object to an array containing that object. Empty argument
lists are converted to an empty array. Arrays are left untouched. Hashes are
converted to arrays of alternating keys and values.
EOS
) do |arguments|
if arguments.empty?
return []
end
if arguments.length == 1
if arguments[0].kind_of?(Array)
return arguments[0]
elsif arguments[0].kind_of?(Hash)
result = []
arguments[0].each do |key, value|
result << key << value
end
return result
end
end
return arguments
end
end
# vim: set ts=2 sw=2 et :

View File

@ -1,49 +0,0 @@
#
# bool2num.rb
#
module Puppet::Parser::Functions
newfunction(:bool2num, :type => :rvalue, :doc => <<-EOS
Converts a boolean to a number. Converts the values:
false, f, 0, n, and no to 0
true, t, 1, y, and yes to 1
Requires a single boolean or string as an input.
EOS
) do |arguments|
raise(Puppet::ParseError, "bool2num(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size < 1
value = arguments[0]
klass = value.class
# We can have either true or false, or string which resembles boolean ...
unless [FalseClass, TrueClass, String].include?(klass)
raise(Puppet::ParseError, 'bool2num(): Requires either ' +
'boolean or string to work with')
end
if value.is_a?(String)
# We consider all the yes, no, y, n and so on too ...
value = case value
#
# This is how undef looks like in Puppet ...
# We yield 0 (or false if you wish) in this case.
#
when /^$/, '' then false # Empty string will be false ...
when /^(1|t|y|true|yes)$/ then true
when /^(0|f|n|false|no)$/ then false
when /^(undef|undefined)$/ then false # This is not likely to happen ...
else
raise(Puppet::ParseError, 'bool2num(): Unknown type of boolean given')
end
end
# We have real boolean values as well ...
result = value ? 1 : 0
return result
end
end
# vim: set ts=2 sw=2 et :

View File

@ -1,34 +0,0 @@
#
# capitalize.rb
#
module Puppet::Parser::Functions
newfunction(:capitalize, :type => :rvalue, :doc => <<-EOS
Capitalizes the first letter of a string or array of strings.
Requires either a single string or an array as an input.
EOS
) do |arguments|
raise(Puppet::ParseError, "capitalize(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size < 1
value = arguments[0]
klass = value.class
unless [Array, String].include?(klass)
raise(Puppet::ParseError, 'capitalize(): Requires either ' +
'array or string to work with')
end
if value.is_a?(Array)
# Numbers in Puppet are often string-encoded which is troublesome ...
result = value.collect { |i| i.is_a?(String) ? i.capitalize : i }
else
result = value.capitalize
end
return result
end
end
# vim: set ts=2 sw=2 et :

View File

@ -1,35 +0,0 @@
#
# chomp.rb
#
module Puppet::Parser::Functions
newfunction(:chomp, :type => :rvalue, :doc => <<-'EOS'
Removes the record separator from the end of a string or an array of
strings, for example `hello\n` becomes `hello`.
Requires a single string or array as an input.
EOS
) do |arguments|
raise(Puppet::ParseError, "chomp(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size < 1
value = arguments[0]
klass = value.class
unless [Array, String].include?(klass)
raise(Puppet::ParseError, 'chomp(): Requires either ' +
'array or string to work with')
end
if value.is_a?(Array)
# Numbers in Puppet are often string-encoded which is troublesome ...
result = value.collect { |i| i.is_a?(String) ? i.chomp : i }
else
result = value.chomp
end
return result
end
end
# vim: set ts=2 sw=2 et :

View File

@ -1,37 +0,0 @@
#
# chop.rb
#
module Puppet::Parser::Functions
newfunction(:chop, :type => :rvalue, :doc => <<-'EOS'
Returns a new string with the last character removed. If the string ends
with `\r\n`, both characters are removed. Applying chop to an empty
string returns an empty string. If you wish to merely remove record
separators then you should use the `chomp` function.
Requires a string or array of strings as input.
EOS
) do |arguments|
raise(Puppet::ParseError, "chop(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size < 1
value = arguments[0]
klass = value.class
unless [Array, String].include?(klass)
raise(Puppet::ParseError, 'chop(): Requires either an ' +
'array or string to work with')
end
if value.is_a?(Array)
# Numbers in Puppet are often string-encoded which is troublesome ...
result = value.collect { |i| i.is_a?(String) ? i.chop : i }
else
result = value.chop
end
return result
end
end
# vim: set ts=2 sw=2 et :

View File

@ -1,37 +0,0 @@
#
# concat.rb
#
module Puppet::Parser::Functions
newfunction(:concat, :type => :rvalue, :doc => <<-EOS
Appends the contents of array 2 onto array 1.
*Example:*
concat(['1','2','3'],['4','5','6'])
Would result in:
['1','2','3','4','5','6']
EOS
) do |arguments|
# Check that 2 arguments have been given ...
raise(Puppet::ParseError, "concat(): Wrong number of arguments " +
"given (#{arguments.size} for 2)") if arguments.size != 2
a = arguments[0]
b = arguments[1]
# Check that both args are arrays.
unless a.is_a?(Array) and b.is_a?(Array)
raise(Puppet::ParseError, 'concat(): Requires array to work with')
end
result = a.concat(b)
return result
end
end
# vim: set ts=2 sw=2 et :

View File

@ -1,22 +0,0 @@
module Puppet::Parser::Functions
newfunction(:count, :type => :rvalue, :arity => -2, :doc => <<-EOS
Takes an array as first argument and an optional second argument.
Count the number of elements in array that matches second argument.
If called with only an array it counts the number of elements that are not nil/undef.
EOS
) do |args|
if (args.size > 2) then
raise(ArgumentError, "count(): Wrong number of arguments "+
"given #{args.size} for 1 or 2.")
end
collection, item = args
if item then
collection.count item
else
collection.count { |obj| obj != nil && obj != :undef && obj != '' }
end
end
end

View File

@ -1,35 +0,0 @@
# Test whether a given class or definition is defined
require 'puppet/parser/functions'
Puppet::Parser::Functions.newfunction(:defined_with_params,
:type => :rvalue,
:doc => <<-'ENDOFDOC'
Takes a resource reference and an optional hash of attributes.
Returns true if a resource with the specified attributes has already been added
to the catalog, and false otherwise.
user { 'dan':
ensure => present,
}
if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
user { 'dan': ensure => present, }
}
ENDOFDOC
) do |vals|
reference, params = vals
raise(ArgumentError, 'Must specify a reference') unless reference
if (! params) || params == ''
params = {}
end
ret = false
if resource = findresource(reference.to_s)
matches = params.collect do |key, value|
resource[key] == value
end
ret = params.empty? || !matches.include?(false)
end
Puppet.debug("Resource #{reference} was not determined to be defined")
ret
end

View File

@ -1,46 +0,0 @@
#
# delete.rb
#
# TODO(Krzysztof Wilczynski): We need to add support for regular expression ...
module Puppet::Parser::Functions
newfunction(:delete, :type => :rvalue, :doc => <<-EOS
Deletes all instances of a given element from an array, substring from a
string, or key from a hash.
*Examples:*
delete(['a','b','c','b'], 'b')
Would return: ['a','c']
delete({'a'=>1,'b'=>2,'c'=>3}, 'b')
Would return: {'a'=>1,'c'=>3}
delete('abracadabra', 'bra')
Would return: 'acada'
EOS
) do |arguments|
if (arguments.size != 2) then
raise(Puppet::ParseError, "delete(): Wrong number of arguments "+
"given #{arguments.size} for 2.")
end
collection = arguments[0]
item = arguments[1]
case collection
when Array, Hash
collection.delete item
when String
collection.gsub! item, ''
else
raise(TypeError, "delete(): First argument must be an Array, " +
"String, or Hash. Given an argument of class #{collection.class}.")
end
collection
end
end
# vim: set ts=2 sw=2 et :

View File

@ -1,49 +0,0 @@
#
# delete_at.rb
#
module Puppet::Parser::Functions
newfunction(:delete_at, :type => :rvalue, :doc => <<-EOS
Deletes a determined indexed value from an array.
*Examples:*
delete_at(['a','b','c'], 1)
Would return: ['a','c']
EOS
) do |arguments|
raise(Puppet::ParseError, "delete_at(): Wrong number of arguments " +
"given (#{arguments.size} for 2)") if arguments.size < 2
array = arguments[0]
unless array.is_a?(Array)
raise(Puppet::ParseError, 'delete_at(): Requires array to work with')
end
index = arguments[1]
if index.is_a?(String) and not index.match(/^\d+$/)
raise(Puppet::ParseError, 'delete_at(): You must provide ' +
'non-negative numeric index')
end
result = array.clone
# Numbers in Puppet are often string-encoded which is troublesome ...
index = index.to_i
if index > result.size - 1 # First element is at index 0 is it not?
raise(Puppet::ParseError, 'delete_at(): Given index ' +
'exceeds size of array given')
end
result.delete_at(index) # We ignore the element that got deleted ...
return result
end
end
# vim: set ts=2 sw=2 et :

View File

@ -1,15 +0,0 @@
module Puppet::Parser::Functions
newfunction(:dirname, :type => :rvalue, :doc => <<-EOS
Returns the dirname of a path.
EOS
) do |arguments|
raise(Puppet::ParseError, "dirname(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size < 1
path = arguments[0]
return File.dirname(path)
end
end
# vim: set ts=2 sw=2 et :

View File

@ -1,33 +0,0 @@
#
# downcase.rb
#
module Puppet::Parser::Functions
newfunction(:downcase, :type => :rvalue, :doc => <<-EOS
Converts the case of a string or all strings in an array to lower case.
EOS
) do |arguments|
raise(Puppet::ParseError, "downcase(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size < 1
value = arguments[0]
klass = value.class
unless [Array, String].include?(klass)
raise(Puppet::ParseError, 'downcase(): Requires either ' +
'array or string to work with')
end
if value.is_a?(Array)
# Numbers in Puppet are often string-encoded which is troublesome ...
result = value.collect { |i| i.is_a?(String) ? i.downcase : i }
else
result = value.downcase
end
return result
end
end
# vim: set ts=2 sw=2 et :

View File

@ -1,28 +0,0 @@
#
# empty.rb
#
module Puppet::Parser::Functions
newfunction(:empty, :type => :rvalue, :doc => <<-EOS
Returns true if the variable is empty.
EOS
) do |arguments|
raise(Puppet::ParseError, "empty(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size < 1
value = arguments[0]
klass = value.class
unless [Array, Hash, String].include?(klass)
raise(Puppet::ParseError, 'empty(): Requires either ' +
'array, hash or string to work with')
end
result = value.empty?
return result
end
end
# vim: set ts=2 sw=2 et :

View File

@ -1,24 +0,0 @@
#
# ensure_packages.rb
#
require 'puppet/parser/functions'
module Puppet::Parser::Functions
newfunction(:ensure_packages, :type => :statement, :doc => <<-EOS
Takes a list of packages and only installs them if they don't already exist.
EOS
) do |arguments|
raise(Puppet::ParseError, "ensure_packages(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size != 1
raise(Puppet::ParseError, "ensure_packages(): Requires array " +
"given (#{arguments[0].class})") if !arguments[0].kind_of?(Array)
Puppet::Parser::Functions.function(:ensure_resource)
arguments[0].each { |package_name|
function_ensure_resource(['package', package_name, {'ensure' => 'present' } ])
}
end
end
# vim: set ts=2 sw=2 et :

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