diff --git a/.gitea/workflows/deployLibvirt.yaml b/.gitea/workflows/deployLibvirt.yaml new file mode 100644 index 0000000..cafc177 --- /dev/null +++ b/.gitea/workflows/deployLibvirt.yaml @@ -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 diff --git a/inventories/eom.dev.yml b/inventories/eom.dev.yml index c2151cf..dfd2624 100644 --- a/inventories/eom.dev.yml +++ b/inventories/eom.dev.yml @@ -4,13 +4,13 @@ all: workstations: hosts: latitude-7230: + latitude-7424: inspiron-3670: - imac: - raspberrypi: hypervisors: hosts: poweredge-r350: + poweredge-r720: poweredge-t640: vms: diff --git a/libvirtGuests.yaml b/libvirtGuests.yaml new file mode 100644 index 0000000..b85053d --- /dev/null +++ b/libvirtGuests.yaml @@ -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: {} diff --git a/main.yaml b/main.yaml index 29d3266..2948dda 100644 --- a/main.yaml +++ b/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 @@ -285,6 +153,11 @@ name: bitnami repo_url: https://charts.bitnami.com/bitnami + - name: Add nvdp repository + kubernetes.core.helm_repository: + name: nvdp + repo_url: https://nvidia.github.io/k8s-device-plugin + - name: Update Helm repos command: helm repo update @@ -393,6 +266,13 @@ ingress: ingressClassName: nginx + - name: Deploy nvidia device plugin + kubernetes.core.helm: + name: nvdp + chart_ref: nvdp/nvidia-device-plugin + release_namespace: nvidia-device-plugin + create_namespace: true + - name: Port forward HTTP(S) to Ingress Controllers hosts: localhost tasks: diff --git a/nvidia-device-plugin.yaml b/nvidia-device-plugin.yaml new file mode 100644 index 0000000..2edc9d9 --- /dev/null +++ b/nvidia-device-plugin.yaml @@ -0,0 +1,18 @@ +- name: Deploy nvdp + hosts: control_planes + become: true + tasks: + - name: Add nvdp repository + kubernetes.core.helm_repository: + name: nvdp + repo_url: https://nvidia.github.io/k8s-device-plugin + + - name: Update Helm repos + command: helm repo update + + - name: Deploy nvidia device plugin + kubernetes.core.helm: + name: nvdp + chart_ref: nvdp/nvidia-device-plugin + release_namespace: nvidia-device-plugin + create_namespace: true diff --git a/roles/ericomeehan.eom b/roles/ericomeehan.eom index 81b3f78..148f933 160000 --- a/roles/ericomeehan.eom +++ b/roles/ericomeehan.eom @@ -1 +1 @@ -Subproject commit 81b3f7827715a1433bb74ea4e53e60eec69ec9ac +Subproject commit 148f933eb51b158e673dd41e21c631c925ab3899 diff --git a/roles/ericomeehan.ericomeehan b/roles/ericomeehan.ericomeehan index 4dc7f79..969a46f 160000 --- a/roles/ericomeehan.ericomeehan +++ b/roles/ericomeehan.ericomeehan @@ -1 +1 @@ -Subproject commit 4dc7f7917edb012b15268a4e94c81b55592130a5 +Subproject commit 969a46feb589453ec8b1a4fc803cdf6bb3ffd77d diff --git a/roles/ericomeehan.gondwana b/roles/ericomeehan.gondwana index d5681a9..db0d438 160000 --- a/roles/ericomeehan.gondwana +++ b/roles/ericomeehan.gondwana @@ -1 +1 @@ -Subproject commit d5681a95e437b86347c624abb6bb74c427444698 +Subproject commit db0d438c699f33b2d143fd2fdfc3c314958932d5 diff --git a/roles/ericomeehan.kraken-bot b/roles/ericomeehan.kraken-bot index 45c0352..439661f 160000 --- a/roles/ericomeehan.kraken-bot +++ b/roles/ericomeehan.kraken-bot @@ -1 +1 @@ -Subproject commit 45c0352dde33deab8c7a1a62f0d289014c617154 +Subproject commit 439661f40be5d5cb2ab167c44602a2792d450727 diff --git a/roles/ericomeehan.nvidia_driver b/roles/ericomeehan.nvidia_driver index 7a3c04f..4b9534a 160000 --- a/roles/ericomeehan.nvidia_driver +++ b/roles/ericomeehan.nvidia_driver @@ -1 +1 @@ -Subproject commit 7a3c04febc0ab5d6370da362ab80d862bfc3dd39 +Subproject commit 4b9534a27ef2c7a096f58959d9762647f524b96d