v0.0.20
This commit is contained in:
110
poweredge-r350.yaml
Normal file
110
poweredge-r350.yaml
Normal file
@@ -0,0 +1,110 @@
|
||||
---
|
||||
# Playbook for poweredge-r350
|
||||
# This is being used to test vm deployments
|
||||
- name: Deploy virtual machines
|
||||
hosts: poweredge-r350
|
||||
become: true
|
||||
vars_files:
|
||||
- ../secrets.yaml
|
||||
pre_tasks:
|
||||
- name: Install packages for virtualization
|
||||
apt:
|
||||
update_cache: yes
|
||||
name:
|
||||
- bridge-utils
|
||||
- genisoimage
|
||||
- qemu-utils
|
||||
- qemu-system-x86
|
||||
- libvirt-daemon-system
|
||||
- python3-libvirt
|
||||
- python3-lxml
|
||||
state: present
|
||||
|
||||
- name: Enable IPv4 packet forwarding
|
||||
lineinfile:
|
||||
path: /etc/sysctl.conf
|
||||
line: 'net.ipv4.ip_forward = 1'
|
||||
state: present
|
||||
|
||||
- name: Enable IPv6 packet forwarding
|
||||
lineinfile:
|
||||
path: /etc/sysctl.conf
|
||||
line: 'net.ipv6.conf.all.forwarding = 1'
|
||||
state: present
|
||||
|
||||
- name: Reload sysctl configuration
|
||||
command: sysctl --system
|
||||
|
||||
- name: Define libvirt networks
|
||||
community.libvirt.virt_net:
|
||||
name: "{{ item.name }}"
|
||||
command: define
|
||||
xml: "{{ lookup('template', 'libvirt-network.xml.j2') }}"
|
||||
loop: "{{ libvirt_networks }}"
|
||||
|
||||
- name: Create libvirt networks
|
||||
community.libvirt.virt_net:
|
||||
name: "{{ item.name }}"
|
||||
command: create
|
||||
loop: "{{ libvirt_networks }}"
|
||||
|
||||
- name: Autostart libvirt networks
|
||||
community.libvirt.virt_net:
|
||||
name: "{{ item.name }}"
|
||||
autostart: true
|
||||
loop: "{{ libvirt_networks }}"
|
||||
|
||||
- name: Download base image for guests
|
||||
get_url:
|
||||
url: https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
|
||||
dest: "/var/lib/libvirt/images/{{ item }}.qcow2"
|
||||
force: true
|
||||
loop: "{{ libvirt_guests }}"
|
||||
|
||||
- name: Create cloud-config directory for guests
|
||||
file:
|
||||
path: "/var/lib/libvirt/configs/{{ item }}"
|
||||
state: directory
|
||||
loop: "{{ libvirt_guests }}"
|
||||
|
||||
- name: Copy cloud-config templates for guests
|
||||
template:
|
||||
src: eom_cloud.cfg.j2
|
||||
dest: "/var/lib/libvirt/configs/{{ domain.name }}/user-data"
|
||||
force: true
|
||||
loop: "{{ libvirt_guests }}"
|
||||
vars:
|
||||
domain: "{{ hostvars[item] }}"
|
||||
|
||||
- name: Copy cloud-config templates for guests
|
||||
template:
|
||||
src: meta-data.j2
|
||||
dest: "/var/lib/libvirt/configs/{{ domain.name }}/meta-data"
|
||||
force: true
|
||||
loop: "{{ libvirt_guests }}"
|
||||
vars:
|
||||
domain: "{{ hostvars[item] }}"
|
||||
|
||||
- name: Generate iso for guests
|
||||
command: "genisoimage -output /var/lib/libvirt/images/{{ item }}.iso -volid cidata -joliet -rock /var/lib/libvirt/configs/{{ item }}/user-data /var/lib/libvirt/configs/{{ item }}/meta-data"
|
||||
loop: "{{ libvirt_guests }}"
|
||||
|
||||
- name: Copy logging config for guests
|
||||
copy:
|
||||
src: 05_logging.cfg
|
||||
dest: "/var/lib/libvirt/configs/{{ item }}/05_logging.cfg"
|
||||
loop: "{{ libvirt_guests }}"
|
||||
|
||||
- name: Define libvirt virtual machine
|
||||
community.libvirt.virt:
|
||||
command: define
|
||||
xml: "{{ lookup('template', 'libvirt-vm.xml.j2') }}"
|
||||
loop: "{{ libvirt_guests }}"
|
||||
vars:
|
||||
domain: "{{ hostvars[item] }}"
|
||||
|
||||
- name: Create libvirt virtual machine
|
||||
community.libvirt.virt:
|
||||
name: "{{ item }}"
|
||||
command: create
|
||||
loop: "{{ libvirt_guests }}"
|
||||
Reference in New Issue
Block a user