【发布时间】:2023-01-26 23:40:10
【问题描述】:
我有以下 Ansible 主机文件:
# Contains the host mappings
[master]
m1.my-host.com ansible_host=192.168.0.100
[node]
n1.my-host.com ansible_host=192.168.0.102
n2.my-host.com ansible_host=192.168.0.103
[k3s_cluster:children]
master
node
[all:vars]
ansible_python_interpreter=/usr/bin/python3
在我的剧本中,我说我需要这样的有序执行:
---
- name: Setup hostname, users and groups
hosts: all
order: sorted
gather_facts: true
remote_user: myuser
become: yes
roles:
- {role: common, tags: ['host', 'system']}
但是当我运行它时,我会看到以下内容:
TASK [Gathering Facts] **********************************************************************************************************************************************************************************************
ok: [n1.my-host.com]
ok: [n2.my-host.com]
ok: [m1.my-host.com]
我宁愿期望它是 m1、n1,然后是 n2。有没有关于为什么不遵守排序顺序的想法?
【问题讨论】: