使用Ansible部署chrony服务

1 chrony auto restart

[Unit]

Description=NTP client/server

Documentation=man:chronyd(8) man:chrony.conf(5)

After=ntpdate.service sntp.service ntpd.service

Conflicts=ntpd.service systemd-timesyncd.service

ConditionCapability=CAP_SYS_TIME

[Service]

Type=forking

PIDFile=/var/run/chrony/chronyd.pid

EnvironmentFile=-/etc/sysconfig/chronyd

ExecStart=/usr/sbin/chronyd $OPTIONS

ExecStartPost=/usr/libexec/chrony-helper update-daemon

PrivateTmp=yes

ProtectHome=yes

ProtectSystem=full

Restart=always

[Install]

WantedBy=multi-user.target

2 deploy chrony

- name: Copy chrony conf file to remote node

  become: true

  ansible.builtin.copy:

    src: roles/ntp_chrony/conf/chrony.conf

    dest: /etc/chrony.conf

    owner: root

    group: root

    mode: '0644'

    backup: true

  tags:

    - copy_chrony_conf

- name: Copy chrony service file to remote node

  become: true

  ansible.builtin.copy:

    src: roles/ntp_chrony/conf/chrony.service

    dest: /usr/lib/systemd/system/chronyd.service

    owner: root

    group: root

    mode: '0644'

    backup: true

  tags:

      - copy_chrony_service

- name: Stop and mask ntpd service if active

  become: true

  ansible.builtin.systemd:

    name: ntpd

    state: stopped

    masked: true

    enabled: false

  tags:

    - stop_ntpd_service

- name: Start chrony service

  become: true

  ansible.builtin.systemd:

    name: chronyd

    state: started

    daemon_reload: true

    enabled: true

  tags:

    - start_chronyd_service

- name: Restart cloudera-scm-agent service

  become: true

  ansible.builtin.systemd:

    name: cloudera-scm-agent

    state: restarted

  tags:

    - restart_scm_agent

3 built in modules

file

文件或者目录的处理

ansible.builtin.file module – Manage files and file properties — Ansible Documentation

copy 

本地节点分发文件到remote节点

ansible.builtin.copy module – Copy files to remote locations — Ansible Documentation

fetch 

从remote节点拉取文件到本地节点

ansible.builtin.fetch module – Fetch files from remote nodes — Ansible Documentation

template

修改有变量的配置文件,并分发

ansible.builtin.template module – Template a file out to a target host — Ansible Documentation

systemd

centos 7 专有systemctl管理,服务器自启动、状态等

ansible.builtin.systemd module – Manage systemd units — Ansible Documentation

service

通用的服务启动、停止,状态监控等

ansible.builtin.service module – Manage services — Ansible Documentation


https://github.com/prometheus/node_exporter/blob/master/docs/TIME.md

Node Exporter 简介_node_exporter_富士康质检员张全蛋的博客-CSDN博客

https://github.com/prometheus/node_exporter

Set the time for your Linux instance - Amazon Elastic Compute Cloud

再见 NTP,是时候拥抱下一代时间同步服务 Chrony 了 - 奇妙的 Linux 世界

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值