From 0c8763c702bdab87493fd00ee80807baf1a61238 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Fri, 3 May 2019 13:06:26 +0200 Subject: [PATCH 1/2] Create VM with Proxmox API --- proxmox.yml | 39 +++++++++++++++++++++++++++++++++ roles/proxmox-vm/tasks/main.yml | 17 ++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 proxmox.yml create mode 100644 roles/proxmox-vm/tasks/main.yml diff --git a/proxmox.yml b/proxmox.yml new file mode 100644 index 0000000..670db43 --- /dev/null +++ b/proxmox.yml @@ -0,0 +1,39 @@ +--- +# This is a special playbook to create a new VM ! +- hosts: pad.adm.auro.re # Host with python-proxmoxer and python-requests + become: false # We do not need root as we use Proxmox API + + vars: + vm_definitions: + - name: ldap-replica-pacaterie + virtu: mordred + cores: 2 # 2 mimimum, 10 maximum + memory: 1024 # M + disksize: 16 # G + installiso: debian-buster-DI-rc1-amd64-netinst.iso + - name: dhcp-pacaterie + virtu: mordred + cores: 2 # 2 mimimum, 10 maximum + memory: 1024 # M + disksize: 16 # G + installiso: debian-buster-DI-rc1-amd64-netinst.iso + - name: dns-pacaterie + virtu: mordred + cores: 2 # 2 mimimum, 10 maximum + memory: 1024 # M + disksize: 16 # G + installiso: debian-buster-DI-rc1-amd64-netinst.iso + - name: prometheus-pacaterie + virtu: mordred + cores: 2 # 2 mimimum, 10 maximum + memory: 1024 # M + disksize: 16 # G + installiso: debian-buster-DI-rc1-amd64-netinst.iso + + vars_prompt: + - name: "password" + prompt: "Enter LDAP password for your user" + private: yes + + roles: + - proxmox-vm diff --git a/roles/proxmox-vm/tasks/main.yml b/roles/proxmox-vm/tasks/main.yml new file mode 100644 index 0000000..be94272 --- /dev/null +++ b/roles/proxmox-vm/tasks/main.yml @@ -0,0 +1,17 @@ +--- +- name: Define a virtual machine in Proxmox + proxmox_kvm: + api_user: "{{ ansible_user_id }}@pam" + api_password: "{{ password }}" + api_host: "{{ item.virtu }}.adm.auro.re" + name: "{{ item.name }}" + node: "{{ item.virtu }}" + scsihw: virtio-scsi-pci + scsi: '{"scsi0":"{{ item.virtu }}:{{ item.disksize }},format=raw"}' + sata: '{"sata0":"local:iso/{{ item.installiso }},media=cdrom"}' + net: '{"net0":"virtio,bridge=vmbr2"}' # Adm only by default + cores: "{{ item.cores }}" + memory: "{{ item.memory }}" + balloon: "{{ item.memory // 2 }}" + bios: seabios # Ansible module doesn't support UEFI boot disk + loop: "{{ vm_definitions }}" From d761c51c6f7de19ad8cfb6676bde35b905527397 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Fri, 3 May 2019 13:11:39 +0200 Subject: [PATCH 2/2] Fix identation --- proxmox.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proxmox.yml b/proxmox.yml index 670db43..f2cf5c2 100644 --- a/proxmox.yml +++ b/proxmox.yml @@ -31,9 +31,9 @@ installiso: debian-buster-DI-rc1-amd64-netinst.iso vars_prompt: - - name: "password" - prompt: "Enter LDAP password for your user" - private: yes + - name: "password" + prompt: "Enter LDAP password for your user" + private: yes roles: - proxmox-vm