Skip to content

Commit cf2d833

Browse files
Support passing pubkeys to authorized_keys for mrack (#3354)
1 parent 43e695d commit cf2d833

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

docs/releases.rst

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ the ``end-time``. It should be also ensured that the end time of
3737
all launch items is the same or higher than the start time of a
3838
parent item/launch.
3939

40+
The :ref:`/plugins/provision/beaker` provision plugin gains support
41+
for adding pubkeys to instance by populating the kickstart file.
42+
4043

4144
tmt-1.39.0
4245
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tmt/schemas/provision/beaker.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,10 @@ properties:
4949
beaker-job-owner:
5050
type: string
5151

52+
public-key:
53+
type: array
54+
items:
55+
type: string
56+
5257
required:
5358
- how

tmt/steps/provision/mrack.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,16 @@ class BeakerGuestData(tmt.steps.provision.GuestSshData):
913913
Submitting user must be a submission delegate for the ``USERNAME``.
914914
""")
915915

916+
public_key: list[str] = field(
917+
default_factory=list,
918+
option='--public-key',
919+
metavar='PUBKEY',
920+
help="""
921+
Public keys to add among authorized SSH keys.
922+
""",
923+
multiple=True,
924+
normalize=tmt.utils.normalize_string_list)
925+
916926

917927
@dataclasses.dataclass
918928
class ProvisionBeakerData(BeakerGuestData, tmt.steps.provision.ProvisionStepData):
@@ -948,6 +958,7 @@ class CreateJobParameters:
948958
kickstart: dict[str, str]
949959
whiteboard: Optional[str]
950960
beaker_job_owner: Optional[str]
961+
public_key: list[str]
951962
group: str = 'linux'
952963

953964
def to_mrack(self) -> dict[str, Any]:
@@ -966,6 +977,8 @@ def to_mrack(self) -> dict[str, Any]:
966977
# see kickstart if it was just metadata.
967978
if kickstart:
968979
data['beaker']['ks_append'] = kickstart
980+
if self.public_key:
981+
data['beaker']['pubkeys'] = self.public_key
969982

970983
return data
971984

@@ -1077,6 +1090,7 @@ class GuestBeaker(tmt.steps.provision.GuestSsh):
10771090
# Timeouts and deadlines
10781091
provision_timeout: int
10791092
provision_tick: int
1093+
public_key: list[str]
10801094
api_session_refresh_tick: int
10811095

10821096
_api: Optional[BeakerAPI] = None
@@ -1145,7 +1159,8 @@ def _create(self, tmt_name: str) -> None:
11451159
os=self.image,
11461160
name=f'{self.image}-{self.arch}',
11471161
whiteboard=self.whiteboard or tmt_name,
1148-
beaker_job_owner=self.beaker_job_owner)
1162+
beaker_job_owner=self.beaker_job_owner,
1163+
public_key=self.public_key)
11491164

11501165
try:
11511166
response = self.api.create(data)

0 commit comments

Comments
 (0)