我正在使用hosts
文件进行静态广告资源:
server1 ansible_ssh_host=1.1.1.1
server2 ansible_ssh_host=1.1.1.2
server3 ansible_ssh_host=1.1.1.3
[group1]
server1
server2
我有一个像这样的剧本example.yml
:
---
- name: base setup
become: true
hosts:
- group1
roles:
- base
我想使用ansible-playbook
进行example.yml
测试,而仅针对主机 server1 进行。有没有办法做到这一点?
答案 0 :(得分:9)
好吧,我写完了这个问题,然后我的SO搜索功能得到了改进。以下是一些答案:
使用-l SUBSET
:
Running an Ansible Playbook on a particular group of servers
使用-i "hostname,"
:
How do I narrow down scope when running an ansible playbook?