1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| [root@localhost ~]
yum -y instal ntpdate
timedatectl
timedatectl set-timezone Asia/Shanghai
timedatectl
ntpdate ntp.aliyun.com echo "对时成功,当前时间为:" date +'%F %H:%M:%S'
[root@k8s-master ~] [all] 10.100.40.252 10.100.40.253 10.100.40.254
[root@k8s-master ~] --- - name: 更新 time hosts: all become: yes tasks: - name: copy time script to remote host copy: src: /root/check_time.sh dest: /root/check_time.sh owner: root group: root mode: 0755
- name: execute time script shell: bash /root/check_time.sh args: chdir: /root
ansible-playbook -i /root/time time.yaml
|