Skip to content

Commit 8ac904a

Browse files
committed
enable tpm simulation for virtual machines
This commit: - Appends the libvirt VM definition xml templates to include tpm simulation. This commit is needed to enable the testing of use-cases where tpm features e.g. disk encryption, remote secure boot attestation, random hash generation, measured boot etc are used. Signed-off-by: Adam Rozman <[email protected]>
1 parent df3b640 commit 8ac904a

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

vm-setup/roles/libvirt/templates/baremetalvm.xml.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
<on_reboot>restart</on_reboot>
4545
<on_crash>restart</on_crash>
4646
<devices>
47+
<tpm model="tpm-tis">
48+
<backend type="emulator" version="2.0"/>
49+
</tpm>
4750
<disk type="file" device="cdrom">
4851
<target dev='{{ libvirt_cdromdev }}' bus='{{ libvirt_cdrombus }}'/>
4952
<readonly/>

vm-setup/roles/packages_installation/tasks/centos_required_packages.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,8 @@
3333
become: yes
3434
when: CONTAINER_RUNTIME == "podman"
3535

36+
- name: Install swtpm
37+
dnf:
38+
name: swtpm
39+
state: present
40+
become: yes

vm-setup/roles/packages_installation/tasks/ubuntu_required_packages.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
state: latest
88

99
# TODO: (Sunnatillo) Remove this task after fully removing apt-key
10-
- name: Remove OS old repository (without gpg key file location)
10+
- name: Remove OS old repository (without gpg key file location)
1111
apt_repository:
1212
repo: "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_{{ OS_VERSION_ID }}/ /"
1313
state: absent
14-
14+
1515
- name: Remove Ubuntu Noble old repository (without gpg key file location)
1616
apt_repository:
1717
repo: "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_{{ OS_VERSION_ID }}/ /"
@@ -35,9 +35,9 @@
3535
when: ansible_distribution_release == "noble"
3636

3737
- name: Dearmor Release key
38-
shell: |
38+
shell: |
3939
cat /usr/share/keyrings/libcontainers-archive-keyring.asc | sudo gpg --dearmor -o /usr/share/keyrings/libcontainers-archive-keyring.gpg --yes
40-
40+
4141
- name: Add OS repository
4242
lineinfile:
4343
path: /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
@@ -66,7 +66,7 @@
6666
- name: Podman
6767
block:
6868
- name: Install podman
69-
apt:
69+
apt:
7070
name: podman
7171
state: present
7272

@@ -92,19 +92,19 @@
9292
dest: /etc/apt/keyrings/docker.asc
9393
mode: '0644'
9494
force: true
95-
95+
9696
- name: Dearmor GPG key
97-
shell: |
97+
shell: |
9898
cat /etc/apt/keyrings/docker.asc | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg --yes
99-
99+
100100
# TODO: (Sunnatillo) Remove this task after fully removing apt-key
101-
- name: Remove Docker old repository (without gpg key file location)
101+
- name: Remove Docker old repository (without gpg key file location)
102102
apt_repository:
103103
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
104104
state: absent
105105

106106
# TODO: (Sunnatillo) Remove this task after fully removing apt-key
107-
- name: Remove Docker old repository (without gpg key file location)
107+
- name: Remove Docker old repository (without gpg key file location)
108108
apt_repository:
109109
repo: "deb https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
110110
state: absent
@@ -150,4 +150,10 @@
150150
append: yes
151151
when: CONTAINER_RUNTIME == "docker"
152152
become: yes
153+
154+
- name: Install swtpm
155+
apt:
156+
name: swtpm
157+
state: present
158+
153159
become: yes

0 commit comments

Comments
 (0)