From 2185458a88dd8dada9888f14a73606c4556f3efd Mon Sep 17 00:00:00 2001 From: Will Szumski Date: Fri, 28 Sep 2018 13:13:51 +0100 Subject: [PATCH 1/3] Add support for Debian GNU/Linux and derivatives --- meta/main.yml | 6 ++++++ tasks/install.yml | 23 ++++++++++++++--------- vars/Debian.yml | 5 +++++ vars/RedHat.yml | 8 ++++++++ 4 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 vars/Debian.yml create mode 100644 vars/RedHat.yml diff --git a/meta/main.yml b/meta/main.yml index 494c5c3..9ce90d6 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -11,6 +11,12 @@ galaxy_info: - name: EL versions: - 7 + - name: Ubuntu + versions: + - all + - name: Debian + versions: + - all galaxy_tags: - cloud - kvm diff --git a/tasks/install.yml b/tasks/install.yml index 5b457d0..770d3c2 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -1,14 +1,18 @@ --- -- name: Ensure the libvirt package is installed - yum: + +- name: gather os specific variables + include_vars: "{{ item }}" + with_first_found: + - "{{ ansible_distribution }}-{{ ansible_distribution_major_version}}.yml" + - "{{ ansible_distribution }}.yml" + - "{{ ansible_os_family }}.yml" + tags: vars + +- name: Ensure libvirt packages are installed + package: name: "{{ item }}" state: installed - with_items: - - libvirt - - libvirt-daemon-kvm - - libvirt-python - - python-lxml - - qemu-kvm + with_items: "{{ libvirt_host_libvirt_packages }}" become: True # NOTE: QEMU emulators are available in EPEL. @@ -18,9 +22,10 @@ state: installed when: libvirt_host_qemu_emulators | length > 0 become: True + when: ansible_os_family == "RedHat" - name: Ensure QEMU emulator packages are installed - yum: + package: name: "{{ package }}" state: installed with_items: "{{ libvirt_host_qemu_emulators }}" diff --git a/vars/Debian.yml b/vars/Debian.yml new file mode 100644 index 0000000..eb67307 --- /dev/null +++ b/vars/Debian.yml @@ -0,0 +1,5 @@ +--- +# List of libvirt package dependencies. +libvirt_host_libvirt_packages: + - libvirt-bin + - qemu-kvm diff --git a/vars/RedHat.yml b/vars/RedHat.yml new file mode 100644 index 0000000..e78cc44 --- /dev/null +++ b/vars/RedHat.yml @@ -0,0 +1,8 @@ +--- +# List of libvirt package dependencies. +libvirt_host_libvirt_packages: + - libvirt + - libvirt-daemon-kvm + - libvirt-python + - python-lxml + - qemu-kvm From 6043c604abe01182311600e619466908867eae4a Mon Sep 17 00:00:00 2001 From: Will Szumski Date: Fri, 28 Sep 2018 13:59:41 +0100 Subject: [PATCH 2/3] Convert double when to list --- tasks/install.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tasks/install.yml b/tasks/install.yml index 770d3c2..6de4a4f 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -20,9 +20,10 @@ yum: name: epel-release state: installed - when: libvirt_host_qemu_emulators | length > 0 become: True - when: ansible_os_family == "RedHat" + when: + - ansible_os_family == "RedHat" + - libvirt_host_qemu_emulators | length > 0 - name: Ensure QEMU emulator packages are installed package: From 4612c5e916bf1a29ab6844631119b2f446721a2c Mon Sep 17 00:00:00 2001 From: Will Szumski Date: Fri, 28 Sep 2018 14:15:30 +0100 Subject: [PATCH 3/3] Add missing dependencies These may be pulled in automatically, but adding them explicitly just in case. --- vars/Debian.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vars/Debian.yml b/vars/Debian.yml index eb67307..c00d72b 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -3,3 +3,5 @@ libvirt_host_libvirt_packages: - libvirt-bin - qemu-kvm + - python-libvirt + - python-lxml