--- - 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: '{{ deb_locales_list }}' when: ansible_distribution_file_variety == "Debian" tags: [ 'systemsetup', 'locale' ] - block: - name: Set the default locale on Trusty shell: update-locale LANG={{ deb_default_locale }} 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 {{ default_locale }} when: localectl_executable.stat.exists | bool tags: [ 'systemsetup', 'locale' ]