mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-25 17:12:50 +00:00
* fix: misspelling Signed-off-by: joyceliu <joyceliu@yunify.com> * fix: misspelling Signed-off-by: joyceliu <joyceliu@yunify.com> * fix: misspelling Signed-off-by: joyceliu <joyceliu@yunify.com> * fix: misspelling Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: user go-template instance pongo2-template Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: not set incorrect Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: more beautiful progress bar Signed-off-by: joyceliu <joyceliu@yunify.com> --------- Signed-off-by: joyceliu <joyceliu@yunify.com> Co-authored-by: joyceliu <joyceliu@yunify.com>
40 lines
1.4 KiB
YAML
40 lines
1.4 KiB
YAML
---
|
|
- name: Configure ntp server
|
|
command: |
|
|
chronyConfigFile={{ if or (.os.release.ID | eq "ubuntu") (.os.release.ID_LIKE | eq "debian") }}"/etc/chrony/chrony.conf"{{ else }}"/etc/chrony.conf"{{ end }}
|
|
# clear old server
|
|
sed -i '/^server/d' $chronyConfigFile
|
|
# disable pool
|
|
sed -i 's/^pool /#pool /g' $chronyConfigFile
|
|
# delete allow
|
|
sed -i '/^allow/d' $chronyConfigFile
|
|
# allow client
|
|
echo "allow 0.0.0.0/0" >> $chronyConfigFile
|
|
# delete local
|
|
sed -i '/^local/d' $chronyConfigFile
|
|
# add local
|
|
echo "local stratum 10" >> $chronyConfigFile
|
|
# add server
|
|
{{- range $server := .ntp_servers -}}
|
|
{{- range $.inventory_hosts -}}
|
|
{{- if eq .inventory_name $server -}}
|
|
{{- $server = .internal_ipv4 -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
grep -q '^server {{ $server }} iburst' $chronyConfigFile || sed '1a server {{ $server }} iburst' -i $chronyConfigFile
|
|
{{- end -}}
|
|
|
|
- name: Set timezone
|
|
command: |
|
|
timedatectl set-timezone {{ .timezone }}
|
|
timedatectl set-ntp true
|
|
when: or (.ntp_servers | len | lt 0) (.timezone | ne "")
|
|
|
|
- name: Restart ntp server
|
|
command: |
|
|
{{- if or (.os.release.ID | eq "ubuntu") (.os.release.ID_LIKE | eq "debian") }}
|
|
systemctl restart chrony.service
|
|
{{- end }}
|
|
systemctl restart chronyd.service
|
|
when: or (.ntp_servers | len | lt 0) (.timezone | ne "")
|