better name; small fixes

This commit is contained in:
ka-ba 2016-08-31 15:51:14 +02:00
parent 8347b2a582
commit e301d42066
5 changed files with 25 additions and 15 deletions

View file

@ -12,10 +12,6 @@
dest: "{{ vm_path }}/loctevm.xml"
delegate_to: 127.0.0.1 # local action
- name: ensure absence of outdated local known-hosts entry
known_hosts: host={{ansible_host}} state=absent
delegate_to: 127.0.0.1 # local action
- name: define VM
virt:
command: define
@ -23,11 +19,5 @@
xml: "{{ lookup('file',vm_path ~ '/loctevm.xml') }}"
delegate_to: 127.0.0.1 # local action
- name: do dummy connect to ensure new local known host entry
command: ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no hein@{{ansible_host}} true
delegate_to: 127.0.0.1 # local action
changed_when: False
failed_when: False
when: not inventory_hostname in vms.list_vms
# block end

View file

@ -15,6 +15,11 @@
file: path={{ vm_path }} state=directory mode=0755
delegate_to: 127.0.0.1 # local action
- name: remove old image file when asked to reset VM
file: path={{ vm_path }}/loctevm.img state=absent
when: vm_reset|default(False)
delegate_to: 127.0.0.1 # local action
- name: ensure image file # FIXME: change to rm + recreate
command: fallocate -l 5G {{ vm_path }}/loctevm.img # 15G? size?
args:
@ -26,24 +31,39 @@
delegate_to: 127.0.0.1 # local action
- name: get and prepare debian image file
include: loctevm-reset-iso.inc.yml
include: loctevm-provide-iso.inc.yml
- name: define Vnd activate Vnet (if not already)
include: loctevm-reset-net.inc.yml
include: loctevm-provide-net.inc.yml
- name: define VM (if not already)
include: loctevm-reset-vm.inc.yml
include: loctevm-provide-vm.inc.yml
- name: create VM - should start OS installation
- name: create VM - should start OS installation - might take looong time
virt:
state: running
name: "{{ inventory_hostname }}"
register: virt_run
delegate_to: 127.0.0.1 # local action
- name: wait for port 80 to appear (after reboot after OS installation)
wait_for: host={{ansible_host}} port=80 state=started timeout=2500
delegate_to: 127.0.0.1 # local action
- block:
- name: ensure absence of outdated local known-hosts entry
known_hosts: host={{ansible_host}} state=absent
delegate_to: 127.0.0.1 # local action
- name: do dummy connect to ensure new local known host entry
command: ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no hein@{{ansible_host}} true
delegate_to: 127.0.0.1 # local action
changed_when: False
failed_when: False
when: virt_run.changed
# block end
- hosts: test-vms
remote_user: hein
gather_facts: False
@ -51,4 +71,4 @@
tasks:
- name: prepare VM (if not already)
include: loctevm-reset-prereq.inc.yml
include: loctevm-provide-prereq.inc.yml