From e22029433aa82817fb4cfcb9281991b5bd526c09 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sun, 24 Oct 2010 07:32:14 -0400 Subject: Move default_sources_list into apt class The contents of the file default_sources_list.pp is used in only one place. Remove the file and move its contents inside the apt class in order to have one less useless depth level. Signed-off-by: Gabriel Filion --- manifests/default_sources_list.pp | 11 ----------- manifests/init.pp | 12 +++++++++--- 2 files changed, 9 insertions(+), 14 deletions(-) delete mode 100644 manifests/default_sources_list.pp diff --git a/manifests/default_sources_list.pp b/manifests/default_sources_list.pp deleted file mode 100644 index cf7d523..0000000 --- a/manifests/default_sources_list.pp +++ /dev/null @@ -1,11 +0,0 @@ -class apt::default_sources_list { - include lsb - config_file { - # include main, security and backports - # additional sources could be included via an array - "/etc/apt/sources.list": - content => template( "apt/$operatingsystem/sources.list.erb"), - require => Package['lsb']; - } -} - diff --git a/manifests/init.pp b/manifests/init.pp index 1011e65..145bba6 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -6,7 +6,7 @@ class apt { import "custom_sources.pp" - + # See README $real_apt_clean = $apt_clean ? { '' => 'auto', @@ -18,12 +18,18 @@ class apt { require => undef, } + include lsb case $custom_sources_list { '': { - include apt::default_sources_list + config_file { + # include main, security and backports + # additional sources could be included via an array + "/etc/apt/sources.list": + content => template( "apt/$operatingsystem/sources.list.erb"), + require => Package['lsb']; + } } default: { - include lsb config_file { "/etc/apt/sources.list": content => $custom_sources_list, require => Package['lsb']; -- cgit v1.2.3 From ac76a5d52df78aec919f08334ca5b140902a9298 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sun, 24 Oct 2010 09:07:34 -0400 Subject: Add apt_conf_snippet and use it where possible With the new define, it's easy to add an apt.conf snippet in apt.conf.d It accepts either 'sources' to get a static file or 'content' to define content inline or with the help of a template. Put it to use where we create files in apt.conf.d Finally, fix the dependancy to the apt_config file (however, I don't see the need for this dependancy) Signed-off-by: Gabriel Filion --- files/02show_upgraded | 1 + files/03clean | 1 + manifests/apt_conf_snippet.pp | 29 +++++++++++++++++++++++++++++ manifests/init.pp | 19 +++++++++++++------ manifests/proxy-client.pp | 6 ++---- manifests/unattended_upgrades.pp | 11 ++++------- templates/20proxy.erb | 1 + 7 files changed, 51 insertions(+), 17 deletions(-) create mode 100644 files/02show_upgraded create mode 100644 files/03clean create mode 100644 manifests/apt_conf_snippet.pp create mode 100644 templates/20proxy.erb diff --git a/files/02show_upgraded b/files/02show_upgraded new file mode 100644 index 0000000..870a3a9 --- /dev/null +++ b/files/02show_upgraded @@ -0,0 +1 @@ +APT::Get::Show-Upgraded true; diff --git a/files/03clean b/files/03clean new file mode 100644 index 0000000..335823d --- /dev/null +++ b/files/03clean @@ -0,0 +1 @@ +DSelect::Clean auto; diff --git a/manifests/apt_conf_snippet.pp b/manifests/apt_conf_snippet.pp new file mode 100644 index 0000000..77b88ae --- /dev/null +++ b/manifests/apt_conf_snippet.pp @@ -0,0 +1,29 @@ +define apt::apt_conf_snippet( + $ensure = 'present', + $source = '', + $content = undef +){ + if $source == '' and $content == undef { + fail("One of \$source or \$content must be specified for apt_conf_snippet ${name}") + } + if $source != '' and $content != undef { + fail("Only one of \$source or \$content must specified for apt_conf_snippet ${name}") + } + + if $source { + file { "/etc/apt/apt.conf.d/${name}": + ensure => $ensure, + source => $source, + notify => Exec["refresh_apt"], + owner => root, group => 0, mode => 0600; + } + } + else { + file { "/etc/apt/apt.conf.d/${name}": + ensure => $ensure, + content => $content, + notify => Exec["refresh_apt"], + owner => root, group => 0, mode => 0600; + } + } +} diff --git a/manifests/init.pp b/manifests/init.pp index 145bba6..0e4bd5c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -23,7 +23,8 @@ class apt { '': { config_file { # include main, security and backports - # additional sources could be included via an array + # additional sources should be included via the custom_sources_template + # define "/etc/apt/sources.list": content => template( "apt/$operatingsystem/sources.list.erb"), require => Package['lsb']; @@ -37,11 +38,17 @@ class apt { } } - config_file { - # little default settings which keep the system sane - "/etc/apt/apt.conf.d/from_puppet": - content => "APT::Get::Show-Upgraded true;\nDSelect::Clean $real_apt_clean;\n", - before => Concatenated_file['/etc/apt/preferences']; + # 01autoremove already present by default + apt_conf_snippet{ "02show_upgraded": + source => ["puppet:///modules/site-apt/${fqdn}/02show_upgraded", + "puppet:///modules/site-apt/02show_upgraded", + "puppet:///modules/apt/02show_upgraded"] + } + + apt_conf_snippet{ "03clean": + source => ["puppet:///modules/site-apt/${fqdn}/03clean", + "puppet:///modules/site-apt/03clean", + "puppet:///modules/apt/03clean"] } case $custom_preferences { diff --git a/manifests/proxy-client.pp b/manifests/proxy-client.pp index ea0a29c..30bda8a 100644 --- a/manifests/proxy-client.pp +++ b/manifests/proxy-client.pp @@ -10,9 +10,7 @@ class apt::proxy-client { default => $apt_proxy_port } - file { "/etc/apt/apt.conf.d/20proxy": - ensure => present, - content => "Acquire::http { Proxy \"http://$real_apt_proxy:$real_apt_proxy_port\"; };\n", - owner => root, group => 0, mode => 0644; + apt_conf_snippet { "20proxy": + content => template("apt/20proxy.erb"), } } diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index e1080a0..6a0c685 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -4,14 +4,11 @@ class apt::unattended_upgrades { require => undef, } - config_file { - "/etc/apt/apt.conf.d/50unattended-upgrades": - source => ["puppet:///modules/site-apt/50unattended-upgrades", - "puppet:///modules/apt/50unattended-upgrades" ], + apt_conf_snippet { "50unattended-upgrades": + source => ["puppet:///modules/site-apt/50unattended-upgrades", + "puppet:///modules/apt/50unattended-upgrades" ], - # err: Could not run Puppet configuration client: Could not find dependent Config_file[apt_config] for Config_file[/etc/apt/apt.conf.d/50unattended-upgrades] at /etc/puppet/modules/apt/manifests/unattended_upgrades.pp:14 - - #before => Config_file[apt_config], + before => Concatenated_file[apt_config], require => Package['unattended-upgrades'], } } diff --git a/templates/20proxy.erb b/templates/20proxy.erb new file mode 100644 index 0000000..e72319f --- /dev/null +++ b/templates/20proxy.erb @@ -0,0 +1 @@ +Acquire::http { Proxy "http://<%= real_apt_proxy %>:<%= real_apt_proxy_port %>"; }; -- cgit v1.2.3