16.5.1 创建及使用角色

ansible角色功能类似于编程中的封装技术——将具体的功能封装起来

使用角色之前先安装软件包

yum install rhel-system-roles

查看内置角色

ansible-galaxy list

以rhel-system-roles.timesync (配置网络时间协议)为例

可以拷贝下面的模版文件用来修改使用

/usr/share/doc/rhel-system-roles-1.21.2/timesync/example-single-pool-playbook.yml

---
- hosts: all
  vars:
    timesync_ntp_servers:
      - hostname: pool.ntp.org
        iburst: yes
  roles:
    - rhel-system-roles.timesync

 

posted @ 2024-06-13 20:38  ~技术小白  阅读(5)  评论(0)    收藏  举报