From aeb6572b9ab094ebefb4d6cc206e0cb078f70c68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CRyan?= <“r_whiting@live.com> Date: Thu, 5 Oct 2023 13:29:11 +0100 Subject: [PATCH] Brought over some changes made on the GitLab Repo: Added some new necessary libraries to auto install Included argument in build file to make sure user is set to "packer" --- os_builders/packfiles/build.pkr.hcl | 1 + os_builders/roles/prep_builder/tasks/main.yml | 29 +++++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/os_builders/packfiles/build.pkr.hcl b/os_builders/packfiles/build.pkr.hcl index f55f623..a6d4a10 100644 --- a/os_builders/packfiles/build.pkr.hcl +++ b/os_builders/packfiles/build.pkr.hcl @@ -14,6 +14,7 @@ build{ ] provisioner "ansible" { + user = "packer" playbook_file = "../provision_image.yml" extra_arguments = [ # Include safety checks diff --git a/os_builders/roles/prep_builder/tasks/main.yml b/os_builders/roles/prep_builder/tasks/main.yml index e5afc20..8055109 100644 --- a/os_builders/roles/prep_builder/tasks/main.yml +++ b/os_builders/roles/prep_builder/tasks/main.yml @@ -1,3 +1,18 @@ +- name: Install required packages + apt: + name: "{{ item }}" + state: present + loop: + - gpg + - make + - git + - qemu-kvm + - libvirt-daemon-system + - libvirt-clients + - libguestfs-tools + - bridge-utils + - virtinst + - name: Add Hashicorp apt key apt_key: url: https://apt.releases.hashicorp.com/gpg @@ -13,19 +28,8 @@ - name: Install Packer apt: name: packer - state: latest - -- name: Install required packages - apt: - name: "{{ item }}" state: present - loop: - - qemu-kvm - - libvirt-daemon-system - - libvirt-clients - - libguestfs-tools - - bridge-utils - - virtinst + - name: Add user to required groups user: @@ -38,6 +42,7 @@ - name: Enable libvirt service service: + daemon_reload: yes name: libvirtd enabled: yes state: started