Compare commits
2 Commits
bf7954c5ae
...
5796aedcb4
Author | SHA1 | Date | |
---|---|---|---|
5796aedcb4 | |||
2ff0bc1502 |
22
.gitea/workflows/deployLibvirt.yaml
Normal file
22
.gitea/workflows/deployLibvirt.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
name: deployLibvirtGuests
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Ansible
|
||||
run: |
|
||||
apt update -y
|
||||
apt install python3-pip -y
|
||||
python3 -m pip install ansible
|
||||
|
||||
- name: Run playbook
|
||||
uses: dawidd6/action-ansible-playbook@v2
|
||||
with:
|
||||
playbook: libvirtGuests.yaml
|
||||
key: ${{secrets.SSH_PRIVATE_KEY}}
|
||||
vault_password: ${{secrets.VAULT_PASSWORD}}
|
||||
options: |
|
||||
--inventory inventories/eom.dev.yaml
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -19,3 +19,6 @@
|
||||
[submodule "roles/ericomeehan.libvirt-guest"]
|
||||
path = roles/ericomeehan.libvirt-guest
|
||||
url = git@gitea.eom.dev:DevOps/ansible-role-libvirt-guest.git
|
||||
[submodule "roles/ericomeehan.matrix-stack"]
|
||||
path = roles/ericomeehan.matrix-stack
|
||||
url = git@gitea.eom.dev:DevOps/ansible-role-matrix-stack.git
|
||||
|
@ -1 +1,2 @@
|
||||
name: alpha-worker-0
|
||||
nvidia_driver_needed: true
|
||||
|
@ -4,13 +4,13 @@ all:
|
||||
workstations:
|
||||
hosts:
|
||||
latitude-7230:
|
||||
latitude-7424:
|
||||
inspiron-3670:
|
||||
imac:
|
||||
raspberrypi:
|
||||
|
||||
hypervisors:
|
||||
hosts:
|
||||
poweredge-r350:
|
||||
poweredge-r720:
|
||||
poweredge-t640:
|
||||
|
||||
vms:
|
||||
|
10
libvirtGuests.yaml
Normal file
10
libvirtGuests.yaml
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
# playbook for libvirtGuests.yaml
|
||||
- name: Libvirt guests
|
||||
hosts: poweredge-r720
|
||||
become: true
|
||||
roles:
|
||||
- role: ericomeehan.libvirtguest
|
||||
vars:
|
||||
libvirt_networks: {}
|
||||
libvirt_guests: {}
|
159
main.yaml
159
main.yaml
@ -40,147 +40,15 @@
|
||||
- /data/gamma
|
||||
- /data/eric
|
||||
|
||||
- name: Prepare virtualization environments
|
||||
hosts: hypervisors
|
||||
become: true
|
||||
tasks:
|
||||
- name: Install packages for virtualization
|
||||
apt:
|
||||
update_cache: yes
|
||||
name:
|
||||
- bridge-utils
|
||||
- genisoimage
|
||||
- qemu-utils
|
||||
- qemu-system-x86
|
||||
- libvirt-daemon-system
|
||||
- prometheus-libvirt-exporter
|
||||
- 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: Copy interfaces template
|
||||
template:
|
||||
src: interfaces.j2
|
||||
dest: /etc/network/interfaces
|
||||
|
||||
- name: Reload sysctl configuration
|
||||
command: sysctl --system
|
||||
|
||||
- name: Reload network service
|
||||
service:
|
||||
name: networking
|
||||
state: restarted
|
||||
|
||||
- name: Deploy virtual machines
|
||||
- name: Setup virtualization
|
||||
hosts: hypervisors
|
||||
become: true
|
||||
vars_files:
|
||||
- ../secrets.yaml
|
||||
tasks:
|
||||
- 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
|
||||
get_url:
|
||||
url: https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
|
||||
dest: /var/lib/libvirt/images/debian-12-generic-amd64.qcow2
|
||||
force: true
|
||||
|
||||
- name: Copy base image
|
||||
copy:
|
||||
src: /var/lib/libvirt/images/debian-12-generic-amd64.qcow2
|
||||
remote_src: true
|
||||
dest: "/var/lib/libvirt/images/{{ item }}.qcow2"
|
||||
force: true
|
||||
loop: "{{ libvirt_guests }}"
|
||||
|
||||
- name: Resize images
|
||||
command: "qemu-img resize -f qcow2 /var/lib/libvirt/images/{{ item }}.qcow2 16G"
|
||||
loop: "{{ libvirt_guests }}"
|
||||
|
||||
- name: Create cloud-config directory
|
||||
file:
|
||||
path: "/tmp/{{ item }}"
|
||||
state: directory
|
||||
loop: "{{ libvirt_guests }}"
|
||||
|
||||
- name: Copy cloud-config user-data template
|
||||
template:
|
||||
src: user-data.j2
|
||||
dest: "/tmp/{{ domain.name }}/user-data"
|
||||
force: true
|
||||
loop: "{{ libvirt_guests }}"
|
||||
roles:
|
||||
- role: ericomeehan.libvirt_guests
|
||||
vars:
|
||||
domain: "{{ hostvars[item] }}"
|
||||
|
||||
- name: Copy cloud-config meta-data template
|
||||
template:
|
||||
src: meta-data.j2
|
||||
dest: "/tmp/{{ domain.name }}/meta-data"
|
||||
force: true
|
||||
loop: "{{ libvirt_guests }}"
|
||||
vars:
|
||||
domain: "{{ hostvars[item] }}"
|
||||
|
||||
- name: Generate iso
|
||||
command: "genisoimage -output /var/lib/libvirt/images/{{ item }}.iso -volid cidata -joliet -rock /tmp/{{ item }}/user-data /tmp/{{ item }}/meta-data"
|
||||
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 }}"
|
||||
|
||||
- name: Autostart libvirt virtual machines
|
||||
community.libvirt.virt:
|
||||
name: "{{ item }}"
|
||||
autostart: true
|
||||
loop: "{{ libvirt_guests }}"
|
||||
|
||||
- name: Wait for guest initialization
|
||||
wait_for:
|
||||
timeout: 300
|
||||
|
||||
- name: Reset libvirt virtual machines for filesystem resize
|
||||
command: "virsh reset {{ item }}"
|
||||
loop: "{{ libvirt_guests }}"
|
||||
doSetup: true
|
||||
|
||||
- name: Wait for manual tasks
|
||||
hosts: localhost
|
||||
@ -196,6 +64,8 @@
|
||||
- ../secrets.yaml
|
||||
roles:
|
||||
- role: ericomeehan.ericomeehan
|
||||
- role: ericomeehan.nvidia_driver
|
||||
when: nvidia_driver_needed == true
|
||||
|
||||
- name: Initialize Kubernetes clusters
|
||||
hosts: clusters
|
||||
@ -285,6 +155,11 @@
|
||||
name: bitnami
|
||||
repo_url: https://charts.bitnami.com/bitnami
|
||||
|
||||
- name: Add nvidia repository
|
||||
kubernetes.core.helm_repository:
|
||||
name: nvidia
|
||||
repo_url: https://helm.ngc.nvidia.com/nvidia
|
||||
|
||||
- name: Update Helm repos
|
||||
command: helm repo update
|
||||
|
||||
@ -393,6 +268,18 @@
|
||||
ingress:
|
||||
ingressClassName: nginx
|
||||
|
||||
- name: Deploy nvidia gpu operator
|
||||
kubernetes.core.helm:
|
||||
name: gpu-operator
|
||||
chart_ref: nvidia/gpu-operator
|
||||
release_namespace: gpu-operator
|
||||
create_namespace: true
|
||||
values:
|
||||
driver:
|
||||
enabled: false
|
||||
toolkit:
|
||||
enabled: false
|
||||
|
||||
- name: Port forward HTTP(S) to Ingress Controllers
|
||||
hosts: localhost
|
||||
tasks:
|
||||
|
23
nvidia-device-plugin.yaml
Normal file
23
nvidia-device-plugin.yaml
Normal file
@ -0,0 +1,23 @@
|
||||
- name: Deploy nvdp
|
||||
hosts: control_planes
|
||||
become: true
|
||||
tasks:
|
||||
- name: Add nvdp repository
|
||||
kubernetes.core.helm_repository:
|
||||
name: nvidia
|
||||
repo_url: https://helm.ngc.nvidia.com/nvidia
|
||||
|
||||
- name: Update Helm repos
|
||||
command: helm repo update
|
||||
|
||||
- name: Deploy nvidia gpu operator
|
||||
kubernetes.core.helm:
|
||||
name: gpu-operator
|
||||
chart_ref: nvidia/gpu-operator
|
||||
release_namespace: gpu-operator
|
||||
create_namespace: true
|
||||
values:
|
||||
driver:
|
||||
enabled: false
|
||||
toolkit:
|
||||
enabled: false
|
@ -1 +1 @@
|
||||
Subproject commit 81b3f7827715a1433bb74ea4e53e60eec69ec9ac
|
||||
Subproject commit 148f933eb51b158e673dd41e21c631c925ab3899
|
@ -1 +1 @@
|
||||
Subproject commit 4dc7f7917edb012b15268a4e94c81b55592130a5
|
||||
Subproject commit 969a46feb589453ec8b1a4fc803cdf6bb3ffd77d
|
@ -1 +1 @@
|
||||
Subproject commit d5681a95e437b86347c624abb6bb74c427444698
|
||||
Subproject commit db0d438c699f33b2d143fd2fdfc3c314958932d5
|
@ -1 +1 @@
|
||||
Subproject commit 45c0352dde33deab8c7a1a62f0d289014c617154
|
||||
Subproject commit 439661f40be5d5cb2ab167c44602a2792d450727
|
1
roles/ericomeehan.matrix-stack
Submodule
1
roles/ericomeehan.matrix-stack
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit eed66cd1834e81e7eb7c341f4f06d0354ce00f82
|
@ -1 +1 @@
|
||||
Subproject commit 7a3c04febc0ab5d6370da362ab80d862bfc3dd39
|
||||
Subproject commit 4b9534a27ef2c7a096f58959d9762647f524b96d
|
Loading…
Reference in New Issue
Block a user