Allow the use of the same key in multiple sources
[puppet-modules/puppetlabs-apt.git] / manifests / init.pp
1 # Class: apt
2 #
3 # This module manages the initial configuration of apt.
4 #
5 # Parameters:
6 #   Both of the parameters listed here are not required in general and were
7 #     added for use cases related to development environments.
8 #   disable_keys - disables the requirement for all packages to be signed
9 #   always_apt_update - rather apt should be updated on every run (intended
10 #     for development environments where package updates are frequent
11 # Actions:
12 #
13 # Requires:
14 #
15 # Sample Usage:
16 #  class { 'apt': }
17 class apt(
18   $disable_keys = false,
19   $always_apt_update = false,
20   $proxy_host = false,
21   $proxy_port = '8080'
22 ) {
23
24   include apt::params
25
26   $refresh_only_apt_update = $always_apt_update? {
27     true => false,
28     false => true
29   }
30
31   package { "python-software-properties": }
32
33   file { "sources.list":
34     path => "${apt::params::root}/sources.list",
35     ensure => present,
36     owner => root,
37     group => root,
38     mode => 644,
39   }
40
41   file { "sources.list.d":
42     path => "${apt::params::root}/sources.list.d",
43     ensure => directory,
44     owner => root,
45     group => root,
46   }
47
48   exec { "apt_update":
49     command => "${apt::params::provider} update",
50     subscribe => [ File["sources.list"], File["sources.list.d"] ],
51     refreshonly => $refresh_only_apt_update,
52   }
53   if($disable_keys) {
54     exec { 'make-apt-insecure':
55       command => '/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth',
56       creates => '/etc/apt/apt.conf.d/99unauth'
57     }
58   }
59
60   if($proxy_host) {
61     file { 'configure-apt-proxy':
62       path    => '/etc/apt/apt.conf.d/proxy',
63       content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";",
64     }
65   }
66 }