diff --git a/creer-une-vm-avec-cloud-init.yaml b/creer-une-vm-avec-cloud-init.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0713241c6f357f0c4cf96c6ce16ba7e48403c736 --- /dev/null +++ b/creer-une-vm-avec-cloud-init.yaml @@ -0,0 +1,34 @@ +- name: "Create VM from cloud images" + hosts: <host-proxmox> + vars: + id: 1000 + vm_name: "template-u2304" + vm_core: 2 + vm_ram: 512 + vm_bridge: vmbr0 + cloudimg_path: "/path/to/lunar-server-cloudimg-amd64.img" + disk: "local" + user: ansible + sshkey_path: "/path/to/ssh/public_key>" + ipconfig0: "ip=<ip-address>/<cidr>,gw=<ip-gateway>" + tasks: + - name: Create VM + command: qm create {{ id }} --name {{ vm_name }} --cores {{ vm_core }} --memory {{ vm_ram }} --net0 virtio,bridge={{ vm_bridge }},firewall=1 --scsihw virtio-scsi-pci --agent 1 + + - name: Import image + command: qm set {{ id }} --scsi0 {{ disk }}:0,import-from={{ cloudimg_path }} + + - name: Set Boot Order + command: qm set {{ id }} --boot order=scsi0 + + - name: Add Cloudinit Disk + command: qm set {{ id }} --ide2 {{ disk }}:cloudinit + + - name: Create Serial Port + command: qm set {{ id }} --serial0 socket --vga serial0 + + - name: Configure Cloud-init - User & Network + shell: | + qm set {{ id }} --ciuser {{ user }} + qm set {{ id }} --sshkeys {{ sshkey_path }} + qm set {{ id }} --ipconfig0 {{ ipconfig0 }}