Greetings all!
I want to rack some of your brains and find out if my goal is possible.
I have a playbook for cloning VM’s with the proxmox_kvm community module, currently I loop through an extra var “{{ vm_name }}” that is split up if I include more than one hostname. This works fine, but it is sequential, and runtime is a few minutes. I started thinking about running my clones in parallel, after reading the docs I determined Job Slicing is the correct route to make this happen. However I may be misunderstanding how Slices work with extra vars, and maybe this isn’t possible with how I have my playbook currently written.
Is it possible to make a slice for each iteration of a loop based on my “{{ vm_name }}” extra var? If not, is there an alternative way to achieve this goal, a workflow perhaps?
---
- name: Clone VM's from template and configure with cloud-init
hosts: localhost
gather_facts: false
vars:
working_node: '{{ pve_node }}'
module_defaults:
proxmox_kvm:
api_user: '{{ lookup("env", "PROXMOX_USER") }}'
api_password: '{{ lookup("env", "PROXMOX_PASSWORD") }}'
api_host: '{{ lookup("env", "PROXMOX_HOST") }}'
tasks:
- name: Loop through vm_name
include_tasks: ../../pve/clone-template.yml
loop: '{{ vm_name.split(",") }}'
Thanks in advance and happy holidays!