Ansible:每个角色只能在一个主机组上运行
目标是针对所有主机运行此游戏,但每个角色应仅按以下方式运行:Ansible:每个角色只能在一个主机组上运行,ansible,Ansible,目标是针对所有主机运行此游戏,但每个角色应仅按以下方式运行: 用于Web服务器的lab01-4 数据库用lab01-5 lab01-6用于其他 我们在不同的组中有几个主机: [webservers] rhel-01 [databases] rhel-02 [others] rhel-03 我们在一个带有标签的游戏中扮演多个角色: - hosts: all become: yes roles: - { role: 'lab01-4', tags: 'webservers',
- 用于Web服务器的lab01-4
- 数据库用lab01-5
- lab01-6用于其他
[webservers]
rhel-01
[databases]
rhel-02
[others]
rhel-03
我们在一个带有标签的游戏中扮演多个角色:
- hosts: all
become: yes
roles:
- { role: 'lab01-4', tags: 'webservers', hosts: 'webservers' }
- { role: 'lab01-5', tags: 'databases', hosts: 'databases' }
- { role: 'lab01-6', tags: 'others', hosts: 'others' }
我发现role()中没有关键字hosts。
Ansible忽略关键字hosts并对所有主机无错误地开始播放
有什么建议吗
Q:“每个角色只能按以下方式运行”
答:例如,按如下方式运行每个剧本
- hosts: webservers
become: yes
roles:
- lab01-4
- hosts: databases
become: yes
roles:
- lab01-5
- hosts: others
become: yes
roles:
- lab01-6
Q:“每个角色只能按以下方式运行”
答:例如,按如下方式运行每个剧本
- hosts: webservers
become: yes
roles:
- lab01-4
- hosts: databases
become: yes
roles:
- lab01-5
- hosts: others
become: yes
roles:
- lab01-6