如何仅在群组中的第一台主机上运行剧本?
我期待这样的事情:
---
- name: playbook that only run on first host in the group
hosts: "{{ groups[group_name] | first }}"
tasks:
- debug:
msg: "on {{ inventory_hostname }}"
但这不起作用,给出错误:
'组'未定义
我怎样才能让它发挥作用?
答案 0 :(得分:13)