Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support passing pubkeys to authorized_keys for mrack #3354

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ support for :ref:`system.model-name</spec/hardware/system>`,
The ``tmt lint`` command now reports a failure if empty
environment files are found.

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


tmt-1.38.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
5 changes: 5 additions & 0 deletions tmt/schemas/provision/beaker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,10 @@ properties:
beaker-job-owner:
type: string

public-keys:
type: array
items:
type: string

required:
- how
16 changes: 15 additions & 1 deletion tmt/steps/provision/mrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,16 @@ class BeakerGuestData(tmt.steps.provision.GuestSshData):
Submitting user must be a submission delegate for the ``USERNAME``.
""")

public_keys: Optional[list[str]] = field(
default=None,
option='--public-keys',
metavar='PUBLICKEYS',
help="""
If set, Beaker jobs will be submitted on behalf of ``USERNAME``.
Submitting user must be a submission delegate for the ``USERNAME``.
""",
normalize=tmt.utils.normalize_string_list)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • public_key + public-key + multiple=True. There is already key/--key key, a singular form, and on the command line I can use it multiple times (--key foo --key bar --public-key baz ...)
  • default_factory=list will be better: it's a list, and an empty list is as good indication of "no keys to install" as None, but it's simpler because it's still just a list. So, list[str] + default_factory=list should work perfectly.
  • help seems to be copy-pasted & deserves an update.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated^^ 83d8781



@dataclasses.dataclass
class ProvisionBeakerData(BeakerGuestData, tmt.steps.provision.ProvisionStepData):
Expand Down Expand Up @@ -901,6 +911,7 @@ class CreateJobParameters:
kickstart: dict[str, str]
whiteboard: Optional[str]
beaker_job_owner: Optional[str]
public_keys: Optional[list[str]]
group: str = 'linux'

def to_mrack(self) -> dict[str, Any]:
Expand All @@ -911,6 +922,8 @@ def to_mrack(self) -> dict[str, Any]:
if self.kickstart:
data['beaker']['ks_meta'] = self.kickstart.get('metadata')
data['beaker']['ks_append'] = self.kickstart
if self.public_keys:
data['beaker']['pubkeys'] = self.public_keys

return data

Expand Down Expand Up @@ -1090,7 +1103,8 @@ def _create(self, tmt_name: str) -> None:
os=self.image,
name=f'{self.image}-{self.arch}',
whiteboard=self.whiteboard or tmt_name,
beaker_job_owner=self.beaker_job_owner)
beaker_job_owner=self.beaker_job_owner,
public_keys=self.public_keys)

try:
response = self.api.create(data)
Expand Down