-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvm-make-snapshots.yml
52 lines (46 loc) · 1.45 KB
/
vm-make-snapshots.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# file: vm-make-snapshots.yml
#
# prerequisites:
# $ sudo yum --enablerepo=rhel-7-server-rhv-4.1-rpms install python-ovirt-engine-sdk4
#
# vm definitions / assumptions:
# see home.lab/ocp-cns-vars.yml
#
# execution:
# $ ansible-playbook vm-make-snapshots.yml --ask-vault-pass -e 'vmVars=home.lab/ocp-cns-vars.yml' -e 'snapDescription="Before a big change"'
# $ ansible-playbook vm-make-snapshots.yml --ask-vault-pass -e 'vmVars=home.lab/ocp-cns-vars.yml' -e 'snapState=restore '-e 'snapDescription="Before a big change"'
---
- hosts: localhost
#- hosts: rhvm
gather_facts: yes
vars:
snapState: present
vars_files:
- "{{ ansible_domain }}/rhvm-vault.yml"
tasks:
- name: Load VM vars
include_vars: "{{ vmVars }}"
- name: Login to RHV
ovirt_auth:
url: "{{ rhvurl }}"
insecure: yes
username: "{{ rhvuser }}"
password: "{{ rhvpass }}"
- name: Create snapshots
ovirt_snapshot:
auth: "{{ ovirt_auth }}"
vm_name: "{{ item.key }}"
state: "{{ snapState }}"
description: "{{ snapDescription }}"
wait: false
with_dict: "{{ vms }}" # See home.lab/ocp-cns-vars.yml
- name: Startup the VMs
ovirt_vm:
auth: "{{ ovirt_auth }}"
name: "{{ item.key }}"
state: running
with_dict: "{{ vms }}" # See home.lab/ocp-cns-vars.yml
- name: Cleanup RHV auth token
ovirt_auth:
ovirt_auth: "{{ ovirt_auth }}"
state: absent