diff --git a/inventory/hosts b/inventory/hosts index 774a118..f04d7c1 100644 --- a/inventory/hosts +++ b/inventory/hosts @@ -28,4 +28,4 @@ linse.freifunk-mwu.de # ext. DNS-master #pudding.freifunk-mwu.de # [test-vms] -local-test-vm.ffmwu.local +local-test-vm.ffmwu.local ansible_host=192.168.137.7 diff --git a/loctevm-reset-net.inc.yml b/loctevm-reset-net.inc.yml new file mode 100644 index 0000000..395b832 --- /dev/null +++ b/loctevm-reset-net.inc.yml @@ -0,0 +1,29 @@ +--- + +- name: find already defined local Vnets + virt_net: command=list_nets + delegate_to: 127.0.0.1 # local action + register: nets + +- debug: var=nets + +- block: + - name: construct Vnet xml file + template: + src: templates/loctenet.xml + dest: "{{ vm_path }}/loctenet.xml" + delegate_to: 127.0.0.1 # local action + + - name: define Vnet + virt_net: + command: define + name: "ffmwu" + xml: "{{ lookup('file',vm_path ~ '/loctenet.xml') }}" + delegate_to: 127.0.0.1 # local action + + when: not "ffmwu" in nets.list_nets + # block end + +- name: exnsure activ Vnet ffmwu + virt_net: name=ffmwu state=active + delegate_to: 127.0.0.1 # local action diff --git a/loctevm-reset-prereq.inc.yml b/loctevm-reset-prereq.inc.yml index 2e90e57..75bf629 100644 --- a/loctevm-reset-prereq.inc.yml +++ b/loctevm-reset-prereq.inc.yml @@ -3,8 +3,9 @@ # FIXME: do nothing for now # FIXME: how to learn about IP of VM ??? -#- name: prepare escalation -# set_fact: ansible_become_pass=bloed -# -#- name: ensure admin user -# user: comment=FFMWU Administrator name=admin state=present +- name: prepare escalation + set_fact: ansible_become_pass=bloed ansible_ssh_pass=bloed + +- name: ensure admin user + user: comment="FFMWU Administrator" name=admin shell=/bin/bash state=present + become: True diff --git a/loctevm-reset.yml b/loctevm-reset.yml index 6cf971e..0ab43af 100755 --- a/loctevm-reset.yml +++ b/loctevm-reset.yml @@ -28,6 +28,9 @@ - name: get and prepare debian image file include: loctevm-reset-iso.inc.yml + - name: define Vnd activate Vnet (if not already) + include: loctevm-reset-net.inc.yml + - name: define VM (if not already) include: loctevm-reset-vm.inc.yml @@ -37,9 +40,15 @@ name: "{{ inventory_hostname }}" 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=300 + delegate_to: 127.0.0.1 # local action + - hosts: test-vms remote_user: hein + gather_facts: False # become: True + tasks: - name: prepare VM (if not already) include: loctevm-reset-prereq.inc.yml diff --git a/templates/loctenet.xml b/templates/loctenet.xml new file mode 100644 index 0000000..fc15265 --- /dev/null +++ b/templates/loctenet.xml @@ -0,0 +1,14 @@ + + ffmwu + + + + + + + + + + + diff --git a/templates/loctevm.xml b/templates/loctevm.xml index 0a4e19e..459fc4f 100644 --- a/templates/loctevm.xml +++ b/templates/loctevm.xml @@ -40,8 +40,9 @@ - + +