From 2ab75757cd7f073c5bf45f7ec1d7472543b813af Mon Sep 17 00:00:00 2001 From: Farhad Shahbazi Date: Fri, 13 May 2016 12:23:20 +0200 Subject: [PATCH] add locale management --- README.md | 6 ++++++ defaults/main.yml | 4 ++++ tasks/locales.yml | 11 +++++++++++ tasks/main.yml | 4 ++++ 4 files changed, 25 insertions(+) create mode 100644 tasks/locales.yml diff --git a/README.md b/README.md index 950a5d4..a40af04 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,12 @@ Including an example of how to use your role (for instance, with variables passe roles: - role: SphericalElephant.common common_basic_packages: ['vim', 'zsh'], + common_locales: + - name: en_US.UTF-8 + - name: en_US + - name: en_US.ISO-8859-15 + - { name: de_AT, state: absent } + common_locales_default: C.UTF-8 common_mailer: False, common_resolvconf_nameservers: ['1.2.3.4', '2.3.4.5'] diff --git a/defaults/main.yml b/defaults/main.yml index 0dcdaa8..0ef1ce6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -5,6 +5,10 @@ common_apt_repositories: - "deb http://cdn.debian.net/debian {{ ansible_distribution_release }}-backports main contrib non-free" - "deb http://security.debian.org/ {{ ansible_distribution_release }}/updates main contrib non-free" common_apt_upgrade_policy: "" + +common_locales: [] +common_locales_default: + common_resolvconf_hnfqdn: true common_resolvconf_nameservers: [] common_resolvconf_domain: "" diff --git a/tasks/locales.yml b/tasks/locales.yml new file mode 100644 index 0000000..eb5127d --- /dev/null +++ b/tasks/locales.yml @@ -0,0 +1,11 @@ +--- + +- name: set locales + locale_gen: name="{{ item.name }}" state="{{ item.state | default('present') }}" + with_items: "{{ common_locales }}" + tags: ['common', 'locales'] + +- name: set default locale + lineinfile: dest="/etc/default/locale" regexp="LANG=" line="LANG={{ common_locales_default }}" + when: common_locales_default + tags: ['common', 'locales'] diff --git a/tasks/main.yml b/tasks/main.yml index 76b5dd0..1e7e64d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -3,6 +3,10 @@ - include: resolvconf.yml - include: apt.yml +- include: locales.yml + when: common_locales + tags: ['common', 'locales'] + - name: set vim as default editor alternatives: name=editor path=/usr/bin/vim.basic when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'