4
如何才能在組中的第一臺主機上運行劇本?如何讓Ansible playbook在羣組中的第一臺主機上運行?
我期待這樣的事情:
---
- name: playbook that only run on first host in the group
hosts: "{{ groups[group_name] | first }}"
tasks:
- debug:
msg: "on {{ inventory_hostname }}"
但是,這並不工作,給人的錯誤:
'groups' is undefined
我怎樣才能使它發揮作用?