Skip to content

Commit

Permalink
apt: improvements
Browse files Browse the repository at this point in the history
* added modulefile/license files
* removed puppet-common dependencies
* use fqdn_rand() built-in instead of ip_to_cron()
* apt support preferences.d since version >= 0.7.22
  • Loading branch information
mbornoz committed Jun 28, 2012
1 parent 630fd57 commit 392328c
Show file tree
Hide file tree
Showing 6 changed files with 784 additions and 21 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Modulefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name 'camptocamp-apt'
version '0.0.2'
source 'https://github.com/camptocamp/puppet-apt'
author 'DevOps Team / Camptocamp'
license 'GNU GPLv3'
summary 'Camptocamp Apt Module'
description 'APT Module for Puppet'
project_page 'https://github.com/camptocamp/puppet-apt'
85 changes: 85 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Apt module for Puppet

Manages apt configuration under Debian or Ubuntu.

This module is provided by [Camptocamp_](http://www.camptocamp.com/)

## Classes

* apt
* apt::backports
* apt::clean
* apt::params
* apt::unattended-upgrade
* apt::unattended-upgrade::automatic

### apt::clean

Variables

* **$apt\_clean\_minutes**: cronjob minutes - default uses fqdn\_rand()
* **$apt\_clean\_hours** : cronjob hours - default to 0
* **$apt\_clean\_mday** : cronjob monthday - default uses fqdn\_rand()

## Definitions

* apt::conf
* apt::key
* apt::preferences
* apt::sources\_list

### apt::conf

apt::conf{'99unattended-upgrade':
ensure => present,
content => "APT::Periodic::Unattended-Upgrade \"1\";\n",
}

### apt::key

apt::key {"A37E4CF5":
source => "http://dev.camptocamp.com/packages/debian/pub.key",
}

### apt::preferences

apt::preferences {"${lsbdistcodename}-backports":
ensure => present,
package => '*',
pin => "release a=${lsbdistcodename}-backports",
priority => 400,
}

### apt::sources\_list

apt::sources_list {"camptocamp":
ensure => present,
content => 'deb http://dev.camptocamp.com/packages/ etch puppet',
}

## Contributing

Please report bugs and feature request using [GitHub issue
tracker](https://github.com/camptocamp/puppet-apt/issues).

For pull requests, it is very much appreciated to check your Puppet manifest
with [puppet-lint](https://github.com/camptocamp/puppet-apt/issues) to respect the recommended Puppet style guidelines from the
[Puppet Labs style guide](http://docs.puppetlabs.com/guides/style_guide.html).

## License

Copyright (c) 2012 <mailto:[email protected]> All rights reserved.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

10 changes: 10 additions & 0 deletions lib/facter/apt_version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
output = %x{apt-get -v 2>&1}

if $?.exitstatus and output.match(/apt (\d+\.\d+\.\d+).*/)

Facter.add("apt_version") do
setcode do
$1
end
end
end
13 changes: 5 additions & 8 deletions manifests/clean.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@
create a cronjob which will run "apt-get clean" once a month.
Arguments:
*$apt_clean_minutes*: cronjob minutes - default uses ip_to_cron from module "common"
*$apt_clean_hours*: cronjob hours - default to 0
*$apt_clean_mday*: cronjob monthday - default uses ip_to_cron from module "common"
Require:
- module common (http://github.com/camptocamp/puppet-common)
*$apt_clean_minutes*: cronjob minutes - default uses fqdn_rand()
*$apt_clean_hours*: cronjob hours - default to 0
*$apt_clean_mday*: cronjob monthday - default uses fqdn_rand()
*/
class apt::clean {
$minutes = $apt_clean_minutes? {'' => ip_to_cron(1, 59), default => $apt_clean_minutes }
$minutes = $apt_clean_minutes? {'' => fqdn_rand(60), default => $apt_clean_minutes }
$hours = $apt_clean_hours? {'' => "0", default => $apt_clean_hours }
$monthday = $apt_clean_mday? {'' => ip_to_cron(1, 28), default => $apt_clean_mday }
$monthday = $apt_clean_mday? {'' => fqdn_rand(29), default => $apt_clean_mday }

cron {"cleanup APT cache - prevents diskfull":
ensure => present,
Expand Down
15 changes: 2 additions & 13 deletions manifests/preferences.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
$fname = regsubst($name, '\.', '-', 'G')

# apt support preferences.d since version >= 0.7.22
if ($lsbdistid == "Debian" and versioncmp($lsbdistrelease, "6.0") >= 0) or
($lsbdistid == "Ubuntu" and versioncmp($lsbdistrelease, "10.04") >= 0) {
file {"/etc/apt/preferences.d/$fname":
if versioncmp($::apt_version, '0.7.22') >= 0 {
file {"/etc/apt/preferences.d/$fname":
ensure => $ensure,
owner => root,
group => root,
Expand All @@ -20,15 +19,5 @@
notify => Exec["apt-get_update"],
}
}
else {
common::concatfilepart { $fname:
ensure => $ensure,
manage => true,
file => "/etc/apt/preferences",
content => template("apt/preferences.erb"),
before => Exec["apt-get_update"],
notify => Exec["apt-get_update"],
}
}

}

0 comments on commit 392328c

Please sign in to comment.