Update playbooks/time-region.yml
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
---
|
||||
- name: Configure timezone and NTP
|
||||
hosts: all
|
||||
become: yes
|
||||
|
||||
vars:
|
||||
timezone_region: "Asia/Kolkata"
|
||||
ntp_server: "0.in.pool.ntp.org"
|
||||
|
||||
tasks:
|
||||
# ----------------------------------------------------------
|
||||
# TIMEZONE (LXC + Ubuntu + Rocky safe)
|
||||
# ----------------------------------------------------------
|
||||
- name: Copy timezone file
|
||||
ansible.builtin.copy:
|
||||
src: "/usr/share/zoneinfo/{{ timezone_region }}"
|
||||
dest: /etc/localtime
|
||||
remote_src: yes
|
||||
register: tz_copy
|
||||
|
||||
- name: Write /etc/timezone
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/timezone
|
||||
content: "{{ timezone_region }}\n"
|
||||
register: tz_write
|
||||
|
||||
- name: Debug timezone set
|
||||
ansible.builtin.debug:
|
||||
msg: "Timezone set to {{ timezone_region }} successfully."
|
||||
when: tz_copy.changed or tz_write.changed
|
||||
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# FINAL SUMMARY
|
||||
# ----------------------------------------------------------
|
||||
- name: Final summary
|
||||
ansible.builtin.debug:
|
||||
msg: "Timezone successfully applied on {{ inventory_hostname }}"
|
||||
Reference in New Issue
Block a user