Update locale and timezone on ubuntu
Here's a simple ansible playbook for setting the locale and time zone on an Ubuntu server.
- name: Set the locale and the time zone
hosts: myhosts
sudo: True
vars:
locale: en_US.UTF-8
timezone: America/New_York
tasks:
- name: set locale
command: /usr/sbin/update-locale LANG={{ locale }} LC_ALL=$locale
- name: set /etc/localtime
file: src=/usr/share/zoneinfo/{{ timezone }} dest=/etc/localtime state=link
- name: set /etc/timezone
template: src=templates/etc/timezone dest=/etc/timezone
notify: update tzdata
handlers:
- name: update tzdata
command: /usr/sbin/dpkg-reconfigure --frontend noninteractive tzdata
It also needs a template file in ./templates/etc/timezone that looks like this:
{{ timezone }}
Use it like this:
$ ansible-playbook set-locale-and-timezone.yaml
Written by Lorin Hochstein
Related protips
1 Response
should you be copying or symlinking these tz files?
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ansible
Authors
Misha Behersky
78.83K
tartansandal
73.25K
Related Tags
#ansible
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#