Skip to content

Commit

Permalink
Merge pull request csmart#72 from csmart/custom_host_packages
Browse files Browse the repository at this point in the history
add support for custom host packages
  • Loading branch information
csmart authored Aug 19, 2023
2 parents 7d5b471 + 9311eef commit 4e91fc0
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 26 deletions.
59 changes: 33 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
<!-- vim-markdown-toc GFM -->

* [Ansible Role: Virtual Infrastructure](#ansible-role-virtual-infrastructure)
* [Requirements](#requirements)
* [KVM host](#kvm-host)
* [Fedora](#fedora)
* [CentOS 7](#centos-7)
* [CentOS Stream 8](#centos-stream-8)
* [Debian](#debian)
* [Ubuntu](#ubuntu)
* [openSUSE](#opensuse)
* [Using routed networks](#using-routed-networks)
* [Configuring bridges with NetworkManager](#configuring-bridges-with-networkmanager)
* [Linux bridge](#linux-bridge)
* [Using Linux bridge in inventory](#using-linux-bridge-in-inventory)
* [Open vSwitch (OVS) bridge](#open-vswitch-ovs-bridge)
* [Using ovs-bridge in inventory](#using-ovs-bridge-in-inventory)
* [Guest Cloud images](#guest-cloud-images)
* [Role Variables](#role-variables)
* [Dependencies](#dependencies)
* [Example Inventory](#example-inventory)
* [Multiple KVM hosts](#multiple-kvm-hosts)
* [Example Playbook](#example-playbook)
* [Grab the cloud image](#grab-the-cloud-image)
* [Run the playbook](#run-the-playbook)
* [Cleanup](#cleanup)
* [Post setup configuration](#post-setup-configuration)
* [License](#license)
* [Author Information](#author-information)
* [Requirements](#requirements)
* [KVM host](#kvm-host)
* [Fedora](#fedora)
* [CentOS 7](#centos-7)
* [CentOS Stream 8](#centos-stream-8)
* [Debian](#debian)
* [Ubuntu](#ubuntu)
* [openSUSE](#opensuse)
* [Using routed networks](#using-routed-networks)
* [Configuring bridges with NetworkManager](#configuring-bridges-with-networkmanager)
* [Linux bridge](#linux-bridge)
* [Using Linux bridge in inventory](#using-linux-bridge-in-inventory)
* [Open vSwitch (OVS) bridge](#open-vswitch-ovs-bridge)
* [Using ovs-bridge in inventory](#using-ovs-bridge-in-inventory)
* [Guest Cloud images](#guest-cloud-images)
* [Role Variables](#role-variables)
* [Dependencies](#dependencies)
* [Example Inventory](#example-inventory)
* [Multiple KVM hosts](#multiple-kvm-hosts)
* [Example Playbook](#example-playbook)
* [Grab the cloud image](#grab-the-cloud-image)
* [Run the playbook](#run-the-playbook)
* [Cleanup](#cleanup)
* [Post setup configuration](#post-setup-configuration)
* [License](#license)
* [Author Information](#author-information)

<!-- vim-markdown-toc -->

Expand Down Expand Up @@ -142,6 +142,13 @@ useful.
and other required packages on supported distros and also make sure the
libvirtd is running.

There is also a variable `virt_infra_host_pkgs_custom` which takes a list of
packages to install on the host, should you need or want the role to install
some extra packages for you.

Note that the variable must be a list and the host must be able to install the
packages, i.e. the package names must be correct for the host and if the host
is running RHEL, it must be registered.

#### Fedora

Expand Down
25 changes: 25 additions & 0 deletions tasks/validations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,31 @@
- result_deps_install.failed
changed_when: true

- name: "KVM host only: Install custom packages"
package:
name: "{{ virt_infra_host_pkgs_custom }}"
state: present
become: true
register: result_custom_install
retries: 30
delay: 5
until: result_custom_install is succeeded
when:
- inventory_hostname in groups['kvmhost']
- virt_infra_host_pkgs_custom is defined
- virt_infra_host_pkgs_custom is not mapping
- virt_infra_host_pkgs_custom is iterable
- virt_infra_host_pkgs_custom is not string
ignore_errors: true

- name: "KVM host only: Advise unable to install custom packages"
set_fact:
validations_failed: "{{ validations_failed|default([]) + ['KVM host: Failed to install custom packages'] }}"
when:
- inventory_hostname in groups['kvmhost']
- result_custom_install.failed is defined and result_custom_install.failed
changed_when: true

- name: "KVM host only: Test for required programs"
shell: 'hash {{ item }} 2>/dev/null'
become: true
Expand Down

0 comments on commit 4e91fc0

Please sign in to comment.