From 1d99cf836c8427e07da80de9cf576da8343462a0 Mon Sep 17 00:00:00 2001 From: Nicolas <nicolas@bejean.fr> Date: Sun, 25 Jun 2023 09:33:28 +0000 Subject: [PATCH] feat: add proxmox playbook --- creer-une-vm-avec-cloud-init.yaml | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 creer-une-vm-avec-cloud-init.yaml diff --git a/creer-une-vm-avec-cloud-init.yaml b/creer-une-vm-avec-cloud-init.yaml new file mode 100644 index 0000000..0713241 --- /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 }} -- GitLab