Fix (#10451) - apt::ppa fails to "apt-get update" when new PPA source is added
[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 ) {
21
22   include apt::params
23
24   $refresh_only_apt_update = $always_apt_update? {
25     true => false,
26     false => true
27   }
28
29   package { "python-software-properties": }
30
31   file { "sources.list":
32     name => "${apt::params::root}/sources.list",
33     ensure => present,
34     owner => root,
35     group => root,
36     mode => 644,
37   }
38
39   file { "sources.list.d":
40     name => "${apt::params::root}/sources.list.d",
41     ensure => directory,
42     owner => root,
43     group => root,
44   }
45
46   exec { "apt_update":
47     command => "${apt::params::provider} update",
48     subscribe => [ File["sources.list"], File["sources.list.d"] ],
49     refreshonly => $refresh_only_apt_update,
50   }
51   if($disable_keys) {
52     exec { 'make-apt-insecure':
53       command => '/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth',
54       creates => '/etc/apt/apt.conf.d/99unauth'
55     }
56   }
57 }