File tree Expand file tree Collapse file tree 4 files changed +82
-0
lines changed Expand file tree Collapse file tree 4 files changed +82
-0
lines changed Original file line number Diff line number Diff line change 1+ # @summary Manages the Apt auth conf in /etc/apt/auth.conf.d/.
2+ #
3+ # @example Install the puppetlabs apt auth
4+ # apt::auth { 'puppetlabs':
5+ # machine => 'apt.puppetlabs.com',
6+ # login => 'apt',
7+ # password => 'password',
8+ # }
9+ #
10+ # @param ensure
11+ # Specifies whether the Apt auth file should exist. Valid options: 'present' and 'absent'.
12+ #
13+ # @param machine
14+ # The machine entry specifies the auth URI.
15+ #
16+ # @param login
17+ # The username to be used.
18+ #
19+ # @param password
20+ # The password to be used.
21+ #
22+
23+ define apt::auth (
24+ String $ensure = ' present' ,
25+ String $machine = $name,
26+ String $login = undef ,
27+ String $password = undef ,
28+ ) {
29+ $content = epp(' apt/auth_conf.d.epp' ,
30+ machine => $machine ,
31+ login => $login ,
32+ password => $password
33+ )
34+
35+ file { "${apt::auth_conf_d}/${name}.conf" :
36+ ensure => $ensure ,
37+ owner => $apt::auth_conf_owner ,
38+ group => ' root' ,
39+ mode => ' 0600' ,
40+ content => Sensitive($content ),
41+ notify => Class[' apt::update' ],
42+ }
43+ }
Original file line number Diff line number Diff line change 8787# @param sources
8888# Hash of `apt::source` resources.
8989#
90+ # @param auths
91+ # Creates new `apt::auth` resources. Valid options: a hash to be passed to the create_resources function linked above.
92+ #
9093# @param keys
9194# Hash of `apt::key` resources.
9295#
145148# @param apt_conf_d
146149# The path to the file `apt.conf.d`
147150#
151+ # @param auth_conf_d
152+ # The path to the file `auth_conf.d`
153+ #
148154# @param source_key_defaults
149155# The fault `source_key` settings
150156#
185191 Hash $purge = {},
186192 Apt::Proxy $proxy = {},
187193 Hash $sources = {},
194+ Hash $auths = {},
188195 Hash $keys = {},
189196 Hash $keyrings = {},
190197 Hash $ppas = {},
200207 Stdlib::Absolutepath $preferences = " ${root} /preferences" ,
201208 Stdlib::Absolutepath $preferences_d = " ${root} /preferences.d" ,
202209 Stdlib::Absolutepath $apt_conf_d = " ${root} /apt.conf.d" ,
210+ Stdlib::Absolutepath $auth_conf_d = " ${root} /auth.conf.d" ,
203211 Hash $config_files = {
204212 ' conf' => {
205213 ' path' => $conf_d ,
379387 notify => Class[' apt::update' ],
380388 }
381389
390+ file { 'auth.conf.d' :
391+ ensure => directory ,
392+ path => $apt::auth_conf_d ,
393+ owner => root,
394+ group => root,
395+ purge => $_purge[' auth.conf.d' ],
396+ recurse => $_purge[' auth.conf.d' ],
397+ notify => Class[' apt::update' ],
398+ }
399+
382400 $confs .each |$key , $value | {
383401 apt::conf { $key:
384402 * => $value ,
391409 }
392410 }
393411
412+ $auths .each |$key , $value | {
413+ apt::auth { $key:
414+ * => $value ,
415+ }
416+ }
417+
394418 $keys .each |$key , $value | {
395419 apt::key { $key:
396420 * => $value ,
Original file line number Diff line number Diff line change 3838 recurse : false ,
3939 notify : 'Class[Apt::Update]' }
4040
41+ auth_conf_d = { ensure : 'directory' ,
42+ path : '/etc/apt/auth.conf.d' ,
43+ owner : 'root' ,
44+ group : 'root' ,
45+ purge : false ,
46+ recurse : false ,
47+ notify : 'Class[Apt::Update]' }
48+
4149describe 'apt' do
4250 let ( :facts ) do
4351 {
7785 expect ( subject ) . to contain_file ( 'apt.conf.d' ) . that_notifies ( 'Class[Apt::Update]' ) . only_with ( apt_conf_d )
7886 }
7987
88+ it {
89+ is_expected . to contain_file ( 'auth.conf.d' ) . that_notifies ( 'Class[Apt::Update]' ) . only_with ( auth_conf_d )
90+ }
91+
8092 it { is_expected . to contain_file ( '/etc/apt/auth.conf' ) . with_ensure ( 'absent' ) }
8193
8294 it 'lays down /etc/apt/apt.conf.d/15update-stamp' do
Original file line number Diff line number Diff line change 1+ machine <%= $machine %>
2+ login <%= $login %>
3+ password <%= $password %>
You can’t perform that action at this time.
0 commit comments