Integrated proxmox
This commit is contained in:
52
playbooks/kvm.yml
Normal file
52
playbooks/kvm.yml
Normal file
@@ -0,0 +1,52 @@
|
||||
---
|
||||
|
||||
- name: Create machine and set up ip
|
||||
hosts: all
|
||||
user: root
|
||||
gather_facts: no
|
||||
serial: 1
|
||||
tasks:
|
||||
- name: Clone VM
|
||||
delegate_to: localhost
|
||||
proxmox_kvm:
|
||||
api_user: "{{ proxmox_user }}"
|
||||
api_password: "{{ proxmox_password }}"
|
||||
api_host: "{{ proxmox_host }}"
|
||||
clone : "{{ ubuntu_template_vm_name }}"
|
||||
name : '{{ inventory_hostname }}'
|
||||
node : 'rack2'
|
||||
storage : 'SSD1'
|
||||
format : 'qcow2'
|
||||
timeout : 3000
|
||||
register: cloned
|
||||
|
||||
- name: Wait 10 seconds for proxmox to register the new node
|
||||
wait_for: timeout=10
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Start VM
|
||||
delegate_to: localhost
|
||||
proxmox_kvm:
|
||||
api_user: "{{ proxmox_user }}"
|
||||
api_password: "{{ proxmox_password }}"
|
||||
api_host: "{{ proxmox_host }}"
|
||||
name: '{{ inventory_hostname }}'
|
||||
node: rack2
|
||||
state: started
|
||||
when: cloned.changed
|
||||
|
||||
- name: Wait for connection
|
||||
delegate_to: 10.0.0.211
|
||||
wait_for_connection:
|
||||
delay: 60
|
||||
timeout: 180
|
||||
when: cloned.changed
|
||||
|
||||
- include: ../roles/configure-interfaces/tasks/main.yml
|
||||
delegate_to: 10.0.0.211
|
||||
when: cloned.changed
|
||||
|
||||
- name: wait for connection
|
||||
wait_for_connection:
|
||||
delay: 60
|
||||
timeout: 180
|
||||
Reference in New Issue
Block a user