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 <lelutin@gmail.com>
This commit is contained in:
parent
e22029433a
commit
ac76a5d52d
7 changed files with 51 additions and 17 deletions
1
files/02show_upgraded
Normal file
1
files/02show_upgraded
Normal file
|
@ -0,0 +1 @@
|
||||||
|
APT::Get::Show-Upgraded true;
|
1
files/03clean
Normal file
1
files/03clean
Normal file
|
@ -0,0 +1 @@
|
||||||
|
DSelect::Clean auto;
|
29
manifests/apt_conf_snippet.pp
Normal file
29
manifests/apt_conf_snippet.pp
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,7 +23,8 @@ class apt {
|
||||||
'': {
|
'': {
|
||||||
config_file {
|
config_file {
|
||||||
# include main, security and backports
|
# 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":
|
"/etc/apt/sources.list":
|
||||||
content => template( "apt/$operatingsystem/sources.list.erb"),
|
content => template( "apt/$operatingsystem/sources.list.erb"),
|
||||||
require => Package['lsb'];
|
require => Package['lsb'];
|
||||||
|
@ -37,11 +38,17 @@ class apt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config_file {
|
# 01autoremove already present by default
|
||||||
# little default settings which keep the system sane
|
apt_conf_snippet{ "02show_upgraded":
|
||||||
"/etc/apt/apt.conf.d/from_puppet":
|
source => ["puppet:///modules/site-apt/${fqdn}/02show_upgraded",
|
||||||
content => "APT::Get::Show-Upgraded true;\nDSelect::Clean $real_apt_clean;\n",
|
"puppet:///modules/site-apt/02show_upgraded",
|
||||||
before => Concatenated_file['/etc/apt/preferences'];
|
"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 {
|
case $custom_preferences {
|
||||||
|
|
|
@ -10,9 +10,7 @@ class apt::proxy-client {
|
||||||
default => $apt_proxy_port
|
default => $apt_proxy_port
|
||||||
}
|
}
|
||||||
|
|
||||||
file { "/etc/apt/apt.conf.d/20proxy":
|
apt_conf_snippet { "20proxy":
|
||||||
ensure => present,
|
content => template("apt/20proxy.erb"),
|
||||||
content => "Acquire::http { Proxy \"http://$real_apt_proxy:$real_apt_proxy_port\"; };\n",
|
|
||||||
owner => root, group => 0, mode => 0644;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,11 @@ class apt::unattended_upgrades {
|
||||||
require => undef,
|
require => undef,
|
||||||
}
|
}
|
||||||
|
|
||||||
config_file {
|
apt_conf_snippet { "50unattended-upgrades":
|
||||||
"/etc/apt/apt.conf.d/50unattended-upgrades":
|
source => ["puppet:///modules/site-apt/50unattended-upgrades",
|
||||||
source => ["puppet:///modules/site-apt/50unattended-upgrades",
|
"puppet:///modules/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 => Concatenated_file[apt_config],
|
||||||
|
|
||||||
#before => Config_file[apt_config],
|
|
||||||
require => Package['unattended-upgrades'],
|
require => Package['unattended-upgrades'],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1
templates/20proxy.erb
Normal file
1
templates/20proxy.erb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Acquire::http { Proxy "http://<%= real_apt_proxy %>:<%= real_apt_proxy_port %>"; };
|
Loading…
Reference in a new issue