VM Deployment ist nun funktionstüchtig
This commit is contained in:
parent
09d4930cd2
commit
5ca763a72f
@ -1,3 +1,4 @@
|
||||
ansible_ssh_private_key_file: private/keyfile
|
||||
ansible_user: ansible
|
||||
libvirt:
|
||||
images: /var/lib/libvirt/images
|
||||
|
2
hosts
2
hosts
@ -2,7 +2,7 @@
|
||||
localhost ansible_connection=local
|
||||
|
||||
[docker_nodes]
|
||||
docker[1:3]
|
||||
docker1
|
||||
|
||||
[gitlab]
|
||||
|
||||
|
@ -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:
|
||||
|
@ -1,5 +1,8 @@
|
||||
#cloud-config
|
||||
|
||||
preserve_hostname: False
|
||||
hostname: {{ inventory_hostname }}
|
||||
|
||||
users:
|
||||
- name: ansible
|
||||
ssh_authorized_keys:
|
||||
@ -7,3 +10,7 @@ users:
|
||||
sudo: ['ALL=(ALL) NOPASSWD:ALL']
|
||||
groups: sudo
|
||||
shell: /bin/bash
|
||||
|
||||
runcmd:
|
||||
- eject /dev/sr0
|
||||
- systemctl disable cloud-init
|
||||
|
@ -38,6 +38,12 @@
|
||||
<target dev="vda" bus="virtio"/>
|
||||
<address type="pci" domain="0x0000" bus="0x04" slot="0x00" function="0x0"/>
|
||||
</disk>
|
||||
<disk type="file" device="cdrom">
|
||||
<driver name="qemu" type="raw"/>
|
||||
<target dev="sda" bus="sata"/>
|
||||
<readonly/>
|
||||
<address type="drive" controller="0" bus="0" target="0" unit="0"/>
|
||||
</disk>
|
||||
<controller type="usb" index="0" model="qemu-xhci" ports="15">
|
||||
<address type="pci" domain="0x0000" bus="0x02" slot="0x00" function="0x0"/>
|
||||
</controller>
|
||||
@ -84,10 +90,15 @@
|
||||
<address type="pci" domain="0x0000" bus="0x03" slot="0x00" function="0x0"/>
|
||||
</controller>
|
||||
<interface type="network">
|
||||
<source network="docker"/>
|
||||
<source network="default"/>
|
||||
<model type="virtio"/>
|
||||
<address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
|
||||
</interface>
|
||||
<interface type="network">
|
||||
<source network="docker"/>
|
||||
<model type="virtio"/>
|
||||
<address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/>
|
||||
</interface>
|
||||
<serial type="pty">
|
||||
<target type="isa-serial" port="0">
|
||||
<model name="isa-serial"/>
|
||||
|
Loading…
Reference in New Issue
Block a user