ansible-role-proxmox_vm_tools/tasks/setup_vm.yml

86 lines
2.6 KiB
YAML

---
- name: VM "{{ pvmt_vm_name }}" a partir du modele "{{ pvmt_vm_template }}"
community.general.proxmox_kvm:
api_user : "{{ pvmt_api_user }}"
api_token_id: "{{ pvmt_api_token_id }}"
api_token_secret: "{{ pvmt_api_token_secret }}"
api_host : "{{ pvmt_api_host }}"
node : "{{ pvmt_node }}"
name : "{{ pvmt_vm_name }}"
clone: "{{ pvmt_vm_template }}"
newid: "{{ pvmt_vm_id }}"
storage: "{{ pvmt_vm_storage }}"
timeout: 300
tags: provision,test
register: creation
- name: Ajuste parametres de la VM "{{ pvmt_vm_name }}"
community.general.proxmox_kvm:
api_user : "{{ pvmt_api_user }}"
api_token_id: "{{ pvmt_api_token_id }}"
api_token_secret: "{{ pvmt_api_token_secret }}"
api_host : "{{ pvmt_api_host }}"
node : "{{ pvmt_node }}"
name : "{{ pvmt_vm_name }}"
update: yes
cores: "{{ pvmt_vm_cores }}"
sockets: "{{ pvmt_vm_sockets }}"
memory: "{{ pvmt_vm_memory }}"
onboot: yes
boot: c
bootdisk: scsi0
# cloud-init params
ciuser: "{{ pvmt_vm_ciuser }}"
sshkeys: "{{ pvmt_vm_sshkeys }}"
searchdomains: "{{ vars[pvmt_vm_network].searchdomain }}"
nameservers: "{{ vars[pvmt_vm_network].nameservers }}"
ipconfig:
ipconfig0: "ip={{ pvmt_vm_ip }}/{{ vars[pvmt_vm_network].netmask }},gw={{ vars[pvmt_vm_network].gateway }}"
tags: provision,test
- name: Ajuste le tag vlan de la VM "{{ pvmt_vm_name }}"
community.general.proxmox_nic:
api_user : "{{ pvmt_api_user }}"
api_token_id: "{{ pvmt_api_token_id }}"
api_token_secret: "{{ pvmt_api_token_secret }}"
api_host : "{{ pvmt_api_host }}"
name : "{{ pvmt_vm_name }}"
interface: net0
state: present
bridge: "{{ vars[pvmt_vm_network].bridge }}"
firewall: yes
model: virtio
tag: "{{ vars[pvmt_vm_network].vlanid }}"
tags: provision,test
- name: Demarre la VM "{{ pvmt_vm_name }}"
community.general.proxmox_kvm:
api_user : "{{ pvmt_api_user }}"
api_token_id: "{{ pvmt_api_token_id }}"
api_token_secret: "{{ pvmt_api_token_secret }}"
api_host : "{{ pvmt_api_host }}"
node : "{{ pvmt_node }}"
name : "{{ pvmt_vm_name }}"
state : started
timeout: 300
tags: provision,test
- local_action: wait_for port=22 host="{{ pvmt_vm_ip }}" search_regex=OpenSSH
- name: Agrandit le disque
include_tasks: resize_disk.yml
with_items:
- "{{ pvmt_vm_disk }}"
- name: Definit logical volume
lvol:
vg: "{{ item.vg }}"
lv: "{{ item.name }}"
size: "{{ item.size }}"
resizefs: true
delegate_to: "{{ pvmt_vm_ip }}"
with_items:
- "{{ pvmt_vm_lvm_volumes }}"