From 4d0ddd005795592f56496d8d39dc37ee86fac038 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Mon, 9 Apr 2012 01:33:13 -0400 Subject: Refactor: manage .d directories when using sources_list and apt_conf The .d directories are only managed by the main 'apt' class. However, both 'sources_list' and 'apt_conf' defines depend on those directories. So in practice, the defines have an implicit need for those directories to be somehow managed. Let's turn this into an explicit relation, and include the directories in the defines. This makes it possible to use both defines without having to include the main 'apt' class. (maybe when using puppet apply?) Signed-off-by: Gabriel Filion --- manifests/sources_list.pp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'manifests/sources_list.pp') diff --git a/manifests/sources_list.pp b/manifests/sources_list.pp index 86b35a7..edf7f22 100644 --- a/manifests/sources_list.pp +++ b/manifests/sources_list.pp @@ -11,6 +11,8 @@ define apt::sources_list ( fail("Only one of \$source or \$content must specified for apt_sources_snippet ${name}") } + include apt::dot_d_directories + file { "/etc/apt/sources.list.d/${name}": ensure => $ensure, owner => root, group => 0, mode => 0644; -- cgit v1.2.3 From a835369958226bac2d010fedb50ed5ef98b5906f Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Mon, 9 Apr 2012 01:39:29 -0400 Subject: Force an apt-get update when changing an apt::sources_list sources_list doesn't currently force puppet to run 'apt-get update' after creating/modifying/removing files in sources.list.d. Signed-off-by: Gabriel Filion --- manifests/apt_conf.pp | 5 ++++- manifests/init.pp | 3 ++- manifests/sources_list.pp | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'manifests/sources_list.pp') diff --git a/manifests/apt_conf.pp b/manifests/apt_conf.pp index 03ae1ac..fe07546 100644 --- a/manifests/apt_conf.pp +++ b/manifests/apt_conf.pp @@ -14,10 +14,13 @@ define apt::apt_conf( include apt::dot_d_directories + # One would expect the 'file' resource on sources.list.d to trigger an + # apt-get update when files are added or modified in the directory, but it + # apparently doesn't. file { "/etc/apt/apt.conf.d/${name}": ensure => $ensure, + owner => root, group => 0, mode => 0644, notify => Exec["refresh_apt"], - owner => root, group => 0, mode => 0644; } if $source { diff --git a/manifests/init.pp b/manifests/init.pp index 0d58c61..4d65e77 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -85,7 +85,8 @@ class apt { '' => template( "apt/$operatingsystem/sources.list.erb"), default => $custom_sources_list }, - require => Package['lsb']; + require => Package['lsb'], + notify => Exec['refresh_apt'], } apt_conf { "02show_upgraded": diff --git a/manifests/sources_list.pp b/manifests/sources_list.pp index edf7f22..499116d 100644 --- a/manifests/sources_list.pp +++ b/manifests/sources_list.pp @@ -13,9 +13,13 @@ define apt::sources_list ( include apt::dot_d_directories + # One would expect the 'file' resource on sources.list.d to trigger an + # apt-get update when files are added or modified in the directory, but it + # apparently doesn't. file { "/etc/apt/sources.list.d/${name}": ensure => $ensure, - owner => root, group => 0, mode => 0644; + owner => root, group => 0, mode => 0644, + notify => Exec['refresh_apt'], } if $source { -- cgit v1.2.3