针对单个主机运行Ansible playbook

时间:2016-02-11 06:22:18

标签: ansible

我正在使用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 进行。有没有办法做到这一点?

1 个答案:

答案 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?