VM Deployment ist nun funktionstüchtig
This commit is contained in:
@@ -41,10 +41,16 @@
|
||||
src: ci-userdata.j2
|
||||
dest: "{{ cidata.path }}/user-data"
|
||||
|
||||
- name: create CI-network-config
|
||||
delegate_to: "{{ virt.host }}"
|
||||
template:
|
||||
src: ci-networkconfig.j2
|
||||
dest: "{{ cidata.path }}/network-config"
|
||||
|
||||
- name: create CI ISO
|
||||
delegate_to: "{{ virt.host }}"
|
||||
shell:
|
||||
cmd: genisoimage -output "{{ libvirt.images }}/{{ inventory_hostname }}-cidata.iso" -volid cidata -joliet -rock user-data meta-data
|
||||
cmd: genisoimage -output "{{ libvirt.images }}/{{ inventory_hostname }}-cidata.iso" -volid cidata -joliet -rock user-data meta-data network-config
|
||||
chdir: "{{ cidata.path }}"
|
||||
|
||||
# VM INIT
|
||||
@@ -52,10 +58,36 @@
|
||||
- name: attach CI to vm
|
||||
delegate_to: "{{ virt.host }}"
|
||||
shell:
|
||||
cmd: virsh attach-disk "{{ inventory_hostname }}" --source "{{ libvirt.images }}/{{ inventory_hostname }}-cidata.iso" --target sda --type cdrom --mode readonly --persistent
|
||||
cmd: virsh change-media "{{ inventory_hostname }}" sda --source "{{ libvirt.images }}/{{ inventory_hostname }}-cidata.iso" --insert --config
|
||||
|
||||
- name: define vm
|
||||
delegate_to: "{{ virt.host }}"
|
||||
virt:
|
||||
name: "{{ inventory_hostname }}"
|
||||
state: running
|
||||
|
||||
- name: ping VM
|
||||
delegate_to: "{{ virt.host }}"
|
||||
shell:
|
||||
cmd: "ping -c 2 {{ ansible_host }}"
|
||||
register: pingcmd
|
||||
retries: 12
|
||||
delay: 10
|
||||
until: pingcmd.rc == 0
|
||||
|
||||
# CLOUD-INIT CLEANUP
|
||||
|
||||
- name: detach CI from vm
|
||||
delegate_to: "{{ virt.host }}"
|
||||
shell:
|
||||
cmd: virsh change-media "{{ inventory_hostname }}" sda --eject
|
||||
|
||||
- name: shutdown VM
|
||||
delegate_to: "{{ virt.host }}"
|
||||
virt:
|
||||
name: "{{ inventory_hostname }}"
|
||||
state: shutdown
|
||||
|
||||
- name: delete CI temp dir
|
||||
delegate_to: "{{ virt.host }}"
|
||||
file:
|
||||
|
Reference in New Issue
Block a user