]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/commitdiff
Factorize locales functions
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 9 Aug 2016 13:38:57 +0000 (15:38 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 9 Aug 2016 13:38:57 +0000 (15:38 +0200)
modules/locales/manifests/init.pp
modules/locales/manifests/locale.pp [new file with mode: 0644]

index 6a5dc2a0e764751b043544e41577270b62b13c24..982b48e07fddf8f09da29a8e7a717f0072b674a6 100644 (file)
@@ -1,13 +1,9 @@
 class locales {
-  file_line { '/etc/locale.gen#fr_FR.UTF-8':
-    path  => '/etc/locale.gen',
-    line  => 'fr_FR.UTF-8 UTF-8  ',
-    match => '#?fr_FR.UTF-8 UTF-8 +$',
+  locales::locale { '/etc/locale.gen#fr_FR.UTF-8':
+    locale => 'fr_FR.UTF-8'
   }
-  file_line { '/etc/locale.gen#en_US.UTF-8':
-    path  => '/etc/locale.gen',
-    line  => 'en_US.UTF-8 UTF-8  ',
-    match => '#?en_US.UTF-8 UTF-8 +$',
+  locales::locale { '/etc/locale.gen#en_US.UTF-8':
+    locale => 'en_US.UTF-8'
   }
   exec { '/usr/bin/locale-gen':
     subscribe   => File_line['/etc/locale.gen#fr_FR.UTF-8', '/etc/locale.gen#en_US.UTF-8'],
diff --git a/modules/locales/manifests/locale.pp b/modules/locales/manifests/locale.pp
new file mode 100644 (file)
index 0000000..1eb14be
--- /dev/null
@@ -0,0 +1,7 @@
+define locales::locale ($locale, $charmap = 'UTF-8') {
+  file_line { "/etc/locale.gen#$locale":
+    path  => '/etc/locale.gen',
+    line  => "$locale $charmap  ",
+    match => "#?$locale $charmap +$",
+  }
+}