diff --git a/roles/gitlab_runner/defaults/main.yml b/roles/gitlab_runner/defaults/main.yml
new file mode 100644
index 0000000000000000000000000000000000000000..e69f3dad2362e3a0bf9be290f423bedd45e45c49
--- /dev/null
+++ b/roles/gitlab_runner/defaults/main.yml
@@ -0,0 +1 @@
+gitlab_runner_libvirt_vm_memory: 2048
diff --git a/roles/gitlab_runner/tasks/main.yml b/roles/gitlab_runner/tasks/main.yml
index 71eee4da447175351f18587a184e72d6cfb98792..1662bc4ea3c99930383a2d8552136018ec3b07f7 100644
--- a/roles/gitlab_runner/tasks/main.yml
+++ b/roles/gitlab_runner/tasks/main.yml
@@ -79,10 +79,12 @@
       copy: src={{ item.src }} dest={{ item.dest }} owner=root group=root mode={{ item.mode }}
       loop:
         - {src: arch-boxes.asc, dest: /usr/local/lib/libvirt-executor/, mode: 644}
-        - {src: domain_template.xml, dest: /usr/local/lib/libvirt-executor/, mode: 644}
         - {src: libvirt-executor, dest: /usr/local/bin/, mode: 755}
         - {src: libvirt-executor-update-base-image, dest: /usr/local/bin/, mode: 755}
 
+    - name: Install libvirt-executor domain template
+      template: src=domain_template.xml.j2 dest=/usr/local/lib/libvirt-executor/domain_template.xml owner=root group=root mode=0644
+
     - name: Create SSH keys for libvirt-executor
       command: ssh-keygen -N "" -f /etc/libvirt-executor/id_ed25519 -t ed25519
       args:
diff --git a/roles/gitlab_runner/templates/config.toml.j2 b/roles/gitlab_runner/templates/config.toml.j2
index 6f8fee71356da7743c7145f181c65f71fcbab712..03cc16f4c3aa95134484b0c17f588b64d86a5a3e 100644
--- a/roles/gitlab_runner/templates/config.toml.j2
+++ b/roles/gitlab_runner/templates/config.toml.j2
@@ -32,7 +32,7 @@ listen_address = ":9252"
   executor = "custom"
   builds_dir = "/builds"
   cache_dir = "/cache"
-  limit = {{ (ansible_memtotal_mb * 0.9 / 2048) | round | int }}
+  limit = {{ (ansible_memtotal_mb * 0.9 / gitlab_runner_libvirt_vm_memory) | round | int }}
   environment = ["ARCHIVER_STAGING_DIR=/var/tmp"]
   [runners.custom]
     prepare_exec = "/usr/local/bin/libvirt-executor"
diff --git a/roles/gitlab_runner/files/domain_template.xml b/roles/gitlab_runner/templates/domain_template.xml.j2
similarity index 94%
rename from roles/gitlab_runner/files/domain_template.xml
rename to roles/gitlab_runner/templates/domain_template.xml.j2
index 80ca498284c1da0eff126febd10bf3d7666f878b..6ce09333d92f564ec76c08e662ef14be718be467 100644
--- a/roles/gitlab_runner/files/domain_template.xml
+++ b/roles/gitlab_runner/templates/domain_template.xml.j2
@@ -1,6 +1,6 @@
 <domain type='kvm'>
   <name>$vm_name</name>
-  <memory unit='MiB'>2048</memory>
+  <memory unit='MiB'>{{ gitlab_runner_libvirt_vm_memory }}</memory>
   <vcpu>4</vcpu>
   <os>
     <type arch='x86_64' machine='q35'>hvm</type>