From 590a50cd1a4b880546865740e6bf9951c126e1ab Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 9 Aug 2023 15:49:23 +1000 Subject: [PATCH] new hypervisor role --- .vscode/settings.json | 3 +- ansible/roles/hypervisor_qcow/tasks/main.yaml | 0 .../hypervisor_qcow/templates/bond.netdev.j2 | 0 .../hypervisor_qcow/templates/bond.network.j2 | 0 .../templates/bridge.netdev.j2 | 0 .../templates/bridge.network.j2 | 0 .../templates/ethernet.netdev.j2 | 0 .../templates/ethernet.network.j2 | 0 .../hypervisor_qcow/templates/vlan.netdev.j2 | 0 .../hypervisor_qcow/templates/vlan.network.j2 | 0 .../defaults/main.yml | 0 .../tasks/main.yml | 36 ++++--------------- .../templates/network.xml.j2 | 0 .../templates/pool.xml.j2 | 0 14 files changed, 9 insertions(+), 30 deletions(-) create mode 100644 ansible/roles/hypervisor_qcow/tasks/main.yaml create mode 100644 ansible/roles/hypervisor_qcow/templates/bond.netdev.j2 create mode 100644 ansible/roles/hypervisor_qcow/templates/bond.network.j2 create mode 100644 ansible/roles/hypervisor_qcow/templates/bridge.netdev.j2 create mode 100644 ansible/roles/hypervisor_qcow/templates/bridge.network.j2 create mode 100644 ansible/roles/hypervisor_qcow/templates/ethernet.netdev.j2 create mode 100644 ansible/roles/hypervisor_qcow/templates/ethernet.network.j2 create mode 100644 ansible/roles/hypervisor_qcow/templates/vlan.netdev.j2 create mode 100644 ansible/roles/hypervisor_qcow/templates/vlan.network.j2 rename ansible/roles/{libvirt-server => hypervisor_zfs}/defaults/main.yml (100%) rename ansible/roles/{libvirt-server => hypervisor_zfs}/tasks/main.yml (78%) rename ansible/roles/{libvirt-server => hypervisor_zfs}/templates/network.xml.j2 (100%) rename ansible/roles/{libvirt-server => hypervisor_zfs}/templates/pool.xml.j2 (100%) diff --git a/.vscode/settings.json b/.vscode/settings.json index 28575b4..6886c6a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -22,5 +22,6 @@ "vs-kubernetes.local-tunnel-debug-provider": "", "checkForMinikubeUpgrade": true, "imageBuildTool": "Docker" - } + }, + "ansible.python.interpreterPath": "/usr/bin/python3" } \ No newline at end of file diff --git a/ansible/roles/hypervisor_qcow/tasks/main.yaml b/ansible/roles/hypervisor_qcow/tasks/main.yaml new file mode 100644 index 0000000..e69de29 diff --git a/ansible/roles/hypervisor_qcow/templates/bond.netdev.j2 b/ansible/roles/hypervisor_qcow/templates/bond.netdev.j2 new file mode 100644 index 0000000..e69de29 diff --git a/ansible/roles/hypervisor_qcow/templates/bond.network.j2 b/ansible/roles/hypervisor_qcow/templates/bond.network.j2 new file mode 100644 index 0000000..e69de29 diff --git a/ansible/roles/hypervisor_qcow/templates/bridge.netdev.j2 b/ansible/roles/hypervisor_qcow/templates/bridge.netdev.j2 new file mode 100644 index 0000000..e69de29 diff --git a/ansible/roles/hypervisor_qcow/templates/bridge.network.j2 b/ansible/roles/hypervisor_qcow/templates/bridge.network.j2 new file mode 100644 index 0000000..e69de29 diff --git a/ansible/roles/hypervisor_qcow/templates/ethernet.netdev.j2 b/ansible/roles/hypervisor_qcow/templates/ethernet.netdev.j2 new file mode 100644 index 0000000..e69de29 diff --git a/ansible/roles/hypervisor_qcow/templates/ethernet.network.j2 b/ansible/roles/hypervisor_qcow/templates/ethernet.network.j2 new file mode 100644 index 0000000..e69de29 diff --git a/ansible/roles/hypervisor_qcow/templates/vlan.netdev.j2 b/ansible/roles/hypervisor_qcow/templates/vlan.netdev.j2 new file mode 100644 index 0000000..e69de29 diff --git a/ansible/roles/hypervisor_qcow/templates/vlan.network.j2 b/ansible/roles/hypervisor_qcow/templates/vlan.network.j2 new file mode 100644 index 0000000..e69de29 diff --git a/ansible/roles/libvirt-server/defaults/main.yml b/ansible/roles/hypervisor_zfs/defaults/main.yml similarity index 100% rename from ansible/roles/libvirt-server/defaults/main.yml rename to ansible/roles/hypervisor_zfs/defaults/main.yml diff --git a/ansible/roles/libvirt-server/tasks/main.yml b/ansible/roles/hypervisor_zfs/tasks/main.yml similarity index 78% rename from ansible/roles/libvirt-server/tasks/main.yml rename to ansible/roles/hypervisor_zfs/tasks/main.yml index bf81d5b..b383ff4 100644 --- a/ansible/roles/libvirt-server/tasks/main.yml +++ b/ansible/roles/hypervisor_zfs/tasks/main.yml @@ -1,50 +1,28 @@ --- -- name: install libvirt server packages +- name: Install libvirt server packages become: true community.general.pacman: name: "{{ libvirt_server_packages }}" - state: latest + state: present update_cache: true when: - ansible_os_family == 'Arch' -- name: add user to libvirt group +- name: Add user to libvirt group become: true ansible.builtin.user: name: "{{ ansible_user }}" groups: libvirt append: true - -- name: start and enable libvirt service + +- name: Start and enable libvirt service become: true ansible.builtin.service: name: libvirtd.service state: started - enabled: yes + enabled: true -- name: set cluster network variables - set_fact: - libvirt_network_name: "{{ libvirt_cluster_network_name }}" - libvirt_network_domain: "{{ libvirt_cluster_network_name }}" - -- name: define vm cluster network - community.libvirt.virt_net: - name: "{{ libvirt_cluster_network_name }}" - command: define - xml: '{{ lookup("template", "network.xml.j2") }}' - -- name: build vm cluster network - community.libvirt.virt_net: - name: "{{ libvirt_cluster_network_name }}" - command: create - -- name: start vm cluster network - community.libvirt.virt_net: - name: "{{ libvirt_cluster_network_name }}" - state: active - autostart: true - -- name: remove default libvirt network +- name: Remove default libvirt network community.libvirt.virt_net: name: default state: absent diff --git a/ansible/roles/libvirt-server/templates/network.xml.j2 b/ansible/roles/hypervisor_zfs/templates/network.xml.j2 similarity index 100% rename from ansible/roles/libvirt-server/templates/network.xml.j2 rename to ansible/roles/hypervisor_zfs/templates/network.xml.j2 diff --git a/ansible/roles/libvirt-server/templates/pool.xml.j2 b/ansible/roles/hypervisor_zfs/templates/pool.xml.j2 similarity index 100% rename from ansible/roles/libvirt-server/templates/pool.xml.j2 rename to ansible/roles/hypervisor_zfs/templates/pool.xml.j2