--- - name: Generate locales and set the default locale on Debian and Ubuntu distributions block: - name: Add/remove a list of locales locale_gen: name={{ item.name }} state={{ item.state | default('present') }} with_items: '{{ locales_list }}' when: ansible_distribution_file_variety == "Debian" tags: [ 'systemsetup', 'locale' ] - block: - name: Set the default locale on Trusty shell: update-locale LANG={{ default_locale_lang }} when: ansible_distribution_release == "trusty" tags: [ 'systemsetup', 'locale' ] - name: Set the locale on distributions that run systemd block: - name: Check if localectl exists stat: path=/usr/bin/localectl register: localectl_executable - name: Set the default locale command: localectl set-locale "{{ item }}" with_items: - 'LANG={{ default_locale_lang }}' - 'LC_MESSAGES={{ default_locale_messages }}' when: localectl_executable.stat.exists | bool tags: [ 'systemsetup', 'locale' ]