> ## Content Index
> Fetch the complete content index at: https://terpuh-labs.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Set Local Timezone with Ansible
- URL: https://terpuh-labs.com/set-local-timezone-with-ansible/
- Published: 2023-03-12T21:58:57.000Z
- Updated: 2023-03-12T22:12:29.000Z
- Author: Yurko Tymchuk
- Tags: Imported from Hashnode, #Import 2026-09-10 11:25

# Set Local Timezone with Ansible

You know this annoyance when you install a fresh linux server and it has time in UTC? At least I end up like that with Armbian when I don't access it with interactive shell.

It turns out that there is a very simple way of setting your timezone automatically based in your IP location, especially if you use Ansible for that.

Now, Ansible has two tasks:

- [ipinfoio\_facts](https://docs.ansible.com/ansible/latest/collections/community/general/ipinfoio%5Ffacts%5Fmodule.html?ref=terpuh-labs.com): which uses [http://ipinfo.io/](http://ipinfo.io/?ref=terpuh-labs.com) to approximate your lacation based on your external IP address;
- [timezone](https://docs.ansible.com/ansible/latest/collections/community/general/timezone%5Fmodule.html?ref=terpuh-labs.com): which sets your timezone.

Thus everything you need to do, is to have these two tasks sequentially in your playbook

```yaml
---
- hosts: "all"
  become: true

  tasks:
    - name: Get IP geolocation data
      ipinfoio_facts:

    - name: "Set timezone to {{ ansible_facts.timezone }}"
      timezone:
        name: "{{ ansible_facts.timezone }}"
      when: ansible_facts.timezone is defined

```

As you can guess from the code, the `ipinfoio_facts` task is going to populate `ansible_facts` with various location datai, and out of which we will use `timezone` to set, well..., the time zone (if it's available).

That's all. I hope I helped someone ☺️