File tree 2 files changed +47
-2
lines changed
2 files changed +47
-2
lines changed Original file line number Diff line number Diff line change 56
56
} else {
57
57
$_refresh = true
58
58
}
59
+ # We perform the update in an `unless` clause of the exec, and
60
+ # return true only if the `/var/cache/apt/pkgcache.bin` file changed.
61
+ # This ensures that Puppet does not report a change if the
62
+ # update command had no effect. See MODULES-10763 for discussion.
63
+ $apt_update_unless = epp(
64
+ ' apt/update_had_no_effect.sh.epp' ,
65
+ ' provider' => $apt::provider ,
66
+ ' timeout' => $apt::_update [' timeout' ],
67
+ ' tries' => $apt::_update [' tries' ],
68
+ )
59
69
exec { 'apt_update' :
60
- command => " ${apt::provider} update " ,
70
+ command => " echo ${apt::provider} updated the package cache. " ,
61
71
loglevel => $apt::_update [' loglevel' ],
62
72
logoutput => ' on_failure' ,
73
+ path => ' /bin:/sbin:/usr/bin:/usr/sbin' ,
74
+ provider => shell,
63
75
refreshonly => $_refresh,
64
76
timeout => $apt::_update [' timeout' ],
65
77
tries => $apt::_update [' tries' ],
66
- try_sleep => 1 ,
78
+ unless => $apt_update_unless ,
67
79
}
68
80
}
Original file line number Diff line number Diff line change
1
+ <%- |
2
+ String $provider = 'apt',
3
+ Integer $timeout = 30,
4
+ Integer $tries = 1,
5
+ | -%>
6
+
7
+ EVAL="$(mktemp)" || EVAL=/tmp/aptdir
8
+ apt-config shell DIR Dir::Cache > "$EVAL" && . "$EVAL"
9
+ [ "$DIR" ] || DIR='var/cache/apt'
10
+ cd "/$DIR" || exit 0
11
+ export TMPDIR="/$DIR"
12
+ apt-config shell CUR DIR::Cache::pkgcache >"$EVAL" && . "$EVAL"
13
+ [ "$CUR" ] || CUR=pkgcache.bin
14
+ OLD="$(mktemp)" || OLD="/${DIR}/${CUR}.old"
15
+ rm -f "$EVAL"
16
+ [ -e "$CUR" ] || touch "$CUR"
17
+ ln -f "$CUR" "$OLD"
18
+ TRIES=<%= $tries %>
19
+ while true; do
20
+ if timeout 1 true; then
21
+ timeout <%= $timeout %>m <%= $provider %> update && break
22
+ else
23
+ <%= $provider %> update && break
24
+ fi
25
+ [ $TRIES -le 1 ] && break
26
+ sleep 1
27
+ TRIES=$(( TRIES - 1 ))
28
+ done
29
+ SAME=1
30
+ [ -e "$CUR" ] || touch "$CUR"
31
+ cmp "$CUR" "$OLD" && SAME=0
32
+ rm -f "$OLD"
33
+ exit $SAME
You can’t perform that action at this time.
0 commit comments