45 lines
1.2 KiB
YAML
Executable file
45 lines
1.2 KiB
YAML
Executable file
#!/usr/bin/ansible-playbook
|
|
---
|
|
# localhost (aka 127.0.0.1) is the hypervisor (hard-coded)
|
|
|
|
- hosts: test-vms
|
|
#- hosts: local-test-vm.ffmwu.local
|
|
gather_facts: False
|
|
# remote_user: root
|
|
|
|
vars:
|
|
- vm_path: "{{ lookup('env','HOME') }}/tmp/ffmwu-loctevm"
|
|
|
|
tasks:
|
|
- name: ensure VM dir and vm image dir
|
|
file: path={{ vm_path }} state=directory mode=0755
|
|
delegate_to: 127.0.0.1 # local action
|
|
|
|
- name: ensure image file # FIXME: change to rm + recreate
|
|
command: fallocate -l 10G {{ vm_path }}/loctevm.img # 15G? size?
|
|
args:
|
|
creates: "{{ vm_path }}/loctevm.img"
|
|
delegate_to: 127.0.0.1 # local action
|
|
|
|
- name: correct access rights of image file
|
|
file: mode=0666 path={{ vm_path }}/loctevm.img state=file
|
|
delegate_to: 127.0.0.1 # local action
|
|
|
|
- name: get and prepare debian image file
|
|
include: loctevm-reset-iso.inc.yml
|
|
|
|
- name: define VM (if not already)
|
|
include: loctevm-reset-vm.inc.yml
|
|
|
|
- name: create VM - should start OS installation
|
|
virt:
|
|
state: running
|
|
name: "{{ inventory_hostname }}"
|
|
delegate_to: 127.0.0.1 # local action
|
|
|
|
- hosts: test-vms
|
|
remote_user: hein
|
|
# become: True
|
|
|
|
- name: prepare VM (if not already)
|
|
include: loctevm-reset-prereq.inc.yml
|