From 6b196e70ab0a3cd369ddff5eca82524ec6efada3 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Wed, 24 Jun 2020 16:47:51 -0700 Subject: [PATCH] openqa/worker: set up swtpm service on tap worker hosts swtpm is a TPM emulator we want to use for testing Clevis on IoT (and potentially other things in future). We're implementing this by having os-autoinst just add the qemu args but expect swtpm itself to be running already - that's counted as the sysadmin's responsibility. My approach to this is to have openQA tap worker hosts also be tpm worker hosts, meaning they run one instance of swtpm per worker instance (as a systemd service) and are added to a 'tpm' worker class which tests can use to ensure they run on a suitably-equipped worker. This sets up all of that. We need a custom SELinux policy module to allow systemd to run swtpm - this is blocked by default. Signed-off-by: Adam Williamson --- .../openqa/worker/files/openqa-swtpm@.service | 12 ++++++++ roles/openqa/worker/files/systemd-swtpm.pp | Bin 0 -> 1101 bytes roles/openqa/worker/files/systemd-swtpm.te | 12 ++++++++ roles/openqa/worker/tasks/main.yml | 11 ++++++- roles/openqa/worker/tasks/swtpm-setup.yml | 28 ++++++++++++++++++ roles/openqa/worker/templates/workers.ini.j2 | 6 ++-- 6 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 roles/openqa/worker/files/openqa-swtpm@.service create mode 100644 roles/openqa/worker/files/systemd-swtpm.pp create mode 100644 roles/openqa/worker/files/systemd-swtpm.te create mode 100644 roles/openqa/worker/tasks/swtpm-setup.yml diff --git a/roles/openqa/worker/files/openqa-swtpm@.service b/roles/openqa/worker/files/openqa-swtpm@.service new file mode 100644 index 0000000000..583de07b6a --- /dev/null +++ b/roles/openqa/worker/files/openqa-swtpm@.service @@ -0,0 +1,12 @@ +[Unit] +Description=openQA swtpm service + +[Service] +User=_openqa-worker +ExecStartPre=-/usr/bin/rm -rf /tmp/mytpm%I +ExecStartPre=/usr/bin/mkdir -p /tmp/mytpm%I +ExecStart=/usr/bin/swtpm socket --tpm2 --tpmstate dir=/tmp/mytpm%I --ctrl type=unixio,path=/tmp/mytpm%I/swtpm-sock --log level=20 +ExecReload=/bin/true + +[Install] +WantedBy=multi-user.target diff --git a/roles/openqa/worker/files/systemd-swtpm.pp b/roles/openqa/worker/files/systemd-swtpm.pp new file mode 100644 index 0000000000000000000000000000000000000000..095e54a3612c2853eebec8dd25c1bd20a5054159 GIT binary patch literal 1101 zcmcIj%TB{E5F9Ab9zby5#)1AoEBFI0+~C9qSfMdes>X>DM--{QfcV~?iiYk=D+}M+ zkyf_%H4|t3v)gP>0MKp#eD5~fYXEQ0)0Zj?>*;G#4l92O;8xNm*y9R7|J6rdm$Uve zw)F_W%1eNHS z>@+>=YE=%u)0&tR*xdh;S3RJA4Sg3-f6FUDazFx%6};6 ff8%@N-Wp$nz5<;e#&xRg