Remove non RHEL configuration
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
---
|
||||
- name: Check if VM disk exists
|
||||
delegate_to: localhost
|
||||
ansible.builtin.stat:
|
||||
path: "{{ vm_path | default('/var/lib/libvirt/images/') }}{{ hostname }}.qcow2"
|
||||
register: vm_disk_stat
|
||||
|
||||
- name: Create VM disk
|
||||
when: not vm_disk_stat.stat.exists
|
||||
delegate_to: localhost
|
||||
ansible.builtin.command: qemu-img create -f qcow2 {{ vm_path | default('/var/lib/libvirt/images/') }}{{ hostname }}.qcow2 {{ vm_size }}G
|
||||
changed_when: result.rc == 0
|
||||
register: result
|
||||
|
||||
- name: Generate Random MAC Address
|
||||
delegate_to: localhost
|
||||
ansible.builtin.shell: set -o pipefail && openssl rand -hex 5 | sed 's/\(..\)/\1:/g; s/.$//' | sed 's/^/02:/'
|
||||
changed_when: false
|
||||
register: mac_address_output
|
||||
|
||||
- name: Render cloud config templates
|
||||
delegate_to: localhost
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: /tmp/{{ item.dest_prefix }}-{{ hostname }}.yml
|
||||
mode: '0644'
|
||||
loop:
|
||||
- { src: cloud-user-data.yml.j2, dest_prefix: cloud-user-data }
|
||||
- { src: cloud-network-config.yml.j2, dest_prefix: cloud-network-config }
|
||||
|
||||
- name: Create cloud-init disk
|
||||
delegate_to: localhost
|
||||
ansible.builtin.command: >
|
||||
cloud-localds {{ vm_path | default('/var/lib/libvirt/images/') }}/{{ hostname }}-cloudinit.iso
|
||||
/tmp/cloud-user-data-{{ hostname }}.yml
|
||||
-N /tmp/cloud-network-config-{{ hostname }}.yml
|
||||
changed_when: result.rc == 0
|
||||
register: result
|
||||
|
||||
- name: Create VM using libvirt
|
||||
delegate_to: localhost
|
||||
community.libvirt.virt:
|
||||
command: define
|
||||
xml: "{{ lookup('template', 'vm.xml.j2') }}"
|
||||
|
||||
- name: Start vm
|
||||
delegate_to: localhost
|
||||
community.libvirt.virt:
|
||||
name: "{{ hostname }}"
|
||||
state: running
|
||||
@@ -1,51 +0,0 @@
|
||||
---
|
||||
- name: Deploy VM on Proxmox
|
||||
delegate_to: localhost
|
||||
community.general.proxmox_kvm:
|
||||
api_host: "{{ hypervisor_url }}"
|
||||
api_user: "{{ hypervisor_username }}"
|
||||
api_password: "{{ hypervisor_password }}"
|
||||
ciuser: "{{ user_name }}"
|
||||
cipassword: "{{ user_password }}"
|
||||
ciupgrade: false
|
||||
node: "{{ hypervisor_node }}"
|
||||
vmid: "{{ vm_id }}"
|
||||
name: "{{ hostname }}"
|
||||
cpu: host
|
||||
cores: "{{ vm_cpus }}"
|
||||
memory: "{{ vm_memory }}"
|
||||
balloon: "{{ vm_ballo | default(omit) }}"
|
||||
numa_enabled: true
|
||||
hotplug: network,disk
|
||||
bios: ovmf
|
||||
boot: ac
|
||||
scsihw: virtio-scsi-single
|
||||
scsi:
|
||||
scsi0: "{{ hypervisor_storage }}:{{ vm_size }}"
|
||||
efidisk0:
|
||||
efitype: 4m
|
||||
format: raw
|
||||
pre_enrolled_keys: false
|
||||
storage: "{{ hypervisor_storage }}"
|
||||
ide:
|
||||
ide0: "{{ boot_iso }},media=cdrom"
|
||||
ide1: "{{ rhel_iso | default(omit) }},media=cdrom"
|
||||
ide2: "{{ hypervisor_storage }}:cloudinit"
|
||||
net:
|
||||
net0: virtio,bridge={{ vm_nif }}{% if vlan_name is defined and vlan_name %},tag={{ vlan_name }}{% endif %}
|
||||
ipconfig:
|
||||
ipconfig0: ip={{ vm_ip }},gw={{ vm_gw }}
|
||||
nameservers: "{{ vm_dns }}"
|
||||
onboot: true
|
||||
state: present
|
||||
|
||||
- name: Start VM on Proxmox
|
||||
delegate_to: localhost
|
||||
community.general.proxmox_kvm:
|
||||
api_host: "{{ hypervisor_url }}"
|
||||
api_user: "{{ hypervisor_username }}"
|
||||
api_password: "{{ hypervisor_password }}"
|
||||
node: "{{ hypervisor_node }}"
|
||||
name: "{{ hostname }}"
|
||||
vmid: "{{ vm_id }}"
|
||||
state: started
|
||||
@@ -1,11 +0,0 @@
|
||||
network:
|
||||
version: 2
|
||||
ethernets:
|
||||
id0:
|
||||
match:
|
||||
macaddress: "{{ mac_address_output.stdout }}"
|
||||
addresses:
|
||||
- "{{ vm_ip }}"
|
||||
gateway4: "{{ vm_gw }}"
|
||||
nameservers:
|
||||
addresses: ['1.1.1.1', '1.0.0.1']
|
||||
@@ -1,10 +0,0 @@
|
||||
#cloud-config
|
||||
hostname: "archiso"
|
||||
ssh_pwauth: true
|
||||
users:
|
||||
- name: "{{ user_name }}"
|
||||
primary_group: "{{ user_name }}"
|
||||
groups: users
|
||||
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||
passwd: "{{ user_password | password_hash('sha512') }}"
|
||||
lock_passwd: False
|
||||
@@ -1,62 +0,0 @@
|
||||
<domain type='kvm'>
|
||||
<name>{{ hostname }}</name>
|
||||
<memory>{{ vm_memory | int * 1024 }}</memory>
|
||||
{% if vm_ballo is defined %}<currentMemory>{{ vm_ballo | int * 1024 }}</currentMemory>{% endif %}
|
||||
<vcpu placement='static'>{{ vm_cpus }}</vcpu>
|
||||
<os>
|
||||
<type arch='x86_64' machine="pc-q35-8.0">hvm</type>
|
||||
<bootmenu enable='no'/>
|
||||
<boot dev='hd'/>
|
||||
<boot dev='cdrom'/>
|
||||
<loader readonly="yes" type="pflash">/usr/share/edk2/x64/OVMF_CODE.secboot.fd</loader>
|
||||
<nvram template="/usr/share/edk2/x64/OVMF_VARS.fd"/>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
<apic/>
|
||||
<pae/>
|
||||
</features>
|
||||
<cpu mode="host-passthrough" check="none" migratable="on"/>
|
||||
<clock offset="utc"/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='qemu' type='qcow2'/>
|
||||
<source file='{{ vm_path | default('/var/lib/libvirt/images/') }}{{ hostname }}.qcow2'/>
|
||||
<target dev='vda' bus='virtio'/>
|
||||
</disk>
|
||||
<disk type="file" device="cdrom">
|
||||
<driver name="qemu" type="raw"/>
|
||||
<source file="{{ boot_iso }}"/>
|
||||
<target dev="sda" bus="sata"/>
|
||||
</disk>
|
||||
<disk type="file" device="cdrom">
|
||||
<driver name="qemu" type="raw"/>
|
||||
<source file="{{ vm_path | default('/var/lib/libvirt/images/') }}{{ hostname }}-cloudinit.iso"/>
|
||||
<target dev="sdb" bus="sata"/>
|
||||
</disk>
|
||||
{% if rhel_iso is defined %}
|
||||
<disk type="file" device="cdrom">
|
||||
<driver name="qemu" type="raw"/>
|
||||
<source file="{{ rhel_iso }}"/>
|
||||
<target dev="sdc" bus="sata"/>
|
||||
</disk>
|
||||
{% endif %}
|
||||
<interface type='network'>
|
||||
<mac address="{{ mac_address_output.stdout }}"/>
|
||||
<source network='default'/>
|
||||
<model type='virtio'/>
|
||||
</interface>
|
||||
<input type="tablet" bus="usb"/>
|
||||
<input type="mouse" bus="ps2"/>
|
||||
<input type="keyboard" bus="ps2"/>
|
||||
<graphics type='spice' autoport="yes">
|
||||
<listen type="address"/>
|
||||
</graphics>
|
||||
<video>
|
||||
<model type="virtio" heads="1" primary="yes"/>
|
||||
</video>
|
||||
</devices>
|
||||
</domain>
|
||||
Reference in New Issue
Block a user