--- # tasks file for proxmox_deploy - name: Cloning virtual machine from "{{ VM_template }}" with name "{{ VM_name }}" proxmox_kvm: api_user : root@pam api_password: "{{ PV_password }}" api_host : px2 name : "{{ VM_name }}-{{ item }}" node : px2 vmid: 9000 clone: "{{ VM_template }}" timeout: 300 tags: provission,test loop: "{{ range(0, 3, 1)|list }}" #- name: starting new Virtual Machine to change IPv4 configuration, it is necessary # proxmox_kvm: # api_user : root@pam # api_password: “{{ PV_password }}” # api_host : “{{ default_proxmox_node }}” # name : “{{ VM_name }}” # node : “{{ default_proxmox_node }}” # state : started # timeout: 300 # when: ‘“{{ VM_INCREASE_DISK }}” != “0”’ # register: wait # tags: provission - name: copy ssh public key to host copy: src: /root/.ssh/id_rsa.pub dest: /root/.ssh/root_c200.pub owner: root group: root mode: 0600 - name: set ssh keys for Virtual Machine shell: A=$(qm list |grep "{{ VM_name }}-{{ item }}" | awk '{print $1}'); qm set $A --sshkey /root/.ssh/root_c200.pub --ciuser root loop: "{{ range(0, 3, 1)|list }}" tags: provission - name: Loading set up for Virtual Machine. Assigning IP for Virtual Machine shell: A=$(qm list |grep "{{ VM_name }}-{{ item }}" | awk '{print $1}'); qm set $A --ipconfig0 'ip=192.168.0.16{{ item }}/24,gw=192.168.0.253' --nameserver '192.168.0.253' --memory 2048 --cores 2 loop: "{{ range(0, 3, 1)|list }}" tags: provission - name: Regenerate cloudinit shell: A=$(qm list |grep "{{ VM_name }}-{{ item }}" | awk '{print $1}'); qm set $A --ide2 local-lvm:cloudinit loop: "{{ range(0, 3, 1)|list }}" tags: provission - name: starting new Virtual Machine in current proxmox node proxmox_kvm: api_user : root@pam api_password: "{{ PV_password }}" api_host : px2 name : "{{ VM_name }}-{{ item }}" node : px2 state : started timeout: 300 tags: provission loop: "{{ range(0, 3, 1)|list }}"