- name: Deploys VM based on local debian image hosts: localhost gather_facts: true become: true vars: # debian_image: "/var/lib/libvirt/images" # vm: "{{ item }}" ssh_pub_key: "/home/pierre/.ssh/id_rsa.pub" root: root os: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-generic-amd64.qcow2 checksum: "" xml_template: debian_template machines: - name: control_test ip: 192.168.122.80 # - name: DC01_test # ip: 192.168.122.81 # - name: DC02_test # ip: 192.168.122.82 tasks: - name: Is os image present ansible.builtin.fail: msg: You did not provide an image to build from when: os == "" - name: Is XML template present ansible.builtin.stat: path: "create_kvm/templates/{{ xml_template }}.xml.j2" register: xml_present - name: XML not present ansible.builtin.fail: msg: You did not provide a valid xml template when: not (xml_present.stat.exists) - name: KVM Provision role ansible.builtin.include_role: name: create_kvm vars: # libvirt_pool_dir: "{{ pool_dir }}" os_image: "{{ os }}" template_file: "{{ xml_template }}.xml.j2" vm_name: "{{ item.name }}" ssh_key: "{{ ssh_pub_key }}" root_pwd: "{{ root }}" loop: "{{ machines }}" - name: Set up the wanted IP ansible.builtin.include_tasks: file: setup_vm_ip.yml loop: "{{ machines }}" # for control,dc01,dc02 # 192.168.122.70 + 1 # /var/lib/libvirt/images/debian11-2-1-clone.qcow2