From 4a6a1e80937ddd4c13d737ae7ee395e2b84d7f5a Mon Sep 17 00:00:00 2001
From: Adam Henry Lewenberg <adamhl@stanford.edu>
Date: Mon, 9 Jan 2017 07:50:18 -0800
Subject: [PATCH] os: change name of aptitude update exec resource

---
 NEWS                   |  7 +++++++
 manifests/os/debian.pp | 34 ++++++++++++++++++++++------------
 2 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/NEWS b/NEWS
index d7b0576..f54209f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+release/005.004 (2017-01-09)
+
+    [os] Change the exec resource in the 'aptitude' staged
+    base::os::debian::apt class to have the name 'apt config aptitude
+    update' so that it will not interfere with other exec's of the same
+    name in the 'main' stage. [adamhl]
+
 release/005.003 (2016-12-16)
 
     [ssh] Add "@" to a few more variables on sshd_config.erb. [adamhl]
diff --git a/manifests/os/debian.pp b/manifests/os/debian.pp
index 8a110a9..0d1ea6d 100644
--- a/manifests/os/debian.pp
+++ b/manifests/os/debian.pp
@@ -137,13 +137,23 @@ class base::os::debian (
 # sources, preferences, etc.  It is meant to be run in its own phase, before
 # the main phase.  This is needed so that we can install packages without the
 # possibility of weird aptitude errors.
+
+# There is an exec resource in this class that does an 'aptitude
+# update'. This class runs in the early 'aptitude' stage (see earlier in
+# this file) and hence the exec resource also runs in this early
+# stage. However, this can cause a problem if classes running in the
+# 'main' stage call 'exec aptitude'. To avoid this issue, we give the
+# 'aptitude update' resource in this class a different name; any other
+# class that wants to run 'aptitude update' will have to declare the
+# 'aptitude update' exec resource itself.
+
 class base::os::debian::apt (
   $apt_cache_notin_tmp = false,
   $apt_cache_tmp_dir   = '/var/cache/apt/tmp'
 ){
 
   # Define aptitude update as a command we can run
-  exec { 'aptitude update':
+  exec { 'apt config aptitude update':
     command     => 'aptitude update',
     path        => '/bin:/usr/bin',
     refreshonly => true,
@@ -153,7 +163,7 @@ class base::os::debian::apt (
   # Make sure this gets created BEFORE `aptitude update` runs.
   file { '/etc/apt/apt.conf.d/10recommends':
     source => 'puppet:///modules/base/os/etc/apt/apt.conf.d/10recommends',
-    before => Exec['aptitude update'],
+    before => Exec['apt config aptitude update'],
   }
 
   # If aptitude is using something other than /tmp, set that up first
@@ -171,7 +181,7 @@ class base::os::debian::apt (
     file { '/etc/apt/apt.conf.d/apt_cache_tmp':
       content => template('base/os/etc/apt/apt.conf.d/apt_cache_tmp.erb'),
       require => File[$apt_cache_tmp_dir],
-      before  => Exec['aptitude update'],
+      before  => Exec['apt config aptitude update'],
     }
   }
 
@@ -180,7 +190,7 @@ class base::os::debian::apt (
   if $::lsbdistcodename == 'wheezy' {
     file { '/etc/apt/apt.conf.d/30no-pdiffs':
       source => 'puppet:///modules/base/os/etc/apt/apt.conf.d/30no-pdiffs',
-      before => Exec['aptitude update'],
+      before => Exec['apt config aptitude update'],
     }
   }
 
@@ -189,18 +199,18 @@ class base::os::debian::apt (
   file {
     '/etc/apt/sources.list':
       content => template('base/os/sources/sources.list.erb'),
-      notify  => Exec['aptitude update'];
+      notify  => Exec['apt config aptitude update'];
     '/etc/apt/sources.list.d':
       ensure  => 'directory',
       recurse => true,
       purge   => true,
-      notify  => Exec['aptitude update'];
+      notify  => Exec['apt config aptitude update'];
     '/etc/apt/sources.list.d/backports.list':
       content => template('base/os/sources/backports.list.erb'),
-      notify  => Exec['aptitude update'];
+      notify  => Exec['apt config aptitude update'];
     '/etc/apt/sources.list.d/stanford.list':
       content => template('base/os/sources/stanford.list.erb'),
-      notify  => Exec['aptitude update'];
+      notify  => Exec['apt config aptitude update'];
   }
 
   # Install APT preferences.  We should never use /etc/apt/preferences
@@ -213,21 +223,21 @@ class base::os::debian::apt (
   if $::lsbdistcodename == 'wheezy' {
     file { '/etc/apt/preferences.d/rsyslog':
       content => template('base/os/preferences/rsyslog.erb'),
-      notify  => Exec['aptitude update'],
+      notify  => Exec['apt config aptitude update'],
     }
   }
   file {
     '/etc/apt/preferences':
       content => '',
-      notify  => Exec['aptitude update'];
+      notify  => Exec['apt config aptitude update'];
     '/etc/apt/preferences.d/backports':
       content => template('base/os/preferences/backports.erb'),
-      notify  => Exec['aptitude update'];
+      notify  => Exec['apt config aptitude update'];
   }
 
   # Install the stanford-keyring package
   package { 'stanford-keyring':
     require         => File['/etc/apt/sources.list.d/stanford.list'],
-    notify          => Exec['aptitude update'],
+    notify          => Exec['apt config aptitude update'],
   }
 }
-- 
GitLab