From 70ec9068e8e95ffa2f755ae4777b718d313e144a Mon Sep 17 00:00:00 2001 From: Adrien Reslinger Date: Wed, 30 Nov 2022 07:46:38 +0100 Subject: [PATCH] Fix linter issues --- defaults/main.yml | 1 - handlers/main.yml | 5 ++-- meta/main.yml | 16 ++++++------- tasks/RedHat.yml | 8 +++---- tasks/main.yml | 61 +++++++++++++++++++++++------------------------ vars/RedHat.yml | 1 - 6 files changed, 45 insertions(+), 47 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index e5e58a6..42d3e57 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,3 +1,2 @@ --- qemu_default_network_interface: brdefaults - diff --git a/handlers/main.yml b/handlers/main.yml index d7c62d5..2665df9 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,4 +1,5 @@ --- - name: Restart libvirt - service: name="{{ libvirt_service }}" state=restarted - + ansible.builtin.service: + name: "{{ libvirt_service }}" + state: restarted diff --git a/meta/main.yml b/meta/main.yml index a69f1c9..a5d0da5 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -6,11 +6,11 @@ galaxy_info: galaxy_tags: [] license: GPL2 platforms: - - name: CentOS - version: - - 7 - - 8 - - name: RedHat - version: - - 7 - - 8 + - name: CentOS + version: + - 7 + - 8 + - name: RedHat + version: + - 7 + - 8 diff --git a/tasks/RedHat.yml b/tasks/RedHat.yml index bb7e38d..d80cffb 100644 --- a/tasks/RedHat.yml +++ b/tasks/RedHat.yml @@ -1,6 +1,6 @@ --- - name: Define libvirt-latest CentOS repo - template: + ansible.builtin.template: src: CentOS-libvirt-latest.repo.j2 dest: /etc/yum.repos.d/CentOS-libvirt-latest.repo owner: root @@ -8,13 +8,13 @@ mode: 0644 - name: Retreive CentOS SIG Virtualization key - get_url: + ansible.builtin.get_url: url: https://www.centos.org/keys/RPM-GPG-KEY-CentOS-SIG-Virtualization dest: /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization mode: 0644 - name: install repo packages - package: + ansible.builtin.package: name: "centos-release-qemu-ev" state: present - update_cache: yes + update_cache: true diff --git a/tasks/main.yml b/tasks/main.yml index f3d8a21..290e152 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,14 +1,14 @@ --- - name: Include vars for {{ ansible_os_family }} - include_vars: "{{ ansible_os_family }}.yml" + ansible.builtin.include_vars: "{{ ansible_os_family }}.yml" - name: "Ensure system is hardware virtualization capability" - fail: + ansible.builtin.fail: msg: "qemu-kvm requires hypervisor capability" when: "ansible_virtualization_type != 'kvm'" - name: Include tasks for {{ ansible_os_family }} - include_tasks: "{{ ansible_os_family }}.yml" + ansible.builtin.include_tasks: "{{ ansible_os_family }}.yml" when: - ansible_distribution == 'CentOS' - ansible_distribution_major_version == '7' @@ -25,14 +25,14 @@ # vg: vg_sys # thinpool: libvirt_var # size: "{{ lv_libvirt_size | default('20g') }}" -# +# # - name: Create cache pool logical volume # community.general.lvol: # vg: firefly # lv: lvcache # size: 512m # opts: --type cache-pool -# +# # - name: Verify or create backup LV # community.general.lvol: # lv: libvirt_var @@ -40,12 +40,12 @@ # state: present # active: yes # size: 200G -# +# # - name: Verify or apply filesystem for backup LV # ansible.builtin.filesystem: # fstype: ext4 # dev: "/dev/mapper/vg_sys-libvirt_var" -# +# # - name: Create /var/lib/libvirt directory # ansible.builtin.file: # path: /var/lib/libvirt @@ -53,7 +53,7 @@ # owner: root # group: root # mode: 0755 -# +# # - name: mount /var/lib/libvirt # ansible.posix.mount: # name: /var/lib/libvirt @@ -63,14 +63,14 @@ # state: mounted - name: install packages - package: + ansible.builtin.package: name: "{{ libvirt_kvm_packages }}" state: present - update_cache: yes + update_cache: true notify: Restart libvirt - name: Allow hypervisor in VM - template: + ansible.builtin.template: src: kvm.conf.j2 dest: /etc/modprobe.d/kvm.conf owner: root @@ -78,7 +78,7 @@ mode: 0644 - name: Install OpenVSwitch - include_role: + ansible.builtin.include_role: name: openvswitch # vars: # openvswitch_brname: "{{ libvirt_brname }}" @@ -87,25 +87,25 @@ register: install_openvswitch - name: Restart libvirt_kvm after openvswitch installation - service: + ansible.builtin.service: name: "{{ libvirt_service }}" state: restarted -#- name: Add OpenVSwitch bridge -# openvswitch_bridge: -# bridge: '{{ qemu_default_network_interface }}' -# parent: '{{ openvswitch_interface }}' -# state: present +# - name: Add OpenVSwitch bridge +# openvswitch.openvswitch.openvswitch_bridge: +# bridge: '{{ qemu_default_network_interface }}' +# parent: '{{ openvswitch_interface }}' +# state: present - name: Enable libvirt deamon - service: + ansible.builtin.service: name: "{{ libvirt_service }}" state: started - enabled: yes + enabled: true - name: Add defaults networks - virt_net: - command: define + community.libvirt.virt_net: + ansible.builtin.command: define name: '{{ item }}' xml: '{{ lookup ("template", "networks/" + item + ".xml.j2") }}' with_items: @@ -113,15 +113,15 @@ - private - name: Enable defaults networks on boot - virt_net: + community.libvirt.virt_net: name: '{{ item }}' - autostart: yes + autostart: true with_items: - default - private - name: Activate defaults networks now if it doesn't already up - virt_net: + community.libvirt.virt_net: name: '{{ item }}' state: active with_items: @@ -129,8 +129,8 @@ - private - name: Add OpenVSwitch networks - virt_net: - command: define + community.libvirt.virt_net: + ansible.builtin.command: define name: '{{ item.name }}' xml: '{{ lookup ("template", "networks/openvswitch.xml.j2") }}' with_items: @@ -140,7 +140,7 @@ - libvirt_openvswitch|bool - name: Activate OpenVSwitch networks now if it doesn't already up - virt_net: + community.libvirt.virt_net: name: '{{ item.name }}' state: active with_items: @@ -150,12 +150,11 @@ - libvirt_openvswitch|bool - name: Enable OpenVSwitch networks on boot - virt_net: + community.libvirt.virt_net: name: '{{ item.name }}' - autostart: yes + autostart: true with_items: - '{{ virtual_network }}' when: - virtual_network is defined - libvirt_openvswitch|bool - diff --git a/vars/RedHat.yml b/vars/RedHat.yml index ce9b1f9..fd55919 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -31,4 +31,3 @@ libvirt_kvm_packages: # - virt-backup # - virt-install libvirt_service: libvirtd -