Sicherstellen, dass vm läuft und Netzwerk oben ist bevor die ip-Adresse der vm gelesen wird
This commit is contained in:
parent
7506c306b9
commit
87c997cb5a
|
@ -1,18 +1,30 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
|
- name: Ensure VM is running, otherwise arp based retrieval of ipv4 address will fail
|
||||||
|
community.libvirt.virt:
|
||||||
|
name: "{{ vm_name }}"
|
||||||
|
state: running
|
||||||
|
|
||||||
|
# Starten der vm reicht nicht, das Netzwerk muss auch oben sein um per arp auf die ipv4-Adresse zu kommen
|
||||||
- name: Retrieve ipv4-address for resolution in /etc/hosts on wirt machine
|
- name: Retrieve ipv4-address for resolution in /etc/hosts on wirt machine
|
||||||
shell: /home/core/Scripte/vhost_getIPv4 "{{ vm_name }}"
|
shell: /home/core/Scripte/vhost_getIPv4 "{{ vm_name }}"
|
||||||
register: ipv4
|
register: ipv4
|
||||||
|
until: ipv4["stdout"] | length > 0
|
||||||
|
retries: 15
|
||||||
|
delay: 2
|
||||||
|
changed_when: "False"
|
||||||
|
|
||||||
- name: Write vmname and ipv4-address for resolution to /etc/hosts on wirt machine
|
- name: Debug ipv4-address for resolution to /etc/hosts on wirt machine
|
||||||
debug: msg={{ ipv4["stdout"] }}
|
debug: msg={{ ipv4["stdout"] }}
|
||||||
|
changed_when: "False"
|
||||||
|
|
||||||
|
# hosts-Eintrag nur erzeugen falls die ip ermittelt werden konnte
|
||||||
- name: Write vmname and ipv4-address for resolution to /etc/hosts on wirt machine iXXXXXXXXXXXXXXXXXXXXX
|
- name: Write vmname and ipv4-address for resolution to /etc/hosts on wirt machine
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/hosts
|
path: /etc/hosts
|
||||||
regexp: '^{{ ipv4["stdout"] }} ='
|
regexp: '^{{ ipv4["stdout"] }} ='
|
||||||
line: "{{ ipv4['stdout'] + ' ' + vm_name }}"
|
line: "{{ ipv4['stdout'] + ' ' + vm_name }}"
|
||||||
|
when: ipv4["stdout"] | length > 0
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
- name: Debug KVM ok
|
- name: Debug KVM ok
|
||||||
debug:
|
debug:
|
||||||
msg: "{{ kvmok }}"
|
msg: "{{ kvmok['stdout'] }}"
|
||||||
|
|
||||||
- name: Add user core to libvirt group
|
- name: Add user core to libvirt group
|
||||||
user:
|
user:
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: Upload libvirt_restart to core's Scripte directory
|
- name: Upload libvirtd_restart to core's Scripte directory
|
||||||
copy:
|
copy:
|
||||||
src: libvirt_restart
|
src: libvirtd_restart
|
||||||
dest: /home/core/Scripte/
|
dest: /home/core/Scripte/
|
||||||
owner: core
|
owner: core
|
||||||
group: users
|
group: users
|
||||||
|
|
Loading…
Reference in New Issue