在Ansible中添加变量列表时,如何获得一个相似值的跨度?例如“000-100” - 在一个Ansible主机文件中,这可以通过列举如“hostname- [a:v] .com”来完成。这个过程是否与变量列表中的类似?Ansible变量列表范围
我的用例是一次性提供oVirt中的许多虚拟机,而不必逐行列表。
---
- name: Create VM based on template
hosts: ovirt-engine
become: yes
become_method: sudo
vars:
- temp: '{{temp_fedora25}}'
- iname:
- db-aa
- db-ab
- db-ac
tasks:
- name: Giving Birth to lil Baby VM's
ovirt:
user: '{{ovirt_usr}}'
password: '{{ovirt_pass}}'
url: '{{engine_url}}'
instance_name: "{{item}}"
instance_nic: ovirtmgmt
resource_type: template
image: '{{temp}}'
zone: superblade-a
disk_alloc: preallocated
with_items: "{{iname}}"
是的,就在那里的文档......效果很好,当然还有一些调整我的情况。我想知道这些值是否可以作为注册变量重用?我用我的完整解决方案添加另一个答案只是为了彻底。 – arkitoure
用'set_fact'添加了一个例子。 –
超级...诀窍。我将不得不放大我的剧本来测试通过这些变量。 – arkitoure