这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,16 @@
$locale_template = 'locale.erb'
}

case $ensure {
'present': {
$default_file_ensure = 'file'
}
default: {
$default_file_ensure = 'absent'
}
}
file { $default_file:
ensure => $ensure,
ensure => $default_file_ensure,
owner => 'root',
group => 0,
mode => '0644',
Expand All @@ -189,10 +197,17 @@
}

$debian_legacy_location = '/etc/default/locale'
if $facts['os']['family'] == 'Debian' and $default_file != $debian_legacy_location {
file { $debian_legacy_location:
ensure => $ensure,
target => $default_file,
$debian_new_location = '/etc/locale.conf'
if $facts['os']['family'] == 'Debian' {
if $default_file == $debian_legacy_location {
file { $debian_new_location:
ensure => absent,
}
} else {
file { $debian_legacy_location:
ensure => $ensure,
target => '../locale.conf',
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
$config_file = '/etc/locale.gen'
}
/(Debian|Raspbian|Kali|Parrot)/: {
if versioncmp($facts['os']['release']['major'], '12') >= 0 {
if versioncmp($facts['os']['release']['major'], '13') >= 0 {
$default_file = '/etc/locale.conf'
} else {
$default_file = '/etc/default/locale'
Expand Down
50 changes: 30 additions & 20 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@

case facts[:os]['family'].downcase
when 'debian'
debian_legacy_location = '/etc/default/locale'
debian_new_location = '/etc/locale.conf'
case facts[:os]['name'].downcase
when 'debian'
default_file = if Gem::Version.new(facts[:os]['release']['major']) >= Gem::Version.new('12')
'/etc/locale.conf'
default_file = if Gem::Version.new(facts[:os]['release']['major']) > Gem::Version.new('12')
debian_new_location
else
'/etc/default/locale'
debian_legacy_location
end
when 'ubuntu'
default_file = if Gem::Version.new(facts[:os]['release']['full']) >= Gem::Version.new('24.04')
'/etc/locale.conf'
debian_new_location
else
'/etc/default/locale'
debian_legacy_location
end
end
when 'sles', 'suse'
Expand All @@ -38,21 +40,29 @@
default_file = '/etc/locale.conf'
end

if os =~ (%r{^(debian|ubuntu)}) && (default_file != '/etc/default/locale')
it do
is_expected.to contain_file('/etc/default/locale').with(
'ensure' => 'present',
'target' => '/etc/locale.conf'
)
end
else
it do
is_expected.to contain_file(default_file).with(
'ensure' => 'present',
'owner' => 'root',
'group' => 0,
'mode' => '0644'
)
it do
is_expected.to contain_file(default_file).with(
'ensure' => 'file',
'owner' => 'root',
'group' => 0,
'mode' => '0644'
)
end

if os =~ (%r{^(debian|ubuntu)})
if default_file == debian_legacy_location
it do
is_expected.to contain_file(debian_new_location).with(
'ensure' => 'absent'
)
end
else
it do
is_expected.to contain_file(debian_legacy_location).with(
'ensure' => 'present',
'target' => '../locale.conf'
)
end
end
end
end
Expand Down
Loading