diff --git a/proxmox.yml b/proxmox.yml new file mode 100644 index 0000000..f2cf5c2 --- /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 }}"