From 05f89e04e3ae7bd28bceb5ca14430ac0e8b89d09 Mon Sep 17 00:00:00 2001 From: jgoutin Date: Fri, 26 Jul 2024 21:36:43 +0200 Subject: [PATCH] common: Add option to install Qemu gest agent --- roles/common/README.md | 1 + roles/common/defaults/main.yml | 1 + roles/common/tasks/guest.yml | 22 ++++++++++++++++++++++ roles/common/tasks/main.yml | 3 +++ 4 files changed, 27 insertions(+) create mode 100644 roles/common/tasks/guest.yml diff --git a/roles/common/README.md b/roles/common/README.md index 2936944..01172e7 100644 --- a/roles/common/README.md +++ b/roles/common/README.md @@ -88,6 +88,7 @@ packages. | `common_grub_hidden_timeout` | 0 | Grub hidden timeout to set. | | `common_grub_password` | | If specified, ensure Grub password is set to this value. | | `common_grub_timeout` | 1 | Grub timeout to set. | +| `common_guest_qemu` | false | If `true` Install Qemu guest agent. | | `common_hostname` | | If specified, set hostname. | | `common_journal_disk_max_size` | | If specified, set systemd journal disk max size (`SystemMaxUse`). | | `common_journal_memory_max_size` | | If specified, set systemd journal memory max size (`RuntimeMaxUse`). | diff --git a/roles/common/defaults/main.yml b/roles/common/defaults/main.yml index 61de2b7..fb7df37 100644 --- a/roles/common/defaults/main.yml +++ b/roles/common/defaults/main.yml @@ -31,6 +31,7 @@ common_random_mac: false common_random_mac_wifi: random common_random_mac_ethernet: stable common_ssh_hardening: true +common_guest_qemu: false # Internal values _smtp_server: "[{{ common_mail_smtp_host }}]:{{ common_mail_smtp_port }}" diff --git a/roles/common/tasks/guest.yml b/roles/common/tasks/guest.yml new file mode 100644 index 0000000..1353d3d --- /dev/null +++ b/roles/common/tasks/guest.yml @@ -0,0 +1,22 @@ +--- + +- name: Ensure Qemu guest agent is installed + ansible.builtin.dnf: + state: present + name: qemu-guest-agent + install_weak_deps: false + retries: 10 + delay: 1 + register: _ + until: _ is successful + when: + - common_guest_qemu | bool + - not (_ostree | bool) + +- name: Ensure Qemu guest agent is installed + community.general.rpm_ostree_pkg: + state: present + name: qemu-guest-agent + when: + - common_guest_qemu | bool + - _ostree | bool diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 7457b39..f865704 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -55,6 +55,9 @@ ansible.builtin.include_tasks: mount_smb.yml when: common_smb_mount is defined +- name: Guest VM configuration + ansible.builtin.include_tasks: guest.yml + - name: Fail2ban configuration ansible.builtin.include_tasks: fail2ban.yml