我有两个文件
库存.yaml:
servers:
hosts:
nas:
ansible_host: 10.10.10.27
router:
ansible_host: 10.10.10.1
和 playbook.yaml
- name: pylonl playbook
hosts: all
tasks:
-name: Ping all hosts
ansible.builtin.ping:
运行ansible -i inventory.yaml all -m ping
有效,但运行ansible -i inventory.yaml playbook.yaml
返回:
[WARNING]: Could not match supplied host pattern, ignoring: playbook.yaml
[WARNING]: No hosts matched, nothing to do
我错过了什么?
答案1
使用ansible-playbook
而不是bin/ansible
“临时”来运行剧本。
ansible-playbook -i inventory.yaml playbook.yaml