Anisble タイムサーバchronyを設定するサンプル

環境
Anisble
CentOS 8

操作方法
1./etc/chrony.confの設定変更内容を確認する

server xxx iburst
server xxx iburst
stratumweight 0
driftfile /var/lib/chrony/drift
rtcsync
makestep 10 3
bindcmdaddress 127.0.0.1
bindcmdaddress ::1
keyfile /etc/chrony.keys
commandkey 1
generatecommandkey
noclientlog
logchange 0.5
logdir /var/log/chrony

2.設定内容を下記ファイルにコピーする
/anisble/data/setup/chrony.conf.j2

3.chrony.ymlを作成する

---
- hosts: all
  tasks:
  - name: make sure chronyd is installed
    yum:
     name: chrony
     state: latest
     update_cache: yes

  - name: deploy chrony.conf template
    template:
     src: /anisble/data/setup/chrony.conf.j2
     dest: /etc/chrony.conf
     owner: root
     group: root
     mode: 0644
     backup: yes

  - name: Restart chronyd
    service:
      name: chronyd
      state: restarted

参考
https://www.redhat.com/sysadmin/ansible-chrony-daemon

Ansible

Posted by arkgame