安装系统角色
yum install -y rhel-system-roles
进入安装系统角色的位置
[root@ansible roles]# pwd
/usr/share/ansible/roles
时区同步
[root@ansible ~]# tree projects/roles/
projects/roles/
├── ansible.cfg
├── inventory
└── main.yml
[root@ansible roles]# ls
ansible.cfg inventory main.yml
[root@ansible roles]# cat inventory
[web]
httpd
[root@ansible roles]# cat main.yml
---
- name: Time synch for httpd
hosts: httpd
vars:
timesync_ntp_servers:
- hostname: runtime.com
iburst: yes
host_timezone: Asia/Shanghai
roles:
- rhel-system-roles.timesync
tasks:
- name: set timezone
timezone:
name: "{
{ host_timezone }}"
运行且查看结果
ansible-playbook main.yml
[root@httpd ~]# cat /etc/chrony.conf
# Ansible managed
server runtime.com iburst
# Allow the syste