728x90

앤서블 노드의 timezone 설정

1. timezone.yml 파일 생성

---
- name: Setup CentOS timezone
  hosts: CentOS
  gather_facts: no
  become: yes

  tasks:
    - name: set timezone to Asia/Seoul
      timezone: name=Asia/Seoul

 

2. 파일 실행

[vagrant@ansible-server ~]$ anp timezone.yml -k
SSH password:

PLAY [Setup CentOS timezone] *****************************************************************

TASK [set timezone to Asia/Seoul] ************************************************************
changed: [node01]
changed: [node02]

PLAY RECAP ***********************************************************************************
node01                     : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
node02                     : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

 

3. 확인

- 이 때, 앤서블 서버의 timezone은 변경되지 않음

- 앤서블 노드의 timezone만 변경된 것을 확인할 수 있음

# ansible-node01의 timezone
[vagrant@ansible-server ~]$ ssh vagrant@172.30.1.110
vagrant@172.30.1.110's password:
Last login: Wed Jun  8 19:45:46 2022 from 172.30.1.100

[vagrant@ansible-node01 ~]$ date
Wed Jun  8 19:46:59 KST 2022

# ansible-node02의 timezone
[vagrant@ansible-server ~]$ ssh vagrant@172.30.1.120
vagrant@172.30.1.120's password:
Last login: Wed Jun  8 19:45:46 2022 from 172.30.1.100

[vagrant@ansible-node02 ~]$ date
Wed Jun  8 19:57:56 KST 2022

 

 

앤서블 서버의 timezone 설정

# timezone 변경 전
[vagrant@ansible-server ~]$ date
Wed Jun  8 10:45:49 UTC 2022

[vagrant@ansible-server ~]$ sudo ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime

# timezone 변경 후
[vagrant@ansible-server ~]$ date
Wed Jun  8 19:50:08 KST 2022

 

 

728x90

+ Recent posts